An LLM-powered application which takes user queries related to company performance metrics and converts them into a structured JSON format ✨
- Uses Google Gemini API to process user queries.
- The application is able to extract the following information from user queries:
- Entity: The company name mentioned in the query (e.g., Flipkart, Amazon).
- Parameter: The performance metric mentioned in the query (e.g., GMV, revenue, profit).
- Start Date: The start date of the time period for which the metric is requested.
- End Date: The end date of the time period for which the metric is requested.
- If the user query does not explicitly mention the start date and/or end date, it assumes the following defaults:
- Start Date: Today's date minus one year.
- End Date: Today's date.
- The extracted information is converted into a JSON format with the following structure:
[
{
"entity": "<company_name>",
"parameter": "<metric_name>",
"startDate": "<start_date_iso>",
"endDate": "<end_date_iso>"
}
]
- If the user query mentions multiple companies or requests a comparison, the JSON output will include multiple objects, one for each company mentioned.
- The start date and end date are converted to the ISO 8601 format (YYYY-MM-DD).
- The LLM understands the user query and extract relevant information, while Python is used for data manipulation and JSON conversion.
User: Get me Flipkart’s GMV for the last one year
Output:
[
{
"entity": "Flipkart",
"parameter": "GMV",
"startDate": "2023-05-02",
"endDate": "2024-05-02"
}
]
User: compare this with amazon
Output:
[
{
"entity": "Flipkart",
"parameter": "GMV",
"startDate": "2023-05-02",
"endDate": "2024-05-02"
},
{
"entity": "Amazon",
"parameter": "GMV",
"startDate": "2023-05-02",
"endDate": "2024-05-02"
}
]
- Handles variations in user queries, such as different spellings or abbreviations of company names and metric parameters.
- Implements error handling for cases where the LLM fails to extract the necessary information from the user query.
- Considered a history length of 4 messages while processing the given query.
- Considered adding support for additional date formats or relative date ranges (e.g., "last quarter", "previous month").