I have created a simple domain-specific query language SIMPLE-QL for which I have a formal grammar. I would like chatgpt to convert english into this simple query language. This is so that if my users forget my grammer but are close, chatgpt can fix their query for them. I have had a bit of success passing in some simple documentation and examples as part of the prompt (see below). It actually works pretty well with GPT-4 (via ChatGPT), but less well with GPT-3 which is what I have API access to. I’m wondering if I could feed it a formal grammar definition instead? Or is there a better way to structure the documentation and examples? Has anyone tried to do something similar? Any help/thoughts/pointers appreciated!
Hi ChatGPT, here is the documentation for a query language called SIMPLE-QL:
SIMPLE-QL grammar: <stride> <filters*> <metric> <rate>% by <segments> <time-range>
Examples:
- daily bookings 3w
- monthly usa quotes 4y
- weekly usa auto-quote quote-conversion 32w
<stride> (required)
- One of: total, annual, quarterly, monthly, weekly, daily
- If no time grouping is specified it default to total.
<time-range> (required)
A flexible way to specify a time range, any of:
- A specified number of past days (d), weeks (w), months (m) or years (y): 3w, 3y, 18m, 90d
- A year: 2022, 2021
- A date range: 2020-01-01 to 2020-06-01
<filters> (optional)
- an alphanumeric label
<rate> (optional)
- an alphanumeric label with a % after it
<segments> (optional)
- one or more alphanumeric labels separated by a comma
Examples:
- monthly bookings usa% 12m
- weekly online orders logged-in% 2021
- total completed-orders in-house% 30d
- total bookings by process 90d
- monthly quote-conversion by quote-source 3y
- weekly usa bookings by office 90d
- usa quote-conversion by country,language 90d
- daily revenue 2022
Please return an SIMPLE-QL query for: usa% of monthly revenue for the past 24 months
This returns something that is close, but not quite correct: monthly usa% revenue 24m
It should be: monthly revenue usa% 24m