Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -70,7 +70,8 @@ def chat_with_ai(user_input, chat_history):
|
|
70 |
chat_history.append((user_input, response['answer']))
|
71 |
|
72 |
return chat_history, ""
|
73 |
-
|
|
|
74 |
def gradio_chatbot():
|
75 |
with gr.Blocks() as demo:
|
76 |
gr.Markdown("# Chat Interface for Langchain")
|
@@ -81,11 +82,13 @@ def gradio_chatbot():
|
|
81 |
)
|
82 |
|
83 |
submit_button = gr.Button("Send")
|
84 |
-
|
85 |
chat_history = gr.State([])
|
86 |
|
87 |
submit_button.click(chat_with_ai, inputs=[user_input, chat_history], outputs=[chatbot, user_input])
|
88 |
user_input.submit(chat_with_ai, inputs=[user_input, chat_history], outputs=[chatbot, user_input])
|
|
|
|
|
89 |
|
90 |
return demo
|
91 |
|
|
|
70 |
chat_history.append((user_input, response['answer']))
|
71 |
|
72 |
return chat_history, ""
|
73 |
+
def clear_history():
|
74 |
+
return [], ""
|
75 |
def gradio_chatbot():
|
76 |
with gr.Blocks() as demo:
|
77 |
gr.Markdown("# Chat Interface for Langchain")
|
|
|
82 |
)
|
83 |
|
84 |
submit_button = gr.Button("Send")
|
85 |
+
btn_clear = gr.Button("Delete Context")
|
86 |
chat_history = gr.State([])
|
87 |
|
88 |
submit_button.click(chat_with_ai, inputs=[user_input, chat_history], outputs=[chatbot, user_input])
|
89 |
user_input.submit(chat_with_ai, inputs=[user_input, chat_history], outputs=[chatbot, user_input])
|
90 |
+
btn_clear.click(fn=clear_history, outputs=[chatbot, user_input])
|
91 |
+
|
92 |
|
93 |
return demo
|
94 |
|