How to Add New Reports for the Report Chatting Functionality
Author: Ahmet Selman Güclü
Types of Reports
The system currently supports two types of reports:
- Country Reports - Reports specific to individual countries
- Year in Review Reports - Annual global reports
Adding Country Reports
To include new country reports, follow these steps:
-
Locate the
COUNTRY_REPORTS
list inreports_utils.py
. Each report entry must contain the country name and PDF URL. For example:{
"url": "https://static.hungermapdata.org/insight-reports/latest/hti-summary.pdf",
"country_name": "Haiti",
} -
Add the new report entry to the
COUNTRY_REPORTS
list. -
Run the script
report_chatting/upload_all_reports.py
to process the new document. This script will:- Extract the document's data and summary
- Upload the extracted information to the
report_chatting
collection in the main database
Example: Adding a Country Report
Suppose you want to add a report for "Kenya":
-
Add this entry to
COUNTRY_REPORTS
:{
"url": "https://static.hungermapdata.org/insight-reports/latest/ken-summary.pdf",
"country_name": "Kenya",
} -
Execute:
python -m src.report_chatting.upload_all_reports
Adding Year in Review Reports
To add new year-in-review reports:
-
Locate the
YEAR_IN_REVIEW_REPORTS
list inreports_utils.py
. Each entry must contain the year and PDF URL. For example:{
"url": "https://static.hungermapdata.org/year-in-review/2023/Global.pdf",
"year": 2023,
} -
Add the new report entry to the
YEAR_IN_REVIEW_REPORTS
list. -
Run the upload script as described above.
Example: Adding a Year in Review Report
To add a new year in review report:
-
Add this entry to
YEAR_IN_REVIEW_REPORTS
:{
"url": "https://static.hungermapdata.org/year-in-review/2024/Global.pdf",
"year": 2024,
} -
Execute:
python -m src.report_chatting.upload_all_reports
Adding a New Type of Report
When introducing a completely new type of report beyond country reports and year-in-review reports:
-
Code Updates:
- Add a new constant list in
reports_utils.py
to store the new report type
- Add a new constant list in
-
Data Storage:
- Evaluate if the new report type requires separate storage or categorization in the database
- Update database schemas if necessary with new parser and upload scripts and include those in the
report_chatting/upload_all_reports.py
script - Run
python -m src.report_chatting.upload_all_reports
to upload the new report type
-
Front-End Identification:
- Add the new report type to the
IReportContext
insrc/domain/entities/chatbot/Chatbot.ts
and use it when creating a new chat and sending message queries to the backend.
export interface IReportContext {
type: 'country' | 'year_in_review';
value: string;
} - Add the new report type to the
-
System Prompt Adjustments:
- Adjust
ai_model.py
,db_similarity_search.py
,app.py
to support the new report type.
- Adjust