Spaces:
Runtime error
Runtime error
Commit
·
29844b7
1
Parent(s):
3a8ec99
update prompt
Browse files
app.py
CHANGED
@@ -491,9 +491,8 @@ prompthead_openai_OR = \
|
|
491 |
You are a helpful AI assistant.
|
492 |
"""
|
493 |
prompthead_openai = \
|
494 |
-
"""
|
495 |
-
|
496 |
-
You must always search information in vector database first and try to answer the question based on the information in vector database only.
|
497 |
Only when there is no information available from vector database, you can search information by using other tools."""
|
498 |
|
499 |
|
@@ -745,7 +744,43 @@ def chathmi3(message, history2):
|
|
745 |
print("History2: ", history2)
|
746 |
print("-" * 20)
|
747 |
print("-" * 20)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
748 |
|
|
|
|
|
|
|
|
|
|
|
|
|
749 |
def fake(message, history4):
|
750 |
pass
|
751 |
|
@@ -889,6 +924,8 @@ with gr.Blocks() as demo:
|
|
889 |
then(HMI_Runing, None, [submit_button, stop_button]).\
|
890 |
then(playsound, None, voice_output).\
|
891 |
then(HMI_Wait, None, [submit_button, stop_button])
|
|
|
|
|
892 |
inf3 = submit_button.click(chathmi3, [inputtext, chatbot], [inputtext, chatbot]).\
|
893 |
then(HMI_Runing, None, [submit_button, stop_button]).\
|
894 |
then(playsound, None, voice_output).\
|
|
|
491 |
You are a helpful AI assistant.
|
492 |
"""
|
493 |
prompthead_openai = \
|
494 |
+
"""You are a helpful AI assistant to answer the following questions as best you can.
|
495 |
+
You must always search information in vector database first and try your best to answer the question based on the information in vector database only.
|
|
|
496 |
Only when there is no information available from vector database, you can search information by using other tools."""
|
497 |
|
498 |
|
|
|
744 |
print("History2: ", history2)
|
745 |
print("-" * 20)
|
746 |
print("-" * 20)
|
747 |
+
|
748 |
+
def chathmi4(message, history2):
|
749 |
+
global last_request
|
750 |
+
global Filename_Chatbot
|
751 |
+
print("Input Message:", message)
|
752 |
+
last_request = message
|
753 |
+
history2 = history2 + [(message, None)]
|
754 |
+
yield ["", history2, gr.update(visible = False), gr.update(visible = True)]
|
755 |
+
try:
|
756 |
+
response = agent.run(message)
|
757 |
+
time.sleep(0.1)
|
758 |
+
history2 = history2 + [(None, response)]
|
759 |
+
yield ["", history2, gr.update(visible = True), gr.update(visible = False)]
|
760 |
+
print ("response of chatbot:", response)
|
761 |
+
# real_content = response[-1:]
|
762 |
+
# print("real_content", real_content)
|
763 |
+
try:
|
764 |
+
temp = response.split("(sandbox:/")[1] # (sandbox:/sample-20230805-0807.wav)
|
765 |
+
file_name = temp.split(")")[0]
|
766 |
+
print("file_name:", file_name)
|
767 |
+
history2 = history2 + [(None, (file_name,))]
|
768 |
+
Filename_Chatbot = file_name
|
769 |
+
yield ["", history2, None, None]
|
770 |
+
except:
|
771 |
+
print("No need to add file in chatbot")
|
772 |
+
|
773 |
+
except Exception as e:
|
774 |
+
print("chathmi3 error:", e)
|
775 |
+
|
776 |
+
# history = history + [(message, None)]
|
777 |
|
778 |
+
print("History2: ", history2)
|
779 |
+
print("-" * 20)
|
780 |
+
print("-" * 20)
|
781 |
+
|
782 |
+
|
783 |
+
|
784 |
def fake(message, history4):
|
785 |
pass
|
786 |
|
|
|
924 |
then(HMI_Runing, None, [submit_button, stop_button]).\
|
925 |
then(playsound, None, voice_output).\
|
926 |
then(HMI_Wait, None, [submit_button, stop_button])
|
927 |
+
inf4 = inputtext.submit(chathmi4, [inputtext, chatbot], [inputtext, chatbot, submit_button, stop_button]).\
|
928 |
+
then(playsound, None, voice_output)
|
929 |
inf3 = submit_button.click(chathmi3, [inputtext, chatbot], [inputtext, chatbot]).\
|
930 |
then(HMI_Runing, None, [submit_button, stop_button]).\
|
931 |
then(playsound, None, voice_output).\
|