Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -85,9 +85,11 @@ class RAGChatbot:
|
|
| 85 |
# Generate response
|
| 86 |
response = self.generate_response(query, context)
|
| 87 |
|
| 88 |
-
return
|
|
|
|
|
|
|
| 89 |
except Exception as e:
|
| 90 |
-
return f"An error occurred: {str(e)}"
|
| 91 |
|
| 92 |
# Create Gradio interface
|
| 93 |
def create_interface():
|
|
@@ -117,21 +119,13 @@ def create_interface():
|
|
| 117 |
submit_btn.click(
|
| 118 |
rag_chatbot.chat,
|
| 119 |
inputs=[msg, chatbot],
|
| 120 |
-
outputs=[chatbot]
|
| 121 |
-
).then(
|
| 122 |
-
lambda: gr.Textbox(interactive=True),
|
| 123 |
-
None,
|
| 124 |
-
[msg]
|
| 125 |
)
|
| 126 |
|
| 127 |
msg.submit(
|
| 128 |
rag_chatbot.chat,
|
| 129 |
inputs=[msg, chatbot],
|
| 130 |
-
outputs=[chatbot]
|
| 131 |
-
).then(
|
| 132 |
-
lambda: gr.Textbox(interactive=True),
|
| 133 |
-
None,
|
| 134 |
-
[msg]
|
| 135 |
)
|
| 136 |
|
| 137 |
clear_btn.click(lambda: None, None, [chatbot, msg])
|
|
|
|
| 85 |
# Generate response
|
| 86 |
response = self.generate_response(query, context)
|
| 87 |
|
| 88 |
+
# Append to history and return as list of tuples
|
| 89 |
+
updated_history = history + [[query, response]]
|
| 90 |
+
return updated_history
|
| 91 |
except Exception as e:
|
| 92 |
+
return history + [[query, f"An error occurred: {str(e)}"]]
|
| 93 |
|
| 94 |
# Create Gradio interface
|
| 95 |
def create_interface():
|
|
|
|
| 119 |
submit_btn.click(
|
| 120 |
rag_chatbot.chat,
|
| 121 |
inputs=[msg, chatbot],
|
| 122 |
+
outputs=[chatbot, msg]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
)
|
| 124 |
|
| 125 |
msg.submit(
|
| 126 |
rag_chatbot.chat,
|
| 127 |
inputs=[msg, chatbot],
|
| 128 |
+
outputs=[chatbot, msg]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
)
|
| 130 |
|
| 131 |
clear_btn.click(lambda: None, None, [chatbot, msg])
|