Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -25,10 +25,8 @@ def respond(message, history):
|
|
25 |
if cfg.streaming:
|
26 |
# Call stream response and stream output
|
27 |
stream = vq.submit_query_streaming(message)
|
28 |
-
outputs = ""
|
29 |
for output in stream:
|
30 |
-
|
31 |
-
yield outputs
|
32 |
else:
|
33 |
# Call non-stream response and return message output
|
34 |
response = vq.submit_query(message)
|
@@ -74,11 +72,19 @@ with gr.Blocks(css=bot_css) as demo:
|
|
74 |
def bot(history):
|
75 |
message = history[-1][0]
|
76 |
bot_message = respond(message, history)
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
81 |
-
bot, chatbot, chatbot
|
82 |
)
|
83 |
|
84 |
clear.click(lambda: None, None, chatbot, queue=False)
|
|
|
25 |
if cfg.streaming:
|
26 |
# Call stream response and stream output
|
27 |
stream = vq.submit_query_streaming(message)
|
|
|
28 |
for output in stream:
|
29 |
+
yield output
|
|
|
30 |
else:
|
31 |
# Call non-stream response and return message output
|
32 |
response = vq.submit_query(message)
|
|
|
72 |
def bot(history):
|
73 |
message = history[-1][0]
|
74 |
bot_message = respond(message, history)
|
75 |
+
|
76 |
+
if cfg.streaming:
|
77 |
+
full_response = ""
|
78 |
+
for chunk in bot_message:
|
79 |
+
full_response += chunk
|
80 |
+
history[-1][1] = full_response
|
81 |
+
yield history
|
82 |
+
else:
|
83 |
+
history[-1][1] = next(bot_message)
|
84 |
+
yield history
|
85 |
|
86 |
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
87 |
+
bot, chatbot, chatbot, api_name="bot_response"
|
88 |
)
|
89 |
|
90 |
clear.click(lambda: None, None, chatbot, queue=False)
|