fix: 注册 rag-chat prompt template,修复 AI 对话始终返回 fallback
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 44s
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 44s
根因:PromptTemplateService 未注册 rag-chat 的 prompt,
sendMessage 中 promptTemplate.get('rag-chat') 抛异常被 catch,
永远走 fallbackReply("AI 服务暂时不可用")。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
78e21c4c4c
commit
d8877f926f
@ -9,6 +9,8 @@ import { REVIEW_CARD_GENERATION_SYSTEM_PROMPT } from './review-card-generation.p
|
||||
import { REVIEW_CARD_OUTPUT_SCHEMA_DESC } from './schemas/review-card-generation.schema';
|
||||
import { LEARNING_TREND_SYSTEM_PROMPT } from './learning-trend.prompt';
|
||||
import { LEARNING_TREND_OUTPUT_SCHEMA_DESC } from './schemas/learning-trend.schema';
|
||||
import { RAG_CHAT_SYSTEM_PROMPT } from './rag-chat.prompt';
|
||||
import { RAG_CHAT_OUTPUT_SCHEMA_DESC } from './schemas/rag-chat.schema';
|
||||
|
||||
export interface PromptTemplate {
|
||||
key: string;
|
||||
@ -52,6 +54,12 @@ export class PromptTemplateService {
|
||||
systemPrompt: LEARNING_TREND_SYSTEM_PROMPT,
|
||||
outputSchemaDesc: LEARNING_TREND_OUTPUT_SCHEMA_DESC,
|
||||
});
|
||||
this.register({
|
||||
key: 'rag-chat',
|
||||
version: 'v1',
|
||||
systemPrompt: RAG_CHAT_SYSTEM_PROMPT,
|
||||
outputSchemaDesc: RAG_CHAT_OUTPUT_SCHEMA_DESC,
|
||||
});
|
||||
}
|
||||
|
||||
get(key: string, version?: string): PromptTemplate {
|
||||
|
||||
7
src/modules/ai/prompts/rag-chat.prompt.ts
Normal file
7
src/modules/ai/prompts/rag-chat.prompt.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export const RAG_CHAT_SYSTEM_PROMPT = `你是知习 AI 学习助手。基于提供的知识库内容回答用户问题。
|
||||
|
||||
## 回答要求
|
||||
- 基于提供的知识库内容回答,不要编造信息
|
||||
- 如果知识库内容不足以回答问题,请诚实告知
|
||||
- 回答时可以用「根据知识库中的《xxx》...」引用来源
|
||||
- 回答应准确、简洁、有依据`;
|
||||
6
src/modules/ai/prompts/schemas/rag-chat.schema.ts
Normal file
6
src/modules/ai/prompts/schemas/rag-chat.schema.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export const RAG_CHAT_OUTPUT_SCHEMA_DESC = `{
|
||||
"answer": "你的回答内容",
|
||||
"citations": [
|
||||
{ "title": "引用的知识点标题", "snippet": "引用的原文片段" }
|
||||
]
|
||||
}`;
|
||||
Loading…
x
Reference in New Issue
Block a user