From 8c25b20fe23f40200681f57aaf7f08c7d3626afd Mon Sep 17 00:00:00 2001 From: iven Date: Thu, 23 Apr 2026 17:58:58 +0800 Subject: [PATCH] =?UTF-8?q?feat(suggest):=20=E6=9B=B4=E6=96=B0=20suggestio?= =?UTF-8?q?n=20prompt=20=E4=B8=BA=E6=B7=B7=E5=90=88=E5=9E=8B=EF=BC=882?= =?UTF-8?q?=E7=BB=AD=E9=97=AE+1=E7=AE=A1=E5=AE=B6=E5=85=B3=E6=80=80?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - llm-service.ts: HARDCODED_PROMPTS.suggestions.system 改为混合型 - 2条对话续问 + 1条管家关怀(痛点回访/经验复用/技能推荐) - streamStore.ts: LLM_PROMPTS_SYSTEM 改为引用 llm-service 导出 - 单一真相源,OTA 更新时自动生效 --- desktop/src/lib/llm-service.ts | 20 ++++++++++++-------- desktop/src/store/chat/streamStore.ts | 14 ++------------ 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/desktop/src/lib/llm-service.ts b/desktop/src/lib/llm-service.ts index 2439efe..7888087 100644 --- a/desktop/src/lib/llm-service.ts +++ b/desktop/src/lib/llm-service.ts @@ -646,17 +646,21 @@ const HARDCODED_PROMPTS: Record }, suggestions: { - system: `你是对话分析助手。根据最近的对话内容,生成 3 个用户可能想继续探讨的问题。 + system: `你是对话分析助手和智能管家。根据对话内容和用户画像信息,生成 3 个个性化建议。 -要求: -- 每个问题必须与对话内容直接相关,具体且有针对性 -- 帮助用户深入理解、实际操作或拓展思路 -- 每个问题不超过 30 个中文字符 -- 不要重复对话中已讨论过的内容 -- 使用与用户相同的语言 +## 生成规则 +1. 2 条对话续问(深入当前话题,帮助用户继续探索) +2. 1 条管家关怀(基于用户消息中提供的痛点、经验或技能信息) + - 如果有未解决痛点 → 回访建议,如"上次你提到X,后来解决了吗?" + - 如果有相关经验 → 引导复用,如"上次用X方法解决了类似问题,要再试试吗?" + - 如果有匹配技能 → 推荐使用,如"你可以试试 [技能名] 来处理这个" + - 如果没有提供痛点/经验/技能信息 → 全部生成对话续问 +3. 每个不超过 30 个中文字符 +4. 不要重复对话中已讨论过的内容 +5. 使用与用户相同的语言 只输出 JSON 数组,包含恰好 3 个字符串。不要输出任何其他内容。 -示例:["如何在生产环境中部署?", "这个方案的成本如何?", "有没有更简单的替代方案?"]`, +示例:["科室绩效分析可以按哪些维度拆解?", "上次的 researcher 技能能用在查房数据整理上吗?", "自动生成合规检查报告的模板有哪些?"]`, user: (context: string) => `以下是对话中最近的消息:\n\n${context}\n\n请生成 3 个后续问题。`, }, }; diff --git a/desktop/src/store/chat/streamStore.ts b/desktop/src/store/chat/streamStore.ts index d70751c..224a5e6 100644 --- a/desktop/src/store/chat/streamStore.ts +++ b/desktop/src/store/chat/streamStore.ts @@ -34,7 +34,7 @@ import { } from './conversationStore'; import { useMessageStore } from './messageStore'; import { useArtifactStore } from './artifactStore'; -import { llmSuggest } from '../../lib/llm-service'; +import { llmSuggest, LLM_PROMPTS } from '../../lib/llm-service'; import { detectNameSuggestion, detectAgentNameSuggestion } from '../../lib/cold-start-mapper'; import { fetchSuggestionContext, type SuggestionContext } from '../../lib/suggestion-context'; @@ -687,17 +687,7 @@ async function llmSuggestViaSaaS(userMessage: string): Promise { } } -const LLM_PROMPTS_SYSTEM = `你是对话分析助手。根据最近的对话内容,生成 3 个用户可能想继续探讨的问题。 - -要求: -- 每个问题必须与对话内容直接相关,具体且有针对性 -- 帮助用户深入理解、实际操作或拓展思路 -- 每个问题不超过 30 个中文字符 -- 不要重复对话中已讨论过的内容 -- 使用与用户相同的语言 - -只输出 JSON 数组,包含恰好 3 个字符串。不要输出任何其他内容。 -示例:["如何在生产环境中部署?", "这个方案的成本如何?", "有没有更简单的替代方案?"]`; +const LLM_PROMPTS_SYSTEM = LLM_PROMPTS.suggestions.system; // --------------------------------------------------------------------------- // ChatStore injection (avoids circular imports)