Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -67,14 +67,21 @@ with gr.Blocks() as demo:
|
|
67 |
chatbot = gr.Chatbot()
|
68 |
msg = gr.Textbox()
|
69 |
clear = gr.Button("Clear")
|
|
|
70 |
|
71 |
-
def respond(message, chat_history):
|
72 |
answer, sources = chat_with_langassist(message)
|
73 |
chat_history.append((message, answer))
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
-
msg.submit(respond, [msg, chatbot], [chatbot, msg])
|
77 |
-
clear.click(lambda: None, None, chatbot)
|
78 |
|
79 |
# Run the Gradio app
|
80 |
if __name__ == "__main__":
|
|
|
67 |
chatbot = gr.Chatbot()
|
68 |
msg = gr.Textbox()
|
69 |
clear = gr.Button("Clear")
|
70 |
+
sources_display = gr.Markdown(label="Sources")
|
71 |
|
72 |
+
def respond(message, chat_history, sources_display):
|
73 |
answer, sources = chat_with_langassist(message)
|
74 |
chat_history.append((message, answer))
|
75 |
+
|
76 |
+
if sources:
|
77 |
+
formatted_sources = "\n".join([f"- **Source:** {source['source']}\n **Text:** {source['text']}" for source in sources])
|
78 |
+
else:
|
79 |
+
formatted_sources = "No sources available."
|
80 |
+
|
81 |
+
return chat_history, gr.update(value=''), formatted_sources
|
82 |
|
83 |
+
msg.submit(respond, [msg, chatbot, sources_display], [chatbot, msg, sources_display])
|
84 |
+
clear.click(lambda: None, None, [chatbot, sources_display])
|
85 |
|
86 |
# Run the Gradio app
|
87 |
if __name__ == "__main__":
|