Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -345,17 +345,28 @@ graph.add_edge("Query Optimization", "SQL Execution")
|
|
| 345 |
compiled_pipeline = graph.compile()
|
| 346 |
|
| 347 |
# ------------------ Gradio Interface ------------------
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 351 |
|
| 352 |
iface = gr.Interface(
|
| 353 |
fn=run_multi_agent_query,
|
| 354 |
inputs=gr.Textbox(lines=2, placeholder="Enter your natural language query here..."),
|
| 355 |
outputs="text",
|
| 356 |
title="Multi-Agent SQL Generator",
|
| 357 |
-
description="Enter a natural language query to generate and execute a SQL query
|
| 358 |
)
|
| 359 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 360 |
if __name__ == "__main__":
|
| 361 |
iface.launch()
|
|
|
|
| 345 |
compiled_pipeline = graph.compile()
|
| 346 |
|
| 347 |
# ------------------ Gradio Interface ------------------
|
| 348 |
+
schema_description = """
|
| 349 |
+
**Database Schema:**
|
| 350 |
+
|
| 351 |
+
- **customers**: customer_id, name, email, phone, address, created_at
|
| 352 |
+
- **products**: product_id, name, category, price, stock_quantity
|
| 353 |
+
- **orders**: order_id, customer_id, order_date, total_amount, status
|
| 354 |
+
- **order_items**: order_item_id, order_id, product_id, quantity, subtotal
|
| 355 |
+
- **payments**: payment_id, order_id, payment_date, amount, payment_method, status
|
| 356 |
+
- **shipment**: shipment_id, order_id, shipment_date, delivery_date, carrier, tracking_number, status
|
| 357 |
+
"""
|
| 358 |
|
| 359 |
iface = gr.Interface(
|
| 360 |
fn=run_multi_agent_query,
|
| 361 |
inputs=gr.Textbox(lines=2, placeholder="Enter your natural language query here..."),
|
| 362 |
outputs="text",
|
| 363 |
title="Multi-Agent SQL Generator",
|
| 364 |
+
description="Enter a natural language query to generate and execute a SQL query.\n\n" + schema_description
|
| 365 |
)
|
| 366 |
|
| 367 |
+
def run_multi_agent_query(natural_language_query):
|
| 368 |
+
result = compiled_pipeline.invoke({"sql_query": natural_language_query})
|
| 369 |
+
return json.dumps(result.get("execution_result", {}), indent=2)
|
| 370 |
+
|
| 371 |
if __name__ == "__main__":
|
| 372 |
iface.launch()
|