Spaces:
Running
Running
Commit
·
941ebd9
1
Parent(s):
9699e75
Test
Browse files
app.py
CHANGED
@@ -48,58 +48,57 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
|
|
48 |
demo = gr.ChatInterface(
|
49 |
respond,
|
50 |
additional_inputs=[
|
51 |
-
gr.Textbox(value="""
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
""", label="System message"),
|
103 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
104 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
105 |
gr.Slider(
|
|
|
48 |
demo = gr.ChatInterface(
|
49 |
respond,
|
50 |
additional_inputs=[
|
51 |
+
gr.Textbox(value="""Your task is to convert a question into a SQL query, given a Postgres database schema.
|
52 |
+
Adhere to these rules:
|
53 |
+
- Use Table Aliases to prevent ambiguity.
|
54 |
+
- When creating a ratio, always cast the numerator as float.
|
55 |
+
- Only use tables and fields explicitly defined in the provided schema. Do not include or reference any tables or fields not listed.
|
56 |
+
- If the required query cannot be constructed using the provided schema, return the string `NOT FOUND`.
|
57 |
+
|
58 |
+
### Input:
|
59 |
+
Generate a SQL query that answers the question `{question}`.
|
60 |
+
This query will run on a database whose schema is represented in this string:
|
61 |
+
CREATE TABLE products (
|
62 |
+
product_id INTEGER PRIMARY KEY, -- Unique ID for each product
|
63 |
+
name VARCHAR(50), -- Name of the product
|
64 |
+
price DECIMAL(10,2), -- Price of each unit of the product
|
65 |
+
quantity INTEGER -- Current quantity in stock
|
66 |
+
);
|
67 |
+
|
68 |
+
CREATE TABLE customers (
|
69 |
+
customer_id INTEGER PRIMARY KEY, -- Unique ID for each customer
|
70 |
+
name VARCHAR(50), -- Name of the customer
|
71 |
+
address VARCHAR(100) -- Mailing address of the customer
|
72 |
+
);
|
73 |
+
|
74 |
+
CREATE TABLE salespeople (
|
75 |
+
salesperson_id INTEGER PRIMARY KEY, -- Unique ID for each salesperson
|
76 |
+
name VARCHAR(50), -- Name of the salesperson
|
77 |
+
region VARCHAR(50) -- Geographic sales region
|
78 |
+
);
|
79 |
+
|
80 |
+
CREATE TABLE sales (
|
81 |
+
sale_id INTEGER PRIMARY KEY, -- Unique ID for each sale
|
82 |
+
product_id INTEGER, -- ID of product sold
|
83 |
+
customer_id INTEGER, -- ID of customer who made purchase
|
84 |
+
salesperson_id INTEGER, -- ID of salesperson who made the sale
|
85 |
+
sale_date DATE, -- Date the sale occurred
|
86 |
+
quantity INTEGER -- Quantity of product sold
|
87 |
+
);
|
88 |
+
|
89 |
+
CREATE TABLE product_suppliers (
|
90 |
+
supplier_id INTEGER PRIMARY KEY, -- Unique ID for each supplier
|
91 |
+
product_id INTEGER, -- Product ID supplied
|
92 |
+
supply_price DECIMAL(10,2) -- Unit price charged by supplier
|
93 |
+
);
|
94 |
+
|
95 |
+
-- sales.product_id can be joined with products.product_id
|
96 |
+
-- sales.customer_id can be joined with customers.customer_id
|
97 |
+
-- sales.salesperson_id can be joined with salespeople.salesperson_id
|
98 |
+
-- product_suppliers.product_id can be joined with products.product_id
|
99 |
+
|
100 |
+
### Response:
|
101 |
+
```sql""", label="System message"),
|
|
|
102 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
103 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
104 |
gr.Slider(
|