Manasa1 commited on
Commit
0a5f820
·
verified ·
1 Parent(s): 1587b05

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -51,19 +51,21 @@ def qa_bot():
51
  qa = retrieval_QA_chain(llm, qa_prompt, db)
52
  return qa
53
 
54
- def chatbot_response(query):
 
 
55
  try:
56
- qa = qa_bot()
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
- return answer
65
  except Exception as e:
66
- return f"An error occurred: {str(e)}"
 
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()