Spaces:
Sleeping
Sleeping
Commit ·
7c8d332
1
Parent(s): 74a81bd
update in schema
Browse files
app/api/v1/endpoints/schema.py
CHANGED
|
@@ -46,7 +46,7 @@ async def get_schema():
|
|
| 46 |
detail="An error occurred while fetching the schema."
|
| 47 |
)
|
| 48 |
|
| 49 |
-
router.post("schema/indexing")
|
| 50 |
async def update_indexing(request: TableIndexingRequest):
|
| 51 |
if not sql_agent.db:
|
| 52 |
raise HTTPException(
|
|
|
|
| 46 |
detail="An error occurred while fetching the schema."
|
| 47 |
)
|
| 48 |
|
| 49 |
+
@router.post("schema/indexing")
|
| 50 |
async def update_indexing(request: TableIndexingRequest):
|
| 51 |
if not sql_agent.db:
|
| 52 |
raise HTTPException(
|
app/api/v1/endpoints/sql_query.py
CHANGED
|
@@ -42,6 +42,7 @@ from pydantic import BaseModel
|
|
| 42 |
from app.services.sql_agent_instance import sql_agent
|
| 43 |
from typing import Optional
|
| 44 |
import uuid
|
|
|
|
| 45 |
router = APIRouter()
|
| 46 |
|
| 47 |
class SQLQueryRequest(BaseModel):
|
|
@@ -60,9 +61,11 @@ async def query_database(request: SQLQueryRequest):
|
|
| 60 |
## add debug
|
| 61 |
print(f"Thread ID: {thread_id}, Query: {request.query}")
|
| 62 |
result = sql_agent.execute_query(request.query, config={"configurable": {"thread_id": thread_id}})
|
|
|
|
| 63 |
print(f"Result: {result}")
|
| 64 |
return SQLQueryResponse(result=result, thread_id=thread_id)
|
| 65 |
except ValueError as e:
|
| 66 |
raise HTTPException(status_code=400, detail=str(e))
|
| 67 |
except Exception as e:
|
| 68 |
-
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
|
|
| 42 |
from app.services.sql_agent_instance import sql_agent
|
| 43 |
from typing import Optional
|
| 44 |
import uuid
|
| 45 |
+
from langchain_core.messages import AIMessage
|
| 46 |
router = APIRouter()
|
| 47 |
|
| 48 |
class SQLQueryRequest(BaseModel):
|
|
|
|
| 61 |
## add debug
|
| 62 |
print(f"Thread ID: {thread_id}, Query: {request.query}")
|
| 63 |
result = sql_agent.execute_query(request.query, config={"configurable": {"thread_id": thread_id}})
|
| 64 |
+
|
| 65 |
print(f"Result: {result}")
|
| 66 |
return SQLQueryResponse(result=result, thread_id=thread_id)
|
| 67 |
except ValueError as e:
|
| 68 |
raise HTTPException(status_code=400, detail=str(e))
|
| 69 |
except Exception as e:
|
| 70 |
+
raise HTTPException(status_code=500, detail=str(e))
|
| 71 |
+
|