Spaces:
Runtime error
Runtime error
Commit
·
597abe5
1
Parent(s):
2abf9ae
Update app.py
Browse files
app.py
CHANGED
@@ -298,15 +298,20 @@ def retrieve_bot_answer(query, loaded_documents):
|
|
298 |
qa_bot_instance = create_retrieval_qa_bot(loaded_documents)
|
299 |
bot_response = qa_bot_instance({"question": query})
|
300 |
# Check if the 'answer' key exists in the bot_response dictionary
|
301 |
-
if 'answer' in bot_response:
|
302 |
-
|
303 |
-
|
304 |
-
else:
|
305 |
-
|
306 |
-
|
|
|
|
|
|
|
|
|
307 |
|
308 |
# from your_module import load_model, set_custom_prompt, set_custom_prompt_condense, create_vector_database, retrieve_bot_answer
|
309 |
|
|
|
310 |
def main():
|
311 |
|
312 |
st.title("Docuverse")
|
@@ -353,11 +358,12 @@ def main():
|
|
353 |
CONDENSE_QUESTION_PROMPT = set_custom_prompt_condense()
|
354 |
db = create_vector_database(loaded_documents)
|
355 |
# st.write(f"db: {db}")
|
356 |
-
|
357 |
# st.write(f"response: {response}")
|
358 |
# Display bot response
|
359 |
st.write("Bot Response:")
|
360 |
-
st.write(
|
|
|
361 |
except Exception as e:
|
362 |
st.error(f"An error occurred: {str(e)}")
|
363 |
else:
|
|
|
298 |
qa_bot_instance = create_retrieval_qa_bot(loaded_documents)
|
299 |
bot_response = qa_bot_instance({"question": query})
|
300 |
# Check if the 'answer' key exists in the bot_response dictionary
|
301 |
+
# if 'answer' in bot_response:
|
302 |
+
# # answer = bot_response['answer']
|
303 |
+
# return bot_response
|
304 |
+
# else:
|
305 |
+
# raise KeyError("Expected 'answer' key in bot_response, but it was not found.")
|
306 |
+
result = bot_response['result']
|
307 |
+
sources = []
|
308 |
+
for source in bot_response["source_documents"]:
|
309 |
+
sources.append(source.metadata['source'])
|
310 |
+
return result, sources
|
311 |
|
312 |
# from your_module import load_model, set_custom_prompt, set_custom_prompt_condense, create_vector_database, retrieve_bot_answer
|
313 |
|
314 |
+
|
315 |
def main():
|
316 |
|
317 |
st.title("Docuverse")
|
|
|
358 |
CONDENSE_QUESTION_PROMPT = set_custom_prompt_condense()
|
359 |
db = create_vector_database(loaded_documents)
|
360 |
# st.write(f"db: {db}")
|
361 |
+
result, sources = retrieve_bot_answer(query,loaded_documents)
|
362 |
# st.write(f"response: {response}")
|
363 |
# Display bot response
|
364 |
st.write("Bot Response:")
|
365 |
+
st.write(result)
|
366 |
+
st.write(sources)
|
367 |
except Exception as e:
|
368 |
st.error(f"An error occurred: {str(e)}")
|
369 |
else:
|