refactor(s2s): 语音助手基础提示词迁移到后端统一管理

- 后端 config.py:新增 S2S_INSTRUCTIONS(.env DPM_S2S_INSTRUCTIONS 可覆盖)
- rag.py:build_instructions() 组装 配置提示词 + 园区知识库摘要
- routers.py:GET /api/s2s/instructions 下发(前端连接时拉取)
- 前端 VoiceAssistant:删除硬编码 DEFAULT_INSTRUCTIONS,改拉取后端指令;
  仅保留后端不可用时的极简兜底

改提示词只需改后端(.env 或代码),前端零硬编码。
This commit is contained in:
Pine
2026-08-18 02:28:55 +08:00
parent e653c4b2f2
commit f4067c1f0e
4 changed files with 39 additions and 9 deletions
+10
View File
@@ -465,3 +465,13 @@ def kb_retrieve(q: str = "", top_k: int = 3):
except Exception as e: # noqa: BLE001
log.warning("kb retrieve 失败: %s", e)
return {"ok": False, "error": str(e)}
@router.get("/api/s2s/instructions")
def s2s_instructions():
"""语音助手基础提示词(服务端统一组装:配置提示词 + 园区知识库)"""
try:
from .rag import build_instructions
return {"ok": True, "instructions": build_instructions()}
except Exception as e: # noqa: BLE001
log.warning("s2s instructions 构建失败: %s", e)
return {"ok": False, "error": str(e)}