A raycast extension to query a Postgre SQL database using GPT generated SQL queries and visualize results using Chart.js
Inspired by censusgpt.com and Metabase questions
A little demo with data form ProductHunt's API
Like this project ?
- 🐥 Follow me on Twitter: @m_dolr
- ⭐️ Star this repository on GitHub
The code contains direct evaluation from GPT responses. This project is provided without any warranty. It is not intended to be used in production. Run at your own risks.
- An OpenAI GPT API Key
- A Postgres SQL Database
- Raycast v1.48.8+
git clone raycast-queryGPT
cd raycast-queryGPT
yarn
yarn dev
The question is passed to GPT along with a description of the database schema, GPT is asked to return a SQL Query.
The SQL Query is then executed against the database
The query and a sample table of the results are passed to GPT in order to ask for what would be the most appropriate visualization for the results between "sentence", "chart" and "table"
Depending on the chosen type the results are then displayed in the appropriate format either using a sentence generated by GPT or by using a JS Object dynamically generated and passed to Chart.js
Update the initial prompt in api.ts:101
to match your DB schema
- Have some kind of setup where there is an initialization phase synchronizing the schema and asking the user to describe the schema dynamically during the setup phase and on migrations
This project is licensed under the MIT license. See the LICENSE file for more info.