Spaces:
Running
on
T4
Running
on
T4
Chat is a coroutine.
Browse files
app.py
CHANGED
|
@@ -196,6 +196,11 @@ def chat(
|
|
| 196 |
if '\ufffd' not in tmp:
|
| 197 |
print(tmp, end='', flush=True)
|
| 198 |
out_last = begin + i + 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
|
| 200 |
out_str = pipeline.decode(all_tokens[begin:])
|
| 201 |
out_str = out_str.replace("\r\n", '\n').replace('\\n', '\n')
|
|
@@ -208,7 +213,7 @@ def chat(
|
|
| 208 |
|
| 209 |
chatbot[-1][1] = out_str.strip()
|
| 210 |
history = [state, all_tokens]
|
| 211 |
-
|
| 212 |
|
| 213 |
with gr.Blocks(title=title) as demo:
|
| 214 |
with gr.Tab("Generative"):
|
|
@@ -264,7 +269,7 @@ with gr.Blocks(title=title) as demo:
|
|
| 264 |
chat_outputs = [chatbot, state]
|
| 265 |
message.submit(user, [message, chatbot], [message, chatbot], queue=False).then(chat, chat_inputs, chat_outputs)
|
| 266 |
send.click(user, [message, chatbot], [message, chatbot], queue=False).then(chat, chat_inputs, chat_outputs)
|
| 267 |
-
clear.click(lambda: ([], None, ""), [], [chatbot, state, message])
|
| 268 |
|
| 269 |
demo.queue(max_size=10)
|
| 270 |
demo.launch(share=False)
|
|
|
|
| 196 |
if '\ufffd' not in tmp:
|
| 197 |
print(tmp, end='', flush=True)
|
| 198 |
out_last = begin + i + 1
|
| 199 |
+
out_str += tmp
|
| 200 |
+
|
| 201 |
+
chatbot[-1][1] = out_str.strip()
|
| 202 |
+
history = [state, all_tokens]
|
| 203 |
+
yield chatbot, history
|
| 204 |
|
| 205 |
out_str = pipeline.decode(all_tokens[begin:])
|
| 206 |
out_str = out_str.replace("\r\n", '\n').replace('\\n', '\n')
|
|
|
|
| 213 |
|
| 214 |
chatbot[-1][1] = out_str.strip()
|
| 215 |
history = [state, all_tokens]
|
| 216 |
+
yield chatbot, history
|
| 217 |
|
| 218 |
with gr.Blocks(title=title) as demo:
|
| 219 |
with gr.Tab("Generative"):
|
|
|
|
| 269 |
chat_outputs = [chatbot, state]
|
| 270 |
message.submit(user, [message, chatbot], [message, chatbot], queue=False).then(chat, chat_inputs, chat_outputs)
|
| 271 |
send.click(user, [message, chatbot], [message, chatbot], queue=False).then(chat, chat_inputs, chat_outputs)
|
| 272 |
+
clear.click(lambda: ([], None, ""), [], [chatbot, state, message], queue=False)
|
| 273 |
|
| 274 |
demo.queue(max_size=10)
|
| 275 |
demo.launch(share=False)
|