-
Notifications
You must be signed in to change notification settings - Fork 3
/
sql.js
31 lines (29 loc) · 1.23 KB
/
sql.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
export const sql = ({
text_input = "",
description = "",
example_schema = {},
target_schema = {},
examples = [],
}) => {
if (!text_input) throw new Error("input is required");
if (!example_schema) throw new Error("example_schema is required");
if (!examples) throw new Error("examples is required");
if (!target_schema) throw new Error("target_schema is required");
const _example =
examples && examples.length > 0
? `Examples: ${examples.map(
(ex) => `Input: ${ex.sentence} Output: [{'Q': ${ex.query}}]`
)}`
: "";
return `
${description}
You are a highly intelligent and accurate SQL query creator. You take a sentence and turn it into a SQL query.
Sometimes you are also provided with a table and you have to create a query that returns the correct answer.
Your output format is a dictionary with a single key 'Q' and the value is the SQL query, so {{ output_format|default("[{'Q':Query}]") }} form, no other form.
The example schema for the examples below is: ${example_schema}
${_example}
The target schema is: ${target_schema}
Input: ${text_input}
Output:
`;
};