fix(captain): 试验场不查 FAQ 知识库 + 添加常见问题报 400

三个问题修复:

1. 添加常见问题报 400 (assistant_id 类型不匹配)
   - CreateResponseDialog.vue: route.params.assistantId 是字符串,
     传给后端 uint 字段导致 JSON 反序列化失败
   - 修复: Number(route.params.assistantId) 转为数字
   - 同时修复 POST /assistant_responses 无尾部斜杠 307 重定向问题

2. 试验场 playground 不做 RAG 检索
   - generatePlaygroundLLMResponse 只构建 system prompt + 对话历史,
     从不查 FAQ 知识库
   - 新增 retrieveFAQContext(): embed 用户问题 → pgvector 搜索 approved
     FAQ → 注入 system prompt
   - 受 feature_faq 配置开关控制

3. FAQ embedding 无法写入 (pgvector 序列化 + 维度问题)
   - pgvector stub 无 driver.Valuer, GORM Save() 报 SQLSTATE 42804
   - 新增 UpdateEmbedding() 用 ?::vector 原始 SQL 绕过
   - SimilaritySearch 排除 embedding 列 + 手动格式化向量字面量
   - embedding 列从 vector(1536) 改为 vector (跟随模型维度)
   - FAQ 创建/更新时自动索引 embedding (SetRAGService 注入)
This commit is contained in:
Rogee
2026-08-01 19:37:19 +08:00
parent 31238476b1
commit 63df5b8b91
9 changed files with 124 additions and 12 deletions
+1
View File
@@ -606,6 +606,7 @@ func Bootstrap(env string) (*App, error) {
// RAG service — knowledge base Q&A (embedding search + LLM generation)
ragService := service.NewRAGService(captainAssistantResponseRepo, captainAssistantRepo, llmProvider)
captainAssistantResponseService.SetRAGService(ragService)
// Auto-reply rule service — CRUD + condition matching + LLM reply composition
autoReplyRuleService := service.NewAutoReplyRuleService(captainAutoReplyRuleRepo, captainAssistantRepo, conversationRepo, llmProvider)