Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -51,19 +51,21 @@ def qa_bot():
|
|
51 |
qa = retrieval_QA_chain(llm, qa_prompt, db)
|
52 |
return qa
|
53 |
|
54 |
-
|
|
|
|
|
55 |
try:
|
56 |
-
|
57 |
-
response = qa({'query': query})
|
58 |
answer = response["result"]
|
59 |
sources = response["source_documents"]
|
60 |
if sources:
|
61 |
answer += f"\nSources:" + str(sources)
|
62 |
else:
|
63 |
answer += "\nNo sources found"
|
64 |
-
|
65 |
except Exception as e:
|
66 |
-
|
|
|
67 |
|
68 |
with gr.Blocks() as demo:
|
69 |
chatbot = gr.Chatbot()
|
|
|
51 |
qa = retrieval_QA_chain(llm, qa_prompt, db)
|
52 |
return qa
|
53 |
|
54 |
+
bot = qa_bot()
|
55 |
+
|
56 |
+
def chatbot_response(message, history):
|
57 |
try:
|
58 |
+
response = bot({'query': message})
|
|
|
59 |
answer = response["result"]
|
60 |
sources = response["source_documents"]
|
61 |
if sources:
|
62 |
answer += f"\nSources:" + str(sources)
|
63 |
else:
|
64 |
answer += "\nNo sources found"
|
65 |
+
history.append((message, answer))
|
66 |
except Exception as e:
|
67 |
+
history.append((message, f"An error occurred: {str(e)}"))
|
68 |
+
return history, history
|
69 |
|
70 |
with gr.Blocks() as demo:
|
71 |
chatbot = gr.Chatbot()
|