Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,23 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from rag import respond_rag_huggingface as response_hf
|
| 3 |
|
| 4 |
-
|
| 5 |
|
| 6 |
def respond(message):
|
| 7 |
-
|
|
|
|
| 8 |
chat_history.append((message, response))
|
| 9 |
return "", chat_history
|
| 10 |
|
| 11 |
with gr.Blocks() as demo:
|
| 12 |
gr.Markdown("# Game of Thrones Q&A bot")
|
| 13 |
|
| 14 |
-
chatbot = gr.Chatbot()
|
| 15 |
-
msg = gr.Textbox(label="
|
| 16 |
-
|
| 17 |
-
|
| 18 |
|
| 19 |
clear = gr.Button("Clear")
|
| 20 |
|
| 21 |
-
msg.submit(respond, [msg], [msg, chatbot])
|
| 22 |
clear.click(lambda: ([], ""), None, [chatbot, msg])
|
|
|
|
| 23 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from rag import respond_rag_huggingface as response_hf
|
| 3 |
|
| 4 |
+
chat_history = []
|
| 5 |
|
| 6 |
def respond(message):
|
| 7 |
+
global chat_history
|
| 8 |
+
response = response_hf(message)
|
| 9 |
chat_history.append((message, response))
|
| 10 |
return "", chat_history
|
| 11 |
|
| 12 |
with gr.Blocks() as demo:
|
| 13 |
gr.Markdown("# Game of Thrones Q&A bot")
|
| 14 |
|
| 15 |
+
chatbot = gr.Chatbot(label="Chat History")
|
| 16 |
+
msg = gr.Textbox(label="Write something about Game of Thrones here...")
|
|
|
|
|
|
|
| 17 |
|
| 18 |
clear = gr.Button("Clear")
|
| 19 |
|
| 20 |
+
msg.submit(respond, inputs=[msg], outputs=[msg, chatbot])
|
| 21 |
clear.click(lambda: ([], ""), None, [chatbot, msg])
|
| 22 |
+
|
| 23 |
demo.launch()
|