whoiskatrin / sql-translator

SQL Translator is a tool for converting natural language queries into SQL code using artificial intelligence. This project is 100% free and open source.
https://www.sqltranslate.app/
MIT License
4.19k stars 358 forks source link

Updated prompt #40

Closed difagume closed 1 year ago

difagume commented 1 year ago

Previous prompt:

Translate this natural language query into SQL:

"selecciona todos los cars rojos"

Use this table schema:

CREATE TABLE cars (id INT, make TEXT, model TEXT, year INT, color TEXT)

Translate this natural language query into SQL:

"selecciona todos los cars rojos"

SQL Query:

Current prompt:

Translate this natural language query into SQL:

"selecciona todos los cars rojos"

Use this table schema:

CREATE TABLE cars (id INT, make TEXT, model TEXT, year INT, color TEXT)

SQL Query:
vercel[bot] commented 1 year ago

Someone is attempting to deploy a commit to a Personal Account owned by @whoiskatrin on Vercel.

@whoiskatrin first needs to authorize it.

difagume commented 1 year ago

style correction when hovering over the button

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
sql-translator ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 20, 2023 at 7:47PM (UTC)
code-arnab commented 1 year ago

Hey guys, I need a bit of your help. Actually, I started a development server at localhost:3000 but when when I hit translate I am getting this error 👎

error - pages\api\translate.ts (5:8) @ eval error - Error: OPENAI_API_KEY is not defined in .env file. Please add it there (see README.md for more details). at eval (webpack-internal:///(api)/./pages/api/translate.ts:11:11) 3 | 4 | if (!process.env.OPENAI_API_KEY) {

5 | throw new Error( | ^ 6 | "OPENAI_API_KEY is not defined in .env file. Please add it there (see README.md for more details)." 7 | ); 8 | }

it would be a great help if you know how to fix this

difagume commented 1 year ago

you need to create the .env file and inside put your openai Api key, look at the .env.production file, and check the README.md file in section 3 of the Installation. api then restart the server to take over the changes in the .ev file

whoiskatrin commented 1 year ago

@difagume could you explain a bit more the prompt change? I'm not 1000% convinced that it's the correct one to proceed with.

code-arnab commented 1 year ago

you need to create the .env file and inside put your openai Api key, look at the .env.production file, and check the README.md file in section 3 of the Installation. api then restart the server to take over the changes in the .ev file

Thank you for the help now its working

difagume commented 1 year ago

@difagume could you explain a bit more the prompt change? I'm not 1000% convinced that it's the correct one to proceed with.

of course @whoiskatrin

in the example above is the actual query when a schema is included, the text is duplicated because at the end of the prompt there is ${prompt}

so I updated how the prompt is assembled with a ternary and the only thing I modified was the texts that were being duplicated when a schema is included:

I give you an example of the prompt with and without schema, I see it the same as before without the duplicated texts and in the tests I did it returns me the same as before.

Without schema:

Translate this natural language query into SQL:

"Get all information from the modulo table where the description is 'Registro'."

SQL Query:

With schema:

Translate this natural language query into SQL:

"Get all information from the modulo table where the description is 'Registro'."

Use this table schema:

CREATE TABLE modulo (
        id bigserial NOT NULL,
        valor varchar NOT NULL,
        descripcion varchar NOT NULL,
        activo bool NOT NULL DEFAULT true,
        CONSTRAINT modulo_pkey PRIMARY KEY (id)
);

SQL Query: