ppsingh commited on
Commit
ab3f0ee
·
verified ·
1 Parent(s): 4e3697b

update guidelines and report selection

Browse files
Files changed (1) hide show
  1. app.py +99 -49
app.py CHANGED
@@ -361,48 +361,94 @@ with gr.Blocks(title="Audit Q&A", css= "style.css", theme=theme,elem_id = "main-
361
  # creating tabs on right panel
362
  with gr.Tabs() as tabs:
363
  #---------------- tab for REPORTS SELECTION ----------------------
364
-
365
  with gr.Tab("Reports",elem_id = "tab-config",id = 2):
366
- gr.Markdown("Reminder: To get better results select the specific report/reports")
367
 
368
-
369
- #----- First level filter for selecting Report source/category ----------
370
- dropdown_sources = gr.Dropdown(
371
- ["Consolidated","Ministry, Department and Agency","Project","Hospital","Local Government","Value for Money","Thematic"],
372
- label="Select Report Category",
373
- value="Consolidated",
374
- interactive=True,
375
  )
376
 
377
- #------ second level filter for selecting subtype within the report category selected above
378
- dropdown_category = gr.Dropdown(
379
- new_files["Consolidated"],
380
- multiselect = True,
381
- value = new_files["Consolidated"][0],
382
- label = "Filter for Sub-reports",
383
- interactive=True)
384
-
385
- #----------- update the secodn level filter abse don values from first level ----------------
386
- def rs_change(rs):
387
- return gr.update(choices=new_files[rs], value=new_files[rs])
388
- dropdown_sources.change(fn=rs_change, inputs=[dropdown_sources], outputs=[dropdown_category])
389
-
390
- #--------- Select the years for reports -------------------------------------
391
- #dropdown_year = gr.Dropdown(
392
- # ['2018','2019','2020','2021','2022','2023'],
393
- # label="Filter for year",
394
- # multiselect=True,
395
- # value=['2023'],
396
- # interactive=True,
397
- #)
398
- gr.Markdown("-------------------------------------------------------------------------")
399
- #---------------- Another way to select reports across category and sub-type ------------
400
- dropdown_reports = gr.Dropdown(
401
- new_report_list,
402
- label="Or select specific reports",
403
- multiselect=True,
404
- value=[],
405
- interactive=True,)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
406
 
407
  ############### tab for Question selection ###############
408
  with gr.TabItem("Examples",elem_id = "tab-examples",id = 0):
@@ -448,25 +494,29 @@ with gr.Blocks(title="Audit Q&A", css= "style.css", theme=theme,elem_id = "main-
448
 
449
  dropdown_samples.change(change_sample_questions,dropdown_samples,samples)
450
 
451
- # ---- New Guidelines Tab ----
 
452
  with gr.Tab("Guidelines", elem_classes="max-height other-tabs"):
453
  gr.Markdown("""
454
- Welcome to Audit Q&A, your AI-powered assistant for exploring and understanding Uganda's audit reports. This tool leverages advanced language models to help you get clear and structured answers based on audit publications. To get you started, here a few tips on how to use the tool:
455
- ### Crafting Effective Prompts
 
 
 
 
 
 
 
456
  - **Be Clear and Specific**: Frame your questions clearly and focus on what you want to learn.
457
  - **One Topic at a Time**: Break complex queries into simpler, focused questions.
458
- - **Be Direct**: Instead of "What are the findings?", try "What were the main issues identified in procurement practices?" or "What challenges were found in revenue collection?"
 
459
 
460
- ### Best Practices
461
- - Start with a simple, focused question.
462
- - Follow up with additional questions if your initial query doesn't yield the desired results.
463
- - Experiment with different phrasings to get the most accurate answers.
464
- - Use the source citations as a reference to validate the provided information.
465
- ### Utilizing Filters
466
  - **Report Category & Subtype**: Use the "Reports" tab to choose your preferred report category and refine your query by selecting a specific sub-type. This will help narrow down the context for your question.
467
  - **Year Selection**: Choose one or more years from the "Year" filter to target your query to specific time periods.
468
  - **Specific Reports**: Optionally, select specific reports using the dropdown to focus on a particular document or set of documents.
469
- ### Useful Resources
470
 
471
  - <ins>[**Short Course: Generative AI for Everyone** (3 hours)](https://www.deeplearning.ai/courses/generative-ai-for-everyone/)</ins>
472
  - <ins>[**Short Course: Advanced Prompting** (1 hour)](https://www.deeplearning.ai/courses/ai-for-everyone/)</ins>
 
361
  # creating tabs on right panel
362
  with gr.Tabs() as tabs:
363
  #---------------- tab for REPORTS SELECTION ----------------------
364
+
365
  with gr.Tab("Reports",elem_id = "tab-config",id = 2):
 
366
 
367
+ #---------------- SELECTION METHOD - RADIO BUTTON ------------
368
+ search_method = gr.Radio(
369
+ choices=["Search by Report Name", "Search by Filters"],
370
+ label="Choose search method",
371
+ info= "Select the audit reports that you want to analyse directly or browse through categories and select reports",
372
+ value="Search by Report Name",
 
373
  )
374
 
375
+ #---------------- SELECT BY REPORT NAME SECTION ------------
376
+ with gr.Group(visible=True) as report_name_section:
377
+ # Get default report value from config if present
378
+ default_report = model_config.get('app', 'dropdown_default', fallback=None)
379
+ # Check if it actually exists in the master list
380
+ default_report_value = [default_report] if default_report in new_report_list else None
381
+
382
+ dropdown_reports = gr.Dropdown(
383
+ new_report_list,
384
+ label="Select one or more reports (scroll or type to search)",
385
+ multiselect=True,
386
+ value=default_report_value,
387
+ interactive=True,
388
+ )
389
+
390
+ #---------------- SELECT BY FILTERS SECTION ------------
391
+ with gr.Group(visible=False) as filters_section:
392
+ #----- First level filter for selecting Report source/category ----------
393
+ dropdown_sources = gr.Dropdown(
394
+ ["Consolidated","Ministry, Department, Agency and Projects","Local Government","Value for Money","Thematic"],
395
+ label="Select Report Category",
396
+ value=None,
397
+ interactive=True,
398
+ )
399
+
400
+ #------ second level filter for selecting subtype within the report category selected above
401
+ dropdown_category = gr.Dropdown(
402
+ [], # Start with empty choices
403
+ value=None,
404
+ label = "Filter for Sub-Type",
405
+ interactive=True)
406
+
407
+ #----------- update the second level filter based on values from first level ----------------
408
+ def rs_change(rs):
409
+ if rs: # Only update choices if a value is selected
410
+ return gr.update(choices=new_files[rs], value=None) # Set value to None (no preselection)
411
+ else:
412
+ return gr.update(choices=[], value=None) # Empty choices if nothing selected
413
+ dropdown_sources.change(fn=rs_change, inputs=[dropdown_sources], outputs=[dropdown_category])
414
+
415
+ # Toggle visibility based on search method
416
+ def toggle_search_method(method):
417
+ """Note - this function removes the default value from report search when toggled"""
418
+ if method == "Search by Report Name":
419
+ # Show report selection, hide filters, and clear filter values
420
+ return (
421
+ gr.update(visible=True), # report_name_section
422
+ gr.update(visible=False), # filters_section
423
+ gr.update(value=None), # dropdown_sources
424
+ gr.update(value=None), # dropdown_category
425
+ gr.update(value=None), # dropdown_year
426
+ gr.update() # dropdown_reports
427
+ )
428
+ else: # "Search by Filters"
429
+ # Show filters, hide report selection, and clear report values
430
+ return (
431
+ gr.update(visible=False), # report_name_section
432
+ gr.update(visible=True), # filters_section
433
+ gr.update(), # dropdown_sources
434
+ gr.update(), # dropdown_category
435
+ gr.update(), # dropdown_year
436
+ gr.update(value=[]) # dropdown_reports
437
+ )
438
+
439
+ # Pass to the event handler
440
+ search_method.change(
441
+ fn=toggle_search_method,
442
+ inputs=[search_method],
443
+ outputs=[
444
+ report_name_section,
445
+ filters_section,
446
+ dropdown_sources,
447
+ dropdown_category,
448
+ dropdown_reports
449
+ ]
450
+ )
451
+
452
 
453
  ############### tab for Question selection ###############
454
  with gr.TabItem("Examples",elem_id = "tab-examples",id = 0):
 
494
 
495
  dropdown_samples.change(change_sample_questions,dropdown_samples,samples)
496
 
497
+
498
+ # ---- Guidelines Tab ----
499
  with gr.Tab("Guidelines", elem_classes="max-height other-tabs"):
500
  gr.Markdown("""
501
+ #### Welcome to Audit Q&A, your AI-powered assistant for exploring and understanding Uganda's audit reports. This tool leverages advanced language models to help you get clear and structured answers based on audit publications. To get you started, here a few tips on how to use the tool:
502
+ ## 💬 Crafting Effective Prompts
503
+ Clear, specific questions will give you the best results. Here are some examples:
504
+ | ❌ Less Effective | ✅ More Effective |
505
+ |------------------|-------------------|
506
+ | "What are the findings?" | "What were the main issues identified in procurement practices in the Ministry of Health in 2022?" |
507
+ | "Tell me about revenue collection" | "What specific challenges were identified in revenue collection at the local government level in 2021-2022?" |
508
+ | "Is there corruption?" | "What audit findings related to misappropriation of funds were reported in the education sector between 2020-2023?" |
509
+ ## ⭐ Best Practices
510
  - **Be Clear and Specific**: Frame your questions clearly and focus on what you want to learn.
511
  - **One Topic at a Time**: Break complex queries into simpler, focused questions.
512
+ - **Provide Context**: Mentioning specific ministries, years, or projects helps narrow the focus.
513
+ - **Follow Up**: Ask follow-up questions to explore a topic more deeply.
514
 
515
+ ## 🔍 Utilizing Filters
 
 
 
 
 
516
  - **Report Category & Subtype**: Use the "Reports" tab to choose your preferred report category and refine your query by selecting a specific sub-type. This will help narrow down the context for your question.
517
  - **Year Selection**: Choose one or more years from the "Year" filter to target your query to specific time periods.
518
  - **Specific Reports**: Optionally, select specific reports using the dropdown to focus on a particular document or set of documents.
519
+ ## 📚 Useful Resources
520
 
521
  - <ins>[**Short Course: Generative AI for Everyone** (3 hours)](https://www.deeplearning.ai/courses/generative-ai-for-everyone/)</ins>
522
  - <ins>[**Short Course: Advanced Prompting** (1 hour)](https://www.deeplearning.ai/courses/ai-for-everyone/)</ins>