feat: add get schema tool

This commit is contained in:
qixinbo
2026-03-22 00:42:48 +08:00
parent b0c8f84db9
commit 0e7f275285
8 changed files with 228 additions and 20 deletions
+9 -8
View File
@@ -74,14 +74,8 @@ class NL2SQLTool(Tool):
# Call the core logic
result = await process_nl2sql(request, on_progress=on_progress)
if result.error:
return f"Error executing query: {result.error}"
# Save the result data to context for potential later use by VisualizationTool
if result.result:
current_data.set(result.result)
# Save visualization payload to context so the chat stream can pick it up
# Always save visualization payload to context so the chat stream can pick it up
# Even if there's an error, we want the frontend to see the generated SQL
viz_payload = _build_sql_chart_viz(result)
existing_viz = current_viz_data.get()
if isinstance(existing_viz, dict):
@@ -91,6 +85,13 @@ class NL2SQLTool(Tool):
else:
current_viz_data.set(viz_payload)
if result.error:
return f"Error executing query: {result.error}\nGenerated SQL: {result.sql}"
# Save the result data to context for potential later use by VisualizationTool
if result.result:
current_data.set(result.result)
# Build a summary string for the Agent to read
row_count = len(result.result) if result.result else 0