Spaces:
Runtime error
Runtime error
Caught the exception when the there are zero documents returned.
Browse files- public_app.py +3 -0
public_app.py
CHANGED
@@ -68,6 +68,9 @@ def get_chain(query, api_key=os.environ['OPENAI_API_KEY']):
|
|
68 |
' If you believe this is wrong, please flag below as appropriate.'
|
69 |
filtered_context = search_with_filter(vs, query, init_k=200, step=500, target_k=7, filter_dict=filter_date)
|
70 |
logging.info(20 * '-' + 'Metadata for the documents to be used' + 20 * '-')
|
|
|
|
|
|
|
71 |
for doc in filtered_context:
|
72 |
logging.info(doc.metadata)
|
73 |
return fed_chain({'input_documents': filtered_context[:7], 'question': query})['output_text']
|
|
|
68 |
' If you believe this is wrong, please flag below as appropriate.'
|
69 |
filtered_context = search_with_filter(vs, query, init_k=200, step=500, target_k=7, filter_dict=filter_date)
|
70 |
logging.info(20 * '-' + 'Metadata for the documents to be used' + 20 * '-')
|
71 |
+
if len(filtered_context) == 0:
|
72 |
+
return 'There is no information in the minutes for the given date. Please check if there were was an FOMC ' \
|
73 |
+
'meeting on the given date. If you believe this is wrong, please flag below as appropriate.'
|
74 |
for doc in filtered_context:
|
75 |
logging.info(doc.metadata)
|
76 |
return fed_chain({'input_documents': filtered_context[:7], 'question': query})['output_text']
|