/generative-sql-ui

A UI to interact with the generative-sql server

Primary LanguageTypeScript

Generative SQL UI

The generative-sql repo queries a database using natural language prompts. OpenAI converts the natural language prompt to a SQL statement, which is then executed against the database. This Generative SQL UI repo connects to the generative-sql server to make it easy to query the database with natural language prompts.

The standard generative-sql service connects to a database of recipes, with recipe, ingredient, user, and category tables. You can experiment with natural language queries. Some examples are:

  • What is the name of the user with the most recipes?
  • How many recipes are in each category?
  • What recipes are for Breakfast?

You will see that some prompts work well and others fail. Keep in mind that the system is using the standard gpt-3.5-turbo OpenAI model without any custom training.

Technology

This UI is built using Next JS and React.

This code is intended to prove the concept, and is not intended to be run in a production environment.

Running the generative-sql-ui

All the npm commands listed below should be run from the main generative-sql-ui directory.

Node JS

The code requires Node JS version 18, and the corresponding npm version 8. You will need to install those locally if you don't already have them.

Install Dependencies

npm i

Config

The file app/config.ts indicates how to connect to the generate-sql server. Update the properties in that file if you do not want to use the original values of localhost:8000.

Build

npm run build

Start

npm run start

Alternatively, you can run the code in development mode with npm run dev. This will automatically refresh the UI in the browser as you make changes to the code.

Enjoy!

Open http://localhost:3000 in a browser and start sending prompts to the server. The UI will show the query that is generated by the system, and also the results of running that query against the database.