Spaces:
Sleeping
Sleeping
Commit
·
0f85b1c
1
Parent(s):
e49ffd0
Revert "Test"
Browse filesThis reverts commit 39917e3ddb8536a09aa55446581a5a51efd282c8.
app.py
CHANGED
|
@@ -16,61 +16,7 @@ def respond(
|
|
| 16 |
temperature,
|
| 17 |
top_p,
|
| 18 |
):
|
| 19 |
-
|
| 20 |
-
### Instructions:
|
| 21 |
-
Your task is to convert a question into a SQL query, given a Postgres database schema.
|
| 22 |
-
Adhere to these rules:
|
| 23 |
-
- **Deliberately go through the question and database schema word by word** to appropriately answer the question
|
| 24 |
-
- **Use Table Aliases** to prevent ambiguity. For example, `SELECT table1.col1, table2.col1 FROM table1 JOIN table2 ON table1.id = table2.id`.
|
| 25 |
-
- When creating a ratio, always cast the numerator as float
|
| 26 |
-
|
| 27 |
-
### Input:
|
| 28 |
-
Generate a SQL query that answers the question `{question}`.
|
| 29 |
-
This query will run on a database whose schema is represented in this string:
|
| 30 |
-
CREATE TABLE products (
|
| 31 |
-
product_id INTEGER PRIMARY KEY, -- Unique ID for each product
|
| 32 |
-
name VARCHAR(50), -- Name of the product
|
| 33 |
-
price DECIMAL(10,2), -- Price of each unit of the product
|
| 34 |
-
quantity INTEGER -- Current quantity in stock
|
| 35 |
-
);
|
| 36 |
-
|
| 37 |
-
CREATE TABLE customers (
|
| 38 |
-
customer_id INTEGER PRIMARY KEY, -- Unique ID for each customer
|
| 39 |
-
name VARCHAR(50), -- Name of the customer
|
| 40 |
-
address VARCHAR(100) -- Mailing address of the customer
|
| 41 |
-
);
|
| 42 |
-
|
| 43 |
-
CREATE TABLE salespeople (
|
| 44 |
-
salesperson_id INTEGER PRIMARY KEY, -- Unique ID for each salesperson
|
| 45 |
-
name VARCHAR(50), -- Name of the salesperson
|
| 46 |
-
region VARCHAR(50) -- Geographic sales region
|
| 47 |
-
);
|
| 48 |
-
|
| 49 |
-
CREATE TABLE sales (
|
| 50 |
-
sale_id INTEGER PRIMARY KEY, -- Unique ID for each sale
|
| 51 |
-
product_id INTEGER, -- ID of product sold
|
| 52 |
-
customer_id INTEGER, -- ID of customer who made purchase
|
| 53 |
-
salesperson_id INTEGER, -- ID of salesperson who made the sale
|
| 54 |
-
sale_date DATE, -- Date the sale occurred
|
| 55 |
-
quantity INTEGER -- Quantity of product sold
|
| 56 |
-
);
|
| 57 |
-
|
| 58 |
-
CREATE TABLE product_suppliers (
|
| 59 |
-
supplier_id INTEGER PRIMARY KEY, -- Unique ID for each supplier
|
| 60 |
-
product_id INTEGER, -- Product ID supplied
|
| 61 |
-
supply_price DECIMAL(10,2) -- Unit price charged by supplier
|
| 62 |
-
);
|
| 63 |
-
|
| 64 |
-
-- sales.product_id can be joined with products.product_id
|
| 65 |
-
-- sales.customer_id can be joined with customers.customer_id
|
| 66 |
-
-- sales.salesperson_id can be joined with salespeople.salesperson_id
|
| 67 |
-
-- product_suppliers.product_id can be joined with products.product_id
|
| 68 |
-
|
| 69 |
-
### Response:
|
| 70 |
-
Based on your instructions, here is the SQL query I have generated to answer the question `{question}`:
|
| 71 |
-
```sql
|
| 72 |
-
"""
|
| 73 |
-
messages = [{"role": "system", "content": sytems}]
|
| 74 |
|
| 75 |
for val in history:
|
| 76 |
if val[0]:
|
|
@@ -101,6 +47,7 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
|
|
| 101 |
demo = gr.ChatInterface(
|
| 102 |
respond,
|
| 103 |
additional_inputs=[
|
|
|
|
| 104 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 105 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 106 |
gr.Slider(
|
|
|
|
| 16 |
temperature,
|
| 17 |
top_p,
|
| 18 |
):
|
| 19 |
+
messages = [{"role": "system", "content": system_message}]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
for val in history:
|
| 22 |
if val[0]:
|
|
|
|
| 47 |
demo = gr.ChatInterface(
|
| 48 |
respond,
|
| 49 |
additional_inputs=[
|
| 50 |
+
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
| 51 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 52 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 53 |
gr.Slider(
|