generative-ai-js icon indicating copy to clipboard operation
generative-ai-js copied to clipboard

Can we ensure the ai to not use any other data not in the context?

Open Ranork opened this issue 6 months ago • 2 comments

We are trying to make a sql query generator with chat complation.

prompt: Show me the customers

history:

[
  {"role": "user", "parts": "### SYSTEM CONTEXT ### \nYou are an *MSSQL* command generator. Use table schema for generating sql commands. ### EXAMPLE RESONSE ### \`\`\`sql ... \`\`\`  \n ### DATABASE SCHEME ### ......."},
  {"role": "model", "parts": "OK" }
]
const gemini = gai.getGenerativeModel({ model });
const chat = gemini.startChat({history, generationConfig: { temperature: 0.2 }});

const result = await chat.sendMessage(prompt);
const response = await result.response;

It gives me cool sql commands but some table names are not logical names (like crnt_tbl for current table). AI tries to access tables that do not exist in the schema, causing the query to not work.

I want it to only use existing table names in the schema. How can I set this up?

Ranork avatar Dec 19 '23 08:12 Ranork