captain-awesome commited on
Commit
32fb2ab
·
1 Parent(s): e4e5ceb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -283,8 +283,12 @@ def retrieve_bot_answer(query, loaded_documents):
283
  """
284
  qa_bot_instance = create_retrieval_qa_bot(loaded_documents)
285
  bot_response = qa_bot_instance({"question": query})
286
- answer = bot_response['answer']
287
- return answer
 
 
 
 
288
 
289
 
290
  # from your_module import load_model, set_custom_prompt, set_custom_prompt_condense, create_vector_database, retrieve_bot_answer
 
283
  """
284
  qa_bot_instance = create_retrieval_qa_bot(loaded_documents)
285
  bot_response = qa_bot_instance({"question": query})
286
+ # Check if the 'answer' key exists in the bot_response dictionary
287
+ if 'answer' in bot_response:
288
+ answer = bot_response['answer']
289
+ return answer
290
+ else:
291
+ raise KeyError("Expected 'answer' key in bot_response, but it was not found.")
292
 
293
 
294
  # from your_module import load_model, set_custom_prompt, set_custom_prompt_condense, create_vector_database, retrieve_bot_answer