ruisp commited on
Commit
a0c26e3
1 Parent(s): 879d8fc

Added examples and replaced raising error with explicit information.

Browse files
Files changed (2) hide show
  1. examples.py +6 -0
  2. public_app.py +6 -9
examples.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ FedMinutesSearch = [['Summarize the monetary policy outlook discussed by the participants during the meeting of June 2023 in three paragraphs.'],
2
+ ['Who were the voting members present in the meeting of March 2023?'],
3
+ ['What was the economic outlook from the staff presented in the meeting '
4
+ 'of April 2009 with respect to labour market developments and industrial production?'],
5
+ ['How important was the pandemic of Covid-19 in the discussions during 2020 for the effects of monetary policy?'],
6
+ ['What was the impact of the oil crisis for the economic outlook during 1973?']]
public_app.py CHANGED
@@ -11,6 +11,7 @@ from langchain.chat_models import ChatOpenAI
11
 
12
  from prompts import PROMPT_EXTRACT_DATE, PROMPT_FED_ANALYST
13
  from filterminutes import search_with_filter
 
14
 
15
  # --------------------------Load the sentence transformer and the vector store--------------------------#
16
  model_name = 'sentence-transformers/all-mpnet-base-v2'
@@ -54,7 +55,8 @@ def get_chain(query, api_key=os.environ['OPENAI_API_KEY']):
54
  date_response = date_extractor.run(query)
55
  if date_response == 'False':
56
  logging.info('No date elements found. Running the qa without filtering can output incorrect results.')
57
- raise gr.Error('No date elements found. Please include temporal references in in your query.')
 
58
  else:
59
  filter_date = json.loads(date_response)
60
  logging.info(f'Date parameters retrieved: {filter_date}')
@@ -78,8 +80,8 @@ if __name__ == '__main__':
78
  'tuned to focus on economic, '
79
  'cultural, financial, and political developments occurring at a given time.'
80
  ' The model actively looks for the presence of date elements in the query '
81
- 'and will raise an error if it cannot find them to minimize the risk of model '
82
- 'hallucination. Nevertheless the usual caveats for application making use of generative AI apply.'
83
  ' Click the query examples below to see some possible outputs from the model.',
84
  article='**Disclaimer**: This app is for demonstration purposes only, and no assurance of uninterrupted'
85
  ' functionality can be given at this time. Answers may take some'
@@ -90,12 +92,7 @@ if __name__ == '__main__':
90
  flagging_options=["error", "ambiguous", "not useful"],
91
  outputs=gr.Textbox(lines=1, label='Answer'),
92
  title='Search the FED minutes',
93
- examples=[['Summarize the monetary policy outlook discussed by the participants during the meeting of June 2023 in three paragraphs.'],
94
- ['Who were the voting members present in the meeting of March 2023?'],
95
- ['What was the economic outlook from the staff presented in the meeting '
96
- 'of April 2009 with respect to labour market developments and industrial production?'],
97
- ['How important was the pandemic of Covid-19 in the discussions during 2020 for the effects of monetary policy?'],
98
- ['What was the impact of the oil crisis for the economic outlook during 1973?']],
99
  cache_examples=True
100
  )
101
  app.queue(concurrency_count=2)
 
11
 
12
  from prompts import PROMPT_EXTRACT_DATE, PROMPT_FED_ANALYST
13
  from filterminutes import search_with_filter
14
+ from examples import FedMinutesSearch
15
 
16
  # --------------------------Load the sentence transformer and the vector store--------------------------#
17
  model_name = 'sentence-transformers/all-mpnet-base-v2'
 
55
  date_response = date_extractor.run(query)
56
  if date_response == 'False':
57
  logging.info('No date elements found. Running the qa without filtering can output incorrect results.')
58
+ return 'No date elements found. Please include temporal references in your query. ' \
59
+ 'If you believe this is wrong, please flag below as appropriate.'
60
  else:
61
  filter_date = json.loads(date_response)
62
  logging.info(f'Date parameters retrieved: {filter_date}')
 
80
  'tuned to focus on economic, '
81
  'cultural, financial, and political developments occurring at a given time.'
82
  ' The model actively looks for the presence of date elements in the query '
83
+ 'and will stop the execution if cannot find them to minimize the risk of model '
84
+ 'hallucination. Nevertheless, the usual caveats for application making use of generative AI apply.'
85
  ' Click the query examples below to see some possible outputs from the model.',
86
  article='**Disclaimer**: This app is for demonstration purposes only, and no assurance of uninterrupted'
87
  ' functionality can be given at this time. Answers may take some'
 
92
  flagging_options=["error", "ambiguous", "not useful"],
93
  outputs=gr.Textbox(lines=1, label='Answer'),
94
  title='Search the FED minutes',
95
+ examples=FedMinutesSearch,
 
 
 
 
 
96
  cache_examples=True
97
  )
98
  app.queue(concurrency_count=2)