Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -300,6 +300,9 @@ qa = ConversationalRetrievalChain.from_llm(
|
|
| 300 |
)
|
| 301 |
|
| 302 |
|
|
|
|
|
|
|
|
|
|
| 303 |
with gr.Blocks() as demo:
|
| 304 |
chatbot = gr.Chatbot()
|
| 305 |
msg = gr.Textbox()
|
|
@@ -307,7 +310,17 @@ with gr.Blocks() as demo:
|
|
| 307 |
|
| 308 |
def user(user_message, history):
|
| 309 |
return gr.update(value="", interactive=False), history + [[user_message, None]]
|
| 310 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 311 |
response = msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
| 312 |
bot, chatbot, chatbot
|
| 313 |
)
|
|
|
|
| 300 |
)
|
| 301 |
|
| 302 |
|
| 303 |
+
import gradio as gr
|
| 304 |
+
import time
|
| 305 |
+
|
| 306 |
with gr.Blocks() as demo:
|
| 307 |
chatbot = gr.Chatbot()
|
| 308 |
msg = gr.Textbox()
|
|
|
|
| 310 |
|
| 311 |
def user(user_message, history):
|
| 312 |
return gr.update(value="", interactive=False), history + [[user_message, None]]
|
| 313 |
+
|
| 314 |
+
def bot(history):
|
| 315 |
+
response = qa(history[-1][0])
|
| 316 |
+
response = response['answer']
|
| 317 |
+
|
| 318 |
+
history[-1][1] = ""
|
| 319 |
+
for character in response:
|
| 320 |
+
history[-1][1] += character
|
| 321 |
+
time.sleep(0.05)
|
| 322 |
+
yield history
|
| 323 |
+
|
| 324 |
response = msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
| 325 |
bot, chatbot, chatbot
|
| 326 |
)
|