I've been building something similar that handles the dirty business of formatting a large database into a prompt.
Additional work that I've found helpful includes:
1. Using embeddings to filter context into the prompt
2. Identifying common syntax errors or hallucinations of non-existent columns
3. Flagging queries that write instead of read
Plus lots of prompt finessing to get it to avoid mistakes.
It doesn't execute the queries, yet. For an arbitrary db, it's still helpful to have a human in the loop to sanity check the SQL (for now at least).
1. Using embeddings to filter context into the prompt
2. Identifying common syntax errors or hallucinations of non-existent columns
3. Flagging queries that write instead of read
Plus lots of prompt finessing to get it to avoid mistakes.
It doesn't execute the queries, yet. For an arbitrary db, it's still helpful to have a human in the loop to sanity check the SQL (for now at least).
Demo at https://www.querymuse.com/query if anyone's interested