Spaces:
Runtime error
Runtime error
Commit
·
be19420
1
Parent(s):
7c3ceb1
clear func
Browse files
app.py
CHANGED
@@ -61,8 +61,9 @@ from langchain.docstore.document import Document
|
|
61 |
import langchain
|
62 |
|
63 |
langchain.debug = True
|
|
|
64 |
memory = ConversationBufferMemory(memory_key="chat_history")
|
65 |
-
|
66 |
memory_openai = ConversationBufferWindowMemory(memory_key="memory", return_messages=True)
|
67 |
|
68 |
# Custom document loaders
|
@@ -647,7 +648,7 @@ def chathmi3(message, history):
|
|
647 |
temp = response.split("(sandbox:/")[1] # (sandbox:/sample-20230805-0807.wav)
|
648 |
file_name = temp.split(")")[0]
|
649 |
print("file_name:", file_name)
|
650 |
-
history = history + [((file_name,)
|
651 |
yield ["", history]
|
652 |
except:
|
653 |
print("No need to add file in chatbot")
|
@@ -664,6 +665,14 @@ def chathmi3(message, history):
|
|
664 |
def fake(message, history):
|
665 |
pass
|
666 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
667 |
with gr.Blocks() as demo:
|
668 |
# gr.Markdown("Start typing below and then click **SUBMIT** to see the output.")
|
669 |
# main = gr.ChatInterface(
|
@@ -704,6 +713,8 @@ with gr.Blocks() as demo:
|
|
704 |
scale= 1,
|
705 |
interactive=False,
|
706 |
autoplay= True)
|
|
|
|
|
707 |
with gr.Accordion(
|
708 |
label = "LOGS",
|
709 |
open = False,
|
@@ -712,6 +723,8 @@ with gr.Blocks() as demo:
|
|
712 |
frash_logs = gr.Button("Update Logs ...")
|
713 |
logs = gr.Textbox(max_lines = 25)
|
714 |
# upload_button.upload(func_upload_file, [upload_button, main.chatbot], main.chatbot)
|
|
|
|
|
715 |
inf1 = inputtext.submit(chathmi3, [inputtext, chatbot], [inputtext, chatbot])
|
716 |
stop_button.click(read_logs, None, logs, cancels=[inf1])
|
717 |
upload_button.upload(func_upload_file, [upload_button, chatbot], chatbot)
|
|
|
61 |
import langchain
|
62 |
|
63 |
langchain.debug = True
|
64 |
+
global memory
|
65 |
memory = ConversationBufferMemory(memory_key="chat_history")
|
66 |
+
global memory_openai
|
67 |
memory_openai = ConversationBufferWindowMemory(memory_key="memory", return_messages=True)
|
68 |
|
69 |
# Custom document loaders
|
|
|
648 |
temp = response.split("(sandbox:/")[1] # (sandbox:/sample-20230805-0807.wav)
|
649 |
file_name = temp.split(")")[0]
|
650 |
print("file_name:", file_name)
|
651 |
+
history = history + [(None, (file_name,))]
|
652 |
yield ["", history]
|
653 |
except:
|
654 |
print("No need to add file in chatbot")
|
|
|
665 |
def fake(message, history):
|
666 |
pass
|
667 |
|
668 |
+
|
669 |
+
def clearall():
|
670 |
+
global memory_openai
|
671 |
+
global memory
|
672 |
+
memory_openai.clear()
|
673 |
+
memory.clear()
|
674 |
+
return []
|
675 |
+
|
676 |
with gr.Blocks() as demo:
|
677 |
# gr.Markdown("Start typing below and then click **SUBMIT** to see the output.")
|
678 |
# main = gr.ChatInterface(
|
|
|
713 |
scale= 1,
|
714 |
interactive=False,
|
715 |
autoplay= True)
|
716 |
+
retry_button = gr.Button("RETRY")
|
717 |
+
clear_button = gr.Button("CLEAR")
|
718 |
with gr.Accordion(
|
719 |
label = "LOGS",
|
720 |
open = False,
|
|
|
723 |
frash_logs = gr.Button("Update Logs ...")
|
724 |
logs = gr.Textbox(max_lines = 25)
|
725 |
# upload_button.upload(func_upload_file, [upload_button, main.chatbot], main.chatbot)
|
726 |
+
clear_button.click(clearall, None, chatbot)
|
727 |
+
# retry_button.click(alltry, chatbot, chatbot)
|
728 |
inf1 = inputtext.submit(chathmi3, [inputtext, chatbot], [inputtext, chatbot])
|
729 |
stop_button.click(read_logs, None, logs, cancels=[inf1])
|
730 |
upload_button.upload(func_upload_file, [upload_button, chatbot], chatbot)
|