Find answers from the community

T
Ted
Offline, last seen 6 months ago
Joined September 25, 2024
Does anyone familiar with sqlalchemy know how to tell it to use a specific queries? It is currently counting the records in a query when it should be summing the values of specific fields.
2 comments
T
Can you promt the SQLTableRetrieverQueryEngine to always return the date range of the queried documents? The response returns the data only when a time is asked for. This is the current prompt I am using.

Plain Text
DEFAULT_RESPONSE_SYNTHESIS_PROMPT_TMPL = (
    "Given the input question and the associated SQL query results from the 'snapshots' table, "
    "synthesize a coherent response. Always ensure that you retrieve and present the date range linked "
    "to the documents in the query. The format of the date can be flexible, but it must be unmistakably evident "
    "that it represents a date range.\n"
    "\n"
    "Context:\n"
    "Table Name: snapshots\n"
    "Relevant Columns: date
    "\n"
    "Example 1:\n"
    "Query: 'How many page impressions were made in October?'\n"
    "SQL: 'SELECT SUM(page_impressions), MIN(date), MAX(date) FROM snapshots WHERE EXTRACT(MONTH FROM date) = 10;'\n"
    "SQL Response: 'SUM: 500000, MIN: 2023-10-01, MAX: 2023-10-31'\n"
    "Response: There were 500,000 page impressions made from October 1, 2023, to October 31, 2023.\n"
    "\n"
    "Example 2:\n"
    "Query: 'How many people total left my page yesterday?'\n"
    "SQL: 'SELECT SUM(page_fan_removes), MIN(date), MAX(date) FROM snapshots WHERE date = current_date - interval '1 day';'\n"
    "SQL Response: 'SUM: 12000, MIN: 2023-10-02 00:00:00, MAX: 2023-10-02 00:00:00'\n"
    "Response: 12,000 users engaged with the page yesterday.\n"
    "\n"
    "Example 3:\n"
    "Query: 'How many users engaged with the page last week?'\n"
    "SQL: 'SELECT SUM(page_engaged_users), MIN(date), MAX(date) FROM snapshots WHERE date BETWEEN '2023-09-01' AND '2023-09-07';'\n"
    "SQL Response: 'SUM: 12000, MIN: 2023-09-01, MAX: 2023-09-07'\n"
    "Response: 12,000 users engaged with the page from September 1, 2023, to September 7, 2023.\n"
    "\n"
    "Now, for the current task:\n"
    "Query: {query_str}\n"
    "SQL: {sql_query}\n"
    "SQL Response: {sql_response_str}\n"
    "Response: "
)
2 comments
L
T