Refactor api_server.py to import environment setup and schema loading from bootstrap.py, enhancing modularity. Introduce a new function in Text2SQLOrchestrator to prioritize VCUserAccessibleFunction in table selection, improving SQL generation accuracy. Update validation logic to enforce restrictions on CJK characters in SQL string literals, ensuring compliance with business rules. Enhance prompts to clarify SQL generation constraints regarding date conditions and CJK usage.

This commit is contained in:
陈辅元
2026-04-17 15:15:01 +08:00
parent bcb9a205fa
commit 3891aae7fe
19 changed files with 707 additions and 306 deletions
+3
View File
@@ -45,6 +45,9 @@
## 流式输出(补充)
- **`/g3sb/api/nl/chat/stream`**:`chat` 与 `sql_gen` 阶段的正文改为多段 SSE 分片推送(默认每段约 64 字符,可用环境变量 `SSE_STREAM_CHUNK_CHARS` 调整),与前端 `onDelta` 累加逻辑一致。
- **重复 SQL 修复(补充)**:为避免同一次 SSE 响应中出现两段 SQL(LLM 自吐 `<data>...</data>` + 服务端末尾补发 `<data>{"sql":...}</data>`),后端在透传 LLM delta 时会过滤掉任何 `<data>...</data>` 段,仅保留流结束时的标准结构化 `<data>` 片段供前端解析。
- **现状约束**:由于当前前端会直接拼接展示 delta 且保留 `<data>`,流式接口默认**不再补发**结构化 `<data>{"sql":...}</data>`,避免“SQL + 可见 `<data>`”造成重复展示。
- **如需补发**:设置环境变量 `SSE_APPEND_SQL_DATA_TAG=true` 才会在流末尾补发结构化 `<data>`(仅建议给会过滤 `<data>` 的客户端使用)。
## 后续事项