Spaces:
Sleeping
Sleeping
pdrMottaS
commited on
Commit
·
d99a89e
1
Parent(s):
2b6420a
change sql endpoint
Browse files
main.py
CHANGED
|
@@ -8,6 +8,7 @@ from llama_index.core.indices.struct_store import NLSQLTableQueryEngine
|
|
| 8 |
import os
|
| 9 |
from huggingface_hub import hf_hub_download
|
| 10 |
from models import SQL
|
|
|
|
| 11 |
|
| 12 |
app = FastAPI()
|
| 13 |
|
|
@@ -36,7 +37,7 @@ async def query_database(query_data: SQL):
|
|
| 36 |
global query_file_path
|
| 37 |
conn = duckdb.connect(query_file_path,read_only=True)
|
| 38 |
df = conn.execute(query_data.query).fetch_df()
|
| 39 |
-
return JSONResponse(df.to_json(orient = "records"))
|
| 40 |
|
| 41 |
# @app.post("/llm")
|
| 42 |
# async def llm(prompt: str):
|
|
|
|
| 8 |
import os
|
| 9 |
from huggingface_hub import hf_hub_download
|
| 10 |
from models import SQL
|
| 11 |
+
import json
|
| 12 |
|
| 13 |
app = FastAPI()
|
| 14 |
|
|
|
|
| 37 |
global query_file_path
|
| 38 |
conn = duckdb.connect(query_file_path,read_only=True)
|
| 39 |
df = conn.execute(query_data.query).fetch_df()
|
| 40 |
+
return JSONResponse(json.loads(df.to_json(orient = "records")))
|
| 41 |
|
| 42 |
# @app.post("/llm")
|
| 43 |
# async def llm(prompt: str):
|