ruisp commited on
Commit
2fba5f4
1 Parent(s): 9bb38f8

Changed flagging options.

Browse files
Files changed (1) hide show
  1. public_app.py +5 -4
public_app.py CHANGED
@@ -61,10 +61,11 @@ def get_chain(query, api_key=os.environ['OPENAI_API_KEY']):
61
  else:
62
  filter_date = json.loads(date_response)
63
  logging.info(f'Date parameters retrieved: {filter_date}')
64
- if int(filter_date['year']) > 2023 and int(filter_date['month']) > 6 | (
65
- int(filter_date['year']) == 1936 and int(filter_date['month']) < 3) | int(filter_date['year']) < 1936:
 
66
  return 'Date is in the future or it is before the earliest of the publicly available records.' \
67
- 'If you believe this is wrong, please flag below as appropriate.'
68
  filtered_context = search_with_filter(vs, query, init_k=200, step=500, target_k=7, filter_dict=filter_date)
69
  logging.info(20 * '-' + 'Metadata for the documents to be used' + 20 * '-')
70
  for doc in filtered_context:
@@ -93,7 +94,7 @@ if __name__ == '__main__':
93
  'during periods of heavy usage. There is still significant work planned ahead. Please be patient :)',
94
  analytics_enabled=True,
95
  allow_flagging="manual",
96
- flagging_options=["error", "ambiguous", "not true"],
97
  outputs=gr.Textbox(lines=1, label='Answer'),
98
  title='Search the FED minutes archive',
99
  examples=FedMinutesSearch,
 
61
  else:
62
  filter_date = json.loads(date_response)
63
  logging.info(f'Date parameters retrieved: {filter_date}')
64
+ if 'year' not in filter_date:
65
+ return 'Please add a specific year to the month.'
66
+ elif (int(filter_date['year']) > 2023 and int(filter_date['month']) > 6) or (int(filter_date['year']) == 1936 and int(filter_date['month']) < 3) or int(filter_date['year']) < 1936:
67
  return 'Date is in the future or it is before the earliest of the publicly available records.' \
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:
 
94
  'during periods of heavy usage. There is still significant work planned ahead. Please be patient :)',
95
  analytics_enabled=True,
96
  allow_flagging="manual",
97
+ flagging_options=["error", "not useful", "not true"],
98
  outputs=gr.Textbox(lines=1, label='Answer'),
99
  title='Search the FED minutes archive',
100
  examples=FedMinutesSearch,