ppsingh commited on
Commit
f0b4f3d
·
verified ·
1 Parent(s): 6f413e7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -14
app.py CHANGED
@@ -111,7 +111,7 @@ class SessionManager:
111
  # Initialize session manager
112
  session_manager = SessionManager()
113
 
114
- async def chat(query,history,sources,reports,subtype,year, client_ip=None, session_id = None, request:gr.Request = None):
115
  """taking a query and a message history, use a pipeline (reformulation, retriever, answering)
116
  to yield a tuple of:(messages in gradio format/messages in langchain format, source documents)
117
  """
@@ -131,7 +131,7 @@ async def chat(query,history,sources,reports,subtype,year, client_ip=None, sessi
131
  print(f"sources:{sources}")
132
  print(f"reports:{reports}")
133
  print(f"subtype:{subtype}")
134
- print(f"year:{year}")
135
  docs_html = ""
136
  output_query = ""
137
 
@@ -140,7 +140,7 @@ async def chat(query,history,sources,reports,subtype,year, client_ip=None, sessi
140
 
141
  ##------------------------------get context----------------------------------------------
142
  context_retrieved = get_context(vectorstore=vectorstore,query=query,reports=reports,
143
- sources=sources,subtype=subtype,year=year)
144
  context_retrieved_formatted = "||".join(doc.page_content for doc in context_retrieved)
145
  context_retrieved_lst = [doc.page_content for doc in context_retrieved]
146
 
@@ -189,8 +189,8 @@ async def chat(query,history,sources,reports,subtype,year, client_ip=None, sessi
189
  # "system_prompt": SYSTEM_PROMPT, #REMOVED FOR TESTING
190
  # "sources": sources, #REMOVED FOR TESTING
191
  # "reports": reports, #REMOVED FOR TESTING
192
- # "subtype": subtype, #REMOVED FOR TESTING
193
- "year": year,
194
  "question": query,
195
  "retriever": model_config.get('retriever','MODEL'),
196
  "endpoint_type": model_config.get('reader','TYPE'),
@@ -350,7 +350,7 @@ with gr.Blocks(title="Audit Q&A", css= "style.css", theme=theme,elem_id = "main-
350
 
351
  #----- First level filter for selecting Report source/category ----------
352
  dropdown_sources = gr.Dropdown(
353
- ["Consolidated","Ministry, Department, Agency and Projects","Local Government","Value for Money","Thematic"],
354
  label="Select Report Category",
355
  value="Consolidated",
356
  interactive=True,
@@ -359,8 +359,9 @@ with gr.Blocks(title="Audit Q&A", css= "style.css", theme=theme,elem_id = "main-
359
  #------ second level filter for selecting subtype within the report category selected above
360
  dropdown_category = gr.Dropdown(
361
  new_files["Consolidated"],
362
- value = new_files["Consolidated"],
363
- label = "Filter for Sub-Type",
 
364
  interactive=True)
365
 
366
  #----------- update the secodn level filter abse don values from first level ----------------
@@ -369,12 +370,12 @@ with gr.Blocks(title="Audit Q&A", css= "style.css", theme=theme,elem_id = "main-
369
  dropdown_sources.change(fn=rs_change, inputs=[dropdown_sources], outputs=[dropdown_category])
370
 
371
  #--------- Select the years for reports -------------------------------------
372
- dropdown_year = gr.Dropdown(
373
- ['2018','2019','2020','2021','2022','2023'],
374
- label="Filter for year",
375
- multiselect=True,
376
- value=['2023'],
377
- interactive=True,
378
  )
379
  gr.Markdown("-------------------------------------------------------------------------")
380
  #---------------- Another way to select reports across category and sub-type ------------
 
111
  # Initialize session manager
112
  session_manager = SessionManager()
113
 
114
+ async def chat(query,history,sources,reports,subtype, client_ip=None, session_id = None, request:gr.Request = None):
115
  """taking a query and a message history, use a pipeline (reformulation, retriever, answering)
116
  to yield a tuple of:(messages in gradio format/messages in langchain format, source documents)
117
  """
 
131
  print(f"sources:{sources}")
132
  print(f"reports:{reports}")
133
  print(f"subtype:{subtype}")
134
+ #print(f"year:{year}")
135
  docs_html = ""
136
  output_query = ""
137
 
 
140
 
141
  ##------------------------------get context----------------------------------------------
142
  context_retrieved = get_context(vectorstore=vectorstore,query=query,reports=reports,
143
+ sources=sources,subtype=subtype)
144
  context_retrieved_formatted = "||".join(doc.page_content for doc in context_retrieved)
145
  context_retrieved_lst = [doc.page_content for doc in context_retrieved]
146
 
 
189
  # "system_prompt": SYSTEM_PROMPT, #REMOVED FOR TESTING
190
  # "sources": sources, #REMOVED FOR TESTING
191
  # "reports": reports, #REMOVED FOR TESTING
192
+ "subtype": subtype, #REMOVED FOR TESTING
193
+ #"year": year,
194
  "question": query,
195
  "retriever": model_config.get('retriever','MODEL'),
196
  "endpoint_type": model_config.get('reader','TYPE'),
 
350
 
351
  #----- First level filter for selecting Report source/category ----------
352
  dropdown_sources = gr.Dropdown(
353
+ ["Consolidated","Ministry, Department, Agency","Projects","Hospital","Local Government","Value for Money","Thematic"],
354
  label="Select Report Category",
355
  value="Consolidated",
356
  interactive=True,
 
359
  #------ second level filter for selecting subtype within the report category selected above
360
  dropdown_category = gr.Dropdown(
361
  new_files["Consolidated"],
362
+ multiselect = True,
363
+ value = new_files["Consolidated"][0],
364
+ label = "Filter for Sub-reports",
365
  interactive=True)
366
 
367
  #----------- update the secodn level filter abse don values from first level ----------------
 
370
  dropdown_sources.change(fn=rs_change, inputs=[dropdown_sources], outputs=[dropdown_category])
371
 
372
  #--------- Select the years for reports -------------------------------------
373
+ #dropdown_year = gr.Dropdown(
374
+ # ['2018','2019','2020','2021','2022','2023'],
375
+ # label="Filter for year",
376
+ # multiselect=True,
377
+ # value=['2023'],
378
+ # interactive=True,
379
  )
380
  gr.Markdown("-------------------------------------------------------------------------")
381
  #---------------- Another way to select reports across category and sub-type ------------