Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
-
from sqlalchemy import text,
|
4 |
from smolagents import tool, CodeAgent, HfApiModel
|
5 |
import pandas as pd
|
6 |
import tempfile
|
@@ -80,17 +80,17 @@ def get_table_data(table_name):
|
|
80 |
except Exception as e:
|
81 |
return pd.DataFrame({"Error": [str(e)]})
|
82 |
|
83 |
-
# SQL Execution Tool
|
84 |
@tool
|
85 |
def sql_engine(query: str) -> str:
|
86 |
"""
|
87 |
Executes an SQL SELECT query and returns the results.
|
88 |
|
89 |
Args:
|
90 |
-
query (str): The SQL query to execute.
|
91 |
|
92 |
Returns:
|
93 |
-
str: The query results
|
94 |
"""
|
95 |
try:
|
96 |
with engine.connect() as con:
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
+
from sqlalchemy import text, inspect
|
4 |
from smolagents import tool, CodeAgent, HfApiModel
|
5 |
import pandas as pd
|
6 |
import tempfile
|
|
|
80 |
except Exception as e:
|
81 |
return pd.DataFrame({"Error": [str(e)]})
|
82 |
|
83 |
+
# SQL Execution Tool (FIXED Docstring for `smolagents`)
|
84 |
@tool
|
85 |
def sql_engine(query: str) -> str:
|
86 |
"""
|
87 |
Executes an SQL SELECT query and returns the results.
|
88 |
|
89 |
Args:
|
90 |
+
query (str): The SQL query string to execute.
|
91 |
|
92 |
Returns:
|
93 |
+
str: The formatted query results, or an error message if the query fails.
|
94 |
"""
|
95 |
try:
|
96 |
with engine.connect() as con:
|