Update app.py
Browse files
app.py
CHANGED
|
@@ -186,10 +186,54 @@ def process_input(question, table_context):
|
|
| 186 |
return cleaned_sql
|
| 187 |
|
| 188 |
# Sample table context examples for the example selector
|
| 189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
|
| 191 |
# Sample question examples
|
| 192 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
|
| 194 |
# Create the Gradio interface
|
| 195 |
with gr.Blocks(title="Text to SQL Converter") as demo:
|
|
|
|
| 186 |
return cleaned_sql
|
| 187 |
|
| 188 |
# Sample table context examples for the example selector
|
| 189 |
+
example_contexts = [
|
| 190 |
+
# Example 1
|
| 191 |
+
"""
|
| 192 |
+
CREATE TABLE customers (
|
| 193 |
+
id INT PRIMARY KEY,
|
| 194 |
+
name VARCHAR(100),
|
| 195 |
+
email VARCHAR(100),
|
| 196 |
+
order_date DATE
|
| 197 |
+
);
|
| 198 |
+
""",
|
| 199 |
+
|
| 200 |
+
# Example 2
|
| 201 |
+
"""
|
| 202 |
+
CREATE TABLE products (
|
| 203 |
+
id INT PRIMARY KEY,
|
| 204 |
+
name VARCHAR(100),
|
| 205 |
+
category VARCHAR(50),
|
| 206 |
+
price DECIMAL(10,2),
|
| 207 |
+
stock_quantity INT
|
| 208 |
+
);
|
| 209 |
+
""",
|
| 210 |
+
|
| 211 |
+
# Example 3
|
| 212 |
+
"""
|
| 213 |
+
CREATE TABLE employees (
|
| 214 |
+
id INT PRIMARY KEY,
|
| 215 |
+
name VARCHAR(100),
|
| 216 |
+
department VARCHAR(50),
|
| 217 |
+
salary DECIMAL(10,2),
|
| 218 |
+
hire_date DATE
|
| 219 |
+
);
|
| 220 |
+
CREATE TABLE departments (
|
| 221 |
+
id INT PRIMARY KEY,
|
| 222 |
+
name VARCHAR(50),
|
| 223 |
+
manager_id INT,
|
| 224 |
+
budget DECIMAL(15,2)
|
| 225 |
+
);
|
| 226 |
+
"""
|
| 227 |
+
]
|
| 228 |
|
| 229 |
# Sample question examples
|
| 230 |
+
example_questions = [
|
| 231 |
+
"Get the names and emails of customers who placed an order in the last 30 days.",
|
| 232 |
+
"Find all products with less than 10 items in stock.",
|
| 233 |
+
"List all employees in the Sales department with a salary greater than 50000.",
|
| 234 |
+
"What is the total budget for departments with more than 5 employees?",
|
| 235 |
+
"Count how many products are in each category where the price is greater than 100."
|
| 236 |
+
]
|
| 237 |
|
| 238 |
# Create the Gradio interface
|
| 239 |
with gr.Blocks(title="Text to SQL Converter") as demo:
|