diff --git a/scripts/langchainapi.py b/scripts/langchainapi.py
index 687c99f..bda9394 100644
--- a/scripts/langchainapi.py
+++ b/scripts/langchainapi.py
@@ -61,6 +61,7 @@ class LangChainApi:
memory_key="history",
return_messages=True,
)
+ self.callback = StreamingLLMCallbackHandler()
self.load_settings(**kwargs)
@@ -68,8 +69,6 @@ class LangChainApi:
if self.backend is None:
return
- self.callback = StreamingLLMCallbackHandler()
-
if self.backend == 'GPT4All':
if (not 'gpt4all_model' in self.settings) or (self.settings['gpt4all_model'] is None):
return
@@ -279,5 +278,7 @@ If you understand, please reply to the following:<|end_of_turn|>
return recieved_dict["message"], recieved_dict["prompt"]
else:
return recieved_dict["message"], None
+ else:
+ return None, None
else:
return None, None
\ No newline at end of file
diff --git a/scripts/main.py b/scripts/main.py
index 4e87e07..0f93613 100644
--- a/scripts/main.py
+++ b/scripts/main.py
@@ -337,11 +337,7 @@ def on_ui_tabs():
chat_gpt_api.remove_last_conversation()
- result, prompt = chat_gpt_api.send(input_text)
-
- chat_history = append_chat_history(chat_history, input_text, result, prompt)
-
- return [last_image_name, info_html, comments_html, info_html.replace('
', '\n').replace('
', '').replace('
', '\n').replace('<', '<').replace('>', '>'), chat_history] + return chat_history def chatgpt_clear(): chat_history_images = {} @@ -522,11 +518,26 @@ def on_ui_tabs(): ).then( fn=chatgpt_generate_finished, outputs=[image_gr, info_html_gr, comments_html_gr, info_text_gr, text_input], - #queue=False, ) - btn_regenerate.click(fn=chatgpt_regenerate, - inputs=chatbot, - outputs=[image_gr, info_html_gr, comments_html_gr, info_text_gr, chatbot]) + btn_regenerate.click( + fn=chatgpt_regenerate, + inputs=chatbot, + outputs=chatbot, + #queue=False, + ).then( + fn=lambda t, c: ['', c + [(t, None)]], + inputs=[text_input, chatbot], + outputs=[text_input, chatbot], + #queue=False, + ).then( + fn=chatgpt_generate, + inputs=chatbot, + outputs=chatbot, + #queue=False, + ).then( + fn=chatgpt_generate_finished, + outputs=[image_gr, info_html_gr, comments_html_gr, info_text_gr, text_input], + ) btn_remove_last.click(fn=chatgpt_remove_last, inputs=[text_input, chatbot], outputs=[text_input, chatbot])