Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -90,8 +90,7 @@ def handle_query(query, faiss_index, embeddings_texts, model):
|
|
90 |
generated_text = "An error occurred while generating the response."
|
91 |
|
92 |
# Update conversation history
|
93 |
-
conversation_history.append(
|
94 |
-
conversation_history.append(f"System: {generated_text}")
|
95 |
|
96 |
# Extract sources
|
97 |
sources = [url for _, url in relevant_texts]
|
@@ -129,7 +128,9 @@ def chatbot(message, history):
|
|
129 |
print("Query:", message)
|
130 |
print("Response:", response)
|
131 |
|
132 |
-
|
|
|
|
|
133 |
|
134 |
if sources:
|
135 |
print("Sources:", sources)
|
@@ -167,4 +168,4 @@ iface = gr.ChatInterface(
|
|
167 |
)
|
168 |
|
169 |
if __name__ == "__main__":
|
170 |
-
iface.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
90 |
generated_text = "An error occurred while generating the response."
|
91 |
|
92 |
# Update conversation history
|
93 |
+
conversation_history.append((query, generated_text))
|
|
|
94 |
|
95 |
# Extract sources
|
96 |
sources = [url for _, url in relevant_texts]
|
|
|
128 |
print("Query:", message)
|
129 |
print("Response:", response)
|
130 |
|
131 |
+
# Display past queries and responses
|
132 |
+
total_text = "\n\n".join([f"User: {query}\nSystem: {resp}" for query, resp in conversation_history])
|
133 |
+
total_text += f"\n\nUser: {message}\nSystem: {response if response else 'No response generated.'}"
|
134 |
|
135 |
if sources:
|
136 |
print("Sources:", sources)
|
|
|
168 |
)
|
169 |
|
170 |
if __name__ == "__main__":
|
171 |
+
iface.launch(server_name="0.0.0.0", server_port=7860)
|