-
Notifications
You must be signed in to change notification settings - Fork 263
Closed
Labels
Description
Some of our user questions are a bit tricky - for example, Geo Spatial queries.
I would like to provide the model with zero-shot examples of user questions and the expected SQL.
I've tried adding this to the prompt (an examples section in the prompt.md). For example this is my prompt markdown:
# Task
Generate a SQL query to answer the following question:
`{user_question}`
# Database Schema
The query will run on a database with the following schema:
{table_metadata_string}
# Examples
## Example 1
Question: What place has the most cars?
SQL: SELECT places.name, COUNT(*) as cnt FROM cars JOIN places ON ST_Contains(ST_GeometryFromText(places.wkt_polygon), ST_Point(cars.latitude, cars.longitude)) GROUP BY places.name ORDER BY cnt DESC LIMIT 1;
## Example 2
Question: What is the sum of bookings for each month in 2023?
SQL: SELECT SUM(total_cost) AS total_cost, EXTRACT(MONTH FROM start_date) as month FROM car_bookings WHERE YEAR(start_date) = 2023 GROUP BY EXTRACT(MONTH FROM start_date) ORDER BY month;
# SQL
But when I do this, the model always returns the SQL for the first example, regardless of the user question.
Any hints on how to approach this?
Thanks!