Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,14 +29,9 @@ def get_top_chunks(query):
|
|
| 29 |
return top_chunks
|
| 30 |
|
| 31 |
def chatbot_response(message, history):
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
except Exception as e:
|
| 36 |
-
numbered_response = f"Sorry, something went wrong: {e}"
|
| 37 |
-
history = history or []
|
| 38 |
-
history.append((message, numbered_response))
|
| 39 |
-
return numbered_response, history
|
| 40 |
|
| 41 |
chatbot = gr.ChatInterface(fn=chatbot_response, title="RAG Chatbot")
|
| 42 |
chatbot.launch()
|
|
|
|
| 29 |
return top_chunks
|
| 30 |
|
| 31 |
def chatbot_response(message, history):
|
| 32 |
+
top_chunks = get_top_chunks(message)
|
| 33 |
+
numbered_response = "\n".join([f"{i+1}. {chunk}" for i, chunk in enumerate(top_chunks)])
|
| 34 |
+
return [{"role": "assistant", "content": numbered_response}]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
chatbot = gr.ChatInterface(fn=chatbot_response, title="RAG Chatbot")
|
| 37 |
chatbot.launch()
|