Spaces:
Runtime error
Runtime error
Commit
·
2d0e444
1
Parent(s):
639a660
ADD REMOTE GPT4
Browse files
app.py
CHANGED
|
@@ -94,7 +94,7 @@ async def start_playwright(question: str):
|
|
| 94 |
output_history = "NOTHING"
|
| 95 |
for i in range(40):
|
| 96 |
output_text = await page.locator("//div[@aria-label='Chat message from assistant']").last.inner_text()
|
| 97 |
-
print("output_text... :"
|
| 98 |
|
| 99 |
if output_text == output_history and '▌' not in output_text:
|
| 100 |
return output_text
|
|
@@ -902,6 +902,42 @@ def chathmi4(message, history2):
|
|
| 902 |
print("-" * 20)
|
| 903 |
print("-" * 20)
|
| 904 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 905 |
|
| 906 |
|
| 907 |
def fake(message, history4):
|
|
@@ -1141,9 +1177,15 @@ with gr.Blocks() as demo:
|
|
| 1141 |
# then(playsound, None, voice_output).\
|
| 1142 |
# then(HMI_Wait, None, [submit_button, stop_button])
|
| 1143 |
# inf4 = inputtext.submit(chathmi4, [inputtext, chatbot], [inputtext, chatbot, submit_button, stop_button])
|
| 1144 |
-
|
| 1145 |
-
|
|
|
|
| 1146 |
# success(ClearAudio, None, voice_output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1147 |
inf3 = submit_button.click(chathmi3, [inputtext, chatbot], [inputtext, chatbot]).\
|
| 1148 |
success(HMI_Runing, None, [submit_button, stop_button]).\
|
| 1149 |
success(playsound1, None, voice_output).\
|
|
|
|
| 94 |
output_history = "NOTHING"
|
| 95 |
for i in range(40):
|
| 96 |
output_text = await page.locator("//div[@aria-label='Chat message from assistant']").last.inner_text()
|
| 97 |
+
print("output_text... :")
|
| 98 |
|
| 99 |
if output_text == output_history and '▌' not in output_text:
|
| 100 |
return output_text
|
|
|
|
| 902 |
print("-" * 20)
|
| 903 |
print("-" * 20)
|
| 904 |
|
| 905 |
+
def chatremote(message, history2):
|
| 906 |
+
global last_request
|
| 907 |
+
global Filename_Chatbot
|
| 908 |
+
print("Input Message:", message)
|
| 909 |
+
last_request = message
|
| 910 |
+
history2 = history2 + [(message, None)]
|
| 911 |
+
yield ["", history2, gr.update(visible = False), gr.update(visible = True)]
|
| 912 |
+
# yield ["", history2, "SUBMIT", "STOP"]
|
| 913 |
+
try:
|
| 914 |
+
# response = agent.run(message)
|
| 915 |
+
response = asyncio.run(start_playwright(message))
|
| 916 |
+
time.sleep(0.1)
|
| 917 |
+
history2 = history2 + [(None, response)]
|
| 918 |
+
yield ["", history2, gr.update(visible = True), gr.update(visible = False)]
|
| 919 |
+
# yield ["", history2, None, None]
|
| 920 |
+
print ("response of chatbot remote:", response)
|
| 921 |
+
# real_content = response[-1:]
|
| 922 |
+
# print("real_content", real_content)
|
| 923 |
+
try:
|
| 924 |
+
temp = response.split("(sandbox:/")[1] # (sandbox:/sample-20230805-0807.wav)
|
| 925 |
+
file_name = temp.split(")")[0]
|
| 926 |
+
print("file_name:", file_name)
|
| 927 |
+
history2 = history2 + [(None, (file_name,))]
|
| 928 |
+
Filename_Chatbot = file_name
|
| 929 |
+
yield ["", history2, "SUBMIT", "STOP"]
|
| 930 |
+
except:
|
| 931 |
+
print("No need to add file in chatbot")
|
| 932 |
+
|
| 933 |
+
except Exception as e:
|
| 934 |
+
print("chathmi remote error:", e)
|
| 935 |
+
|
| 936 |
+
# history = history + [(message, None)]
|
| 937 |
+
|
| 938 |
+
print("History2: ", history2)
|
| 939 |
+
print("-" * 20)
|
| 940 |
+
print("-" * 20)
|
| 941 |
|
| 942 |
|
| 943 |
def fake(message, history4):
|
|
|
|
| 1177 |
# then(playsound, None, voice_output).\
|
| 1178 |
# then(HMI_Wait, None, [submit_button, stop_button])
|
| 1179 |
# inf4 = inputtext.submit(chathmi4, [inputtext, chatbot], [inputtext, chatbot, submit_button, stop_button])
|
| 1180 |
+
''' open ai '''
|
| 1181 |
+
# inf4 = inputtext.submit(chathmi4, [inputtext, chatbot], [inputtext, chatbot, submit_button, stop_button]).\
|
| 1182 |
+
# success(playsound1, None, voice_output)#.\
|
| 1183 |
# success(ClearAudio, None, voice_output)
|
| 1184 |
+
|
| 1185 |
+
''' GPT4 Remote '''
|
| 1186 |
+
inf4 = inputtext.submit(chathmi4, [inputtext, chatbot], [inputtext, chatbot, submit_button, stop_button]).\
|
| 1187 |
+
success(playsound1, None, voice_output)
|
| 1188 |
+
|
| 1189 |
inf3 = submit_button.click(chathmi3, [inputtext, chatbot], [inputtext, chatbot]).\
|
| 1190 |
success(HMI_Runing, None, [submit_button, stop_button]).\
|
| 1191 |
success(playsound1, None, voice_output).\
|