From cc231506cb37d9d3801878e8673be4b6b3643f60 Mon Sep 17 00:00:00 2001 From: liuwei Date: Thu, 23 Apr 2026 10:38:18 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BE=A4=E6=80=BB=E7=BB=93=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81=E6=94=AF=E6=8C=81markdown/template=E5=8F=8C=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E8=AF=8D=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 Dify 工作流新增 summary_mode 输入变量,支持 markdown/template 模式识别\n- 新增 if-else 分支节点,根据 summary_mode 路由到不同 LLM 提示词\n- 保留原 Markdown 提示词链路,新增 Template 专用紧凑提示词链路\n- 为 template 分支补充独立输出节点,并接入失败回退链路\n- 在 message_summary 插件请求输入中新增 summary_mode 字段,传递当前渲染模式 --- plugins/message_summary/main.py | 4 + plugins/message_summary/群总结AI (1).yml | 484 +++++++++++++++++++++++ 2 files changed, 488 insertions(+) create mode 100644 plugins/message_summary/群总结AI (1).yml diff --git a/plugins/message_summary/main.py b/plugins/message_summary/main.py index 52769bd..d9800e5 100644 --- a/plugins/message_summary/main.py +++ b/plugins/message_summary/main.py @@ -1316,6 +1316,10 @@ class MessageSummaryPlugin(MessagePluginInterface): "query": prompt, "group_name": group_name, "chat_content": content_compress, + # 传给 Dify 工作流做提示词分流: + # - markdown: 走历史 Markdown 风格提示词; + # - template: 走模板友好的紧凑结构提示词。 + "summary_mode": self._summary_image_mode, } self.LOG.info(f"群聊总结请求准备: group={group_name}, mode={self._api_mode}, response_mode={self._response_mode}") diff --git a/plugins/message_summary/群总结AI (1).yml b/plugins/message_summary/群总结AI (1).yml new file mode 100644 index 0000000..2984bf5 --- /dev/null +++ b/plugins/message_summary/群总结AI (1).yml @@ -0,0 +1,484 @@ +app: + description: 总结机器人 + icon: 🤖 + icon_background: '#FFEAD5' + mode: workflow + name: 群总结AI + use_icon_as_answer_icon: false +dependencies: +- current_identifier: null + type: marketplace + value: + marketplace_plugin_unique_identifier: langgenius/openai_api_compatible:0.0.27@f9ce3ff5e28f09931a3a7fca59add2d09590408f7e9a3d701b10c77a60249719 + version: null +kind: app +version: 0.5.0 +workflow: + conversation_variables: [] + environment_variables: [] + features: + file_upload: + allowed_file_extensions: + - .JPG + - .JPEG + - .PNG + - .GIF + - .WEBP + - .SVG + allowed_file_types: + - image + allowed_file_upload_methods: + - local_file + - remote_url + enabled: false + fileUploadConfig: + audio_file_size_limit: 50 + batch_count_limit: 5 + file_size_limit: 15 + image_file_batch_limit: 10 + image_file_size_limit: 10 + single_chunk_attachment_limit: 10 + video_file_size_limit: 100 + workflow_file_upload_limit: 10 + image: + enabled: false + number_limits: 3 + transfer_methods: + - local_file + - remote_url + number_limits: 3 + opening_statement: '' + retriever_resource: + enabled: true + sensitive_word_avoidance: + enabled: false + speech_to_text: + enabled: false + suggested_questions: [] + suggested_questions_after_answer: + enabled: false + text_to_speech: + enabled: false + language: '' + voice: '' + graph: + edges: + - data: + isInIteration: false + isInLoop: false + sourceType: start + targetType: if-else + id: 1775526517808-source-1779001000101-target + source: '1775526517808' + sourceHandle: source + target: '1779001000101' + targetHandle: target + type: custom + zIndex: 0 + - data: + isInIteration: false + isInLoop: false + sourceType: if-else + targetType: llm + id: 1779001000101-markdown-case-1775526520571-target + source: '1779001000101' + sourceHandle: markdown_case + target: '1775526520571' + targetHandle: target + type: custom + zIndex: 0 + - data: + isInIteration: false + isInLoop: false + sourceType: if-else + targetType: llm + id: 1779001000101-template-case-1779001000201-target + source: '1779001000101' + sourceHandle: template_case + target: '1779001000201' + targetHandle: target + type: custom + zIndex: 0 + - data: + isInLoop: false + sourceType: if-else + targetType: llm + id: 1779001000101-false-1775526520571-target + source: '1779001000101' + sourceHandle: 'false' + target: '1775526520571' + targetHandle: target + type: custom + zIndex: 0 + - data: + isInIteration: false + isInLoop: false + sourceType: llm + targetType: end + id: 1775526520571-source-1775526572853-target + source: '1775526520571' + sourceHandle: source + target: '1775526572853' + targetHandle: target + type: custom + zIndex: 0 + - data: + isInIteration: false + isInLoop: false + sourceType: llm + targetType: end + id: 1779001000201-source-1779001000301-target + source: '1779001000201' + sourceHandle: source + target: '1779001000301' + targetHandle: target + type: custom + zIndex: 0 + - data: + isInLoop: false + sourceType: llm + targetType: llm + id: 1779001000201-fail-branch-17766505156180-target + source: '1779001000201' + sourceHandle: fail-branch + target: '17766505156180' + targetHandle: target + type: custom + zIndex: 0 + - data: + isInLoop: false + sourceType: llm + targetType: llm + id: 1775526520571-fail-branch-17766505156180-target + source: '1775526520571' + sourceHandle: fail-branch + target: '17766505156180' + targetHandle: target + type: custom + zIndex: 0 + - data: + isInIteration: false + isInLoop: false + sourceType: llm + targetType: end + id: 17766505156180-source-1776650551808-target + source: '17766505156180' + sourceHandle: source + target: '1776650551808' + targetHandle: target + type: custom + zIndex: 0 + nodes: + - data: + selected: true + title: 用户输入 + type: start + variables: + - default: markdown + hint: '' + label: summary_mode + max_length: 32 + options: [] + placeholder: markdown/template + required: false + type: text-input + variable: summary_mode + - default: '' + hint: '' + label: query + max_length: 9999999 + options: [] + placeholder: '' + required: true + type: paragraph + variable: query + height: 109 + id: '1775526517808' + position: + x: 0 + y: 22 + positionAbsolute: + x: 0 + y: 22 + selected: true + sourcePosition: right + targetPosition: left + type: custom + width: 242 + - data: + cases: + - case_id: markdown_case + conditions: + - comparison_operator: contains + id: markdown_case_cond + value: markdown + varType: string + variable_selector: + - '1775526517808' + - summary_mode + id: markdown_case + logical_operator: and + - case_id: template_case + conditions: + - comparison_operator: contains + id: template_case_cond + value: template + varType: string + variable_selector: + - '1775526517808' + - summary_mode + id: template_case + logical_operator: and + selected: false + title: 渲染模式分支 + type: if-else + height: 172 + id: '1779001000101' + position: + x: 308 + y: 15 + positionAbsolute: + x: 308 + y: 15 + selected: false + sourcePosition: right + targetPosition: left + type: custom + width: 242 + - data: + context: + enabled: false + variable_selector: [] + error_strategy: fail-branch + model: + completion_params: + temperature: 0.7 + mode: chat + name: grok-4 + provider: langgenius/openai_api_compatible/openai_api_compatible + prompt_template: + - id: 99711a1c-46bd-4a45-8551-1fa21ff2e884 + role: system + text: "你是一名「微信群高效总结官」。 \n目标:快速整理群内的有效信息,剥离无效沟通,提炼重点观点与交易信息。 重要:最少总结5个话题\n\ + 要求:生成 **双层结构总结**——先速览重点,再补充详情。 请不要翻译用户昵称。请按照以下模板使用标准markdown格式输出。\n---\n\ + \n# \U0001F31F「[群名] - [最新日期] 总结」\U0001F31F\n\n---\n\n## ⚡ 一分钟速览\n\n(本部分仅列核心信息,帮助用户快速掌握重点)\n\ + \n* \U0001F4E9 **今日消息数**:[总数] 条\n* \U0001F525 **最热时段**:[时段]\n\n### \U0001F3C6\ + \ 核心话题与结论\n\n1. **[话题1简述]**:[核心结论]\n2. **[话题2简述]**:[核心结论]\n3. **[话题3简述]**:[核心结论]\n\ + 4. **[话题4简述]**:[核心结论]\n5. **[话题5简述]**:[核心结论]\n\n### \U0001F4B0 交易/资源快报\n\ + \n* [@用户A] 出售 **[商品]**,价格 **[金额]**\n* [@用户B] 推荐 **[工具/资源链接]**\n\n### \U0001F4CC\ + \ 今日总结\n\n大家在 **[主题]** 上形成 **[共识/存在分歧]** —— 建议后续关注 **[方向]**。\n\n---\n\n\ + ## \U0001F30C 话题详情\n\n### 1️⃣ 【[话题1]:[话题主题]】\n\n* **时段**:[开始时间] - [结束时间]\n\ + * **参与人数**:\U0001F465 [具体人数] 人参与\n\n#### \U0001F50D 核心观点回顾\n\n* **[@用户A]**:认为\ + \ **[观点1]** (理由:**[简要原因]**)\n* **[@用户B]**:支持/反驳,提出 **[观点2]**\n* **[@用户C]**:补充\ + \ **[观点3]**,并举了 **[实例/经验]**\n\n#### \U0001F9E9 客观分析\n\n* **共识点**:大多数人认同\ + \ **[共识]**\n* **分歧点**:争论焦点在 **[矛盾点]**\n* **价值**:该讨论对 **[领域/问题]** 提供了参考\n\ + \n#### \U0001F525 亮点瞬间\n\n> **[@用户D] 金句:** “**[精选金句]**”\n\n---\n\n###\ + \ 2️⃣ 【[话题2]:[话题主题]】\n\n* **时段**:[开始时间] - [结束时间]\n* **参与人数**:\U0001F465\ + \ [具体人数] 人参与\n\n#### \U0001F50D 核心观点回顾\n\n* **[@用户X]**:...\n* **[@用户Y]**:...\n\ + \n#### \U0001F9E9 客观分析\n\n* **共识点**:...\n* **分歧点**:...\n\n#### \U0001F525\ + \ 亮点瞬间\n\n> **[@用户Z] 金句:** “**[精选金句]**”\n\n---\n\n## \U0001F4B0 交易与资源区\n\ + \n(集中收录卖货和资源分享,方便用户直接定位)\n\n* **[@用户X] 卖货**:**[商品名称 + 价格]**\n* **[@用户Y]\ + \ 分享**:[工具/文章/资源链接](推荐理由:[简要理由])\n* **[@用户Z] 提供**:**[优惠/活动信息]** (截止日期:[日期])\n\ + \n---\n\n## \U0001F396️ 今日荣誉榜\n\n### \U0001F3C6 群聊 MVP:[@用户N]\n\n* **理由**:\n\ + \ * 发起 [数量] 个话题\n * 提供 [数量] 个实用信息(资源/交易)\n * 最佳金句:“**[语录]**”\n\ + \n---\n\n✨ *本总结由 AI 自动生成,帮助你 1 分钟快速补齐群聊重点!*\n" + - id: 79bea224-b4af-4eb2-83ff-64db7356f9ff + role: user + text: '{{#1775526517808.query#}}' + retry_config: + max_retries: 3 + retry_enabled: true + retry_interval: 1000 + selected: false + title: LLM + type: llm + vision: + enabled: false + height: 154 + id: '1775526520571' + position: + x: 342 + y: 0 + positionAbsolute: + x: 342 + y: 0 + selected: false + sourcePosition: right + targetPosition: left + type: custom + width: 242 + - data: + context: + enabled: false + variable_selector: [] + error_strategy: fail-branch + model: + completion_params: + temperature: 0.6 + mode: chat + name: grok-4 + provider: langgenius/openai_api_compatible/openai_api_compatible + prompt_template: + - id: template_system_prompt + role: system + text: "你是一名「微信群总结结构化编辑官」。\n目标:输出更适配 summary template 的内容结构,减少无关铺陈。\n要求:\n1) 仍然至少覆盖 5 个话题;\n2) 每个话题控制在“时段/参与人数/核心观点(2-3条)/客观分析(1-2条)/亮点瞬间(1条)”的紧凑结构;\n3) 保留昵称原样,不翻译昵称;\n4) 使用标准 Markdown 输出,不要 JSON,不要代码块包裹;\n5) 控制篇幅,避免单个话题过长。\n\n请严格按以下结构输出:\n\n# 🌟「[群名] - [最新日期] 总结」🌟\n\n## ⚡ 一分钟速览\n- 今日消息数:[总数]\n- 最热时段:[时段]\n\n### 🏆 核心话题与结论\n1. [话题1简述]:[结论]\n2. [话题2简述]:[结论]\n3. [话题3简述]:[结论]\n4. [话题4简述]:[结论]\n5. [话题5简述]:[结论]\n\n## 🌌 话题详情\n### 1️⃣ 【[话题1]】\n- 时段:[开始]-[结束]\n- 参与人数:[人数]\n#### 🔍 核心观点回顾\n- [观点1]\n- [观点2]\n#### 🧩 客观分析\n- [分析1]\n- [分析2]\n#### 🔥 亮点瞬间\n> [金句或高光总结]\n\n(继续话题2~5,保持同样结构)\n\n## 💰 交易与资源区\n- [卖货/资源1]\n- [卖货/资源2]\n\n## 🎖️ 今日荣誉榜\n- MVP:[昵称](简要理由)\n" + - id: template_user_prompt + role: user + text: '{{#1775526517808.query#}}' + retry_config: + max_retries: 3 + retry_enabled: true + retry_interval: 1000 + selected: false + title: LLM Template + type: llm + vision: + enabled: false + height: 170 + id: '1779001000201' + position: + x: 670 + y: -170 + positionAbsolute: + x: 670 + y: -170 + selected: false + sourcePosition: right + targetPosition: left + type: custom + width: 242 + - data: + outputs: + - value_selector: + - '1775526520571' + - text + value_type: string + variable: text + selected: false + title: 输出 + type: end + height: 88 + id: '1775526572853' + position: + x: 704 + y: 7 + positionAbsolute: + x: 704 + y: 7 + selected: false + sourcePosition: right + targetPosition: left + type: custom + width: 242 + - data: + outputs: + - value_selector: + - '1779001000201' + - text + value_type: string + variable: text + selected: false + title: 输出 Template + type: end + height: 88 + id: '1779001000301' + position: + x: 1030 + y: -155 + positionAbsolute: + x: 1030 + y: -155 + selected: false + sourcePosition: right + targetPosition: left + type: custom + width: 242 + - data: + context: + enabled: false + variable_selector: [] + model: + completion_params: + temperature: 0.7 + mode: chat + name: gpt-5.4 + provider: langgenius/openai_api_compatible/openai_api_compatible + prompt_template: + - id: 99711a1c-46bd-4a45-8551-1fa21ff2e884 + role: system + text: "你是一名「微信群高效总结官」。 \n目标:快速整理群内的有效信息,剥离无效沟通,提炼重点观点与交易信息。 重要:最少总结5个话题\n\ + 要求:生成 **双层结构总结**——先速览重点,再补充详情。 请不要翻译用户昵称。请按照以下模板使用标准markdown格式输出。\n---\n\ + \n# \U0001F31F「[群名] - [最新日期] 总结」\U0001F31F\n\n---\n\n## ⚡ 一分钟速览\n\n(本部分仅列核心信息,帮助用户快速掌握重点)\n\ + \n* \U0001F4E9 **今日消息数**:[总数] 条\n* \U0001F525 **最热时段**:[时段]\n\n### \U0001F3C6\ + \ 核心话题与结论\n\n1. **[话题1简述]**:[核心结论]\n2. **[话题2简述]**:[核心结论]\n3. **[话题3简述]**:[核心结论]\n\ + 4. **[话题4简述]**:[核心结论]\n5. **[话题5简述]**:[核心结论]\n\n### \U0001F4B0 交易/资源快报\n\ + \n* [@用户A] 出售 **[商品]**,价格 **[金额]**\n* [@用户B] 推荐 **[工具/资源链接]**\n\n### \U0001F4CC\ + \ 今日总结\n\n大家在 **[主题]** 上形成 **[共识/存在分歧]** —— 建议后续关注 **[方向]**。\n\n---\n\n\ + ## \U0001F30C 话题详情\n\n### 1️⃣ 【[话题1]:[话题主题]】\n\n* **时段**:[开始时间] - [结束时间]\n\ + * **参与人数**:\U0001F465 [具体人数] 人参与\n\n#### \U0001F50D 核心观点回顾\n\n* **[@用户A]**:认为\ + \ **[观点1]** (理由:**[简要原因]**)\n* **[@用户B]**:支持/反驳,提出 **[观点2]**\n* **[@用户C]**:补充\ + \ **[观点3]**,并举了 **[实例/经验]**\n\n#### \U0001F9E9 客观分析\n\n* **共识点**:大多数人认同\ + \ **[共识]**\n* **分歧点**:争论焦点在 **[矛盾点]**\n* **价值**:该讨论对 **[领域/问题]** 提供了参考\n\ + \n#### \U0001F525 亮点瞬间\n\n> **[@用户D] 金句:** “**[精选金句]**”\n\n---\n\n###\ + \ 2️⃣ 【[话题2]:[话题主题]】\n\n* **时段**:[开始时间] - [结束时间]\n* **参与人数**:\U0001F465\ + \ [具体人数] 人参与\n\n#### \U0001F50D 核心观点回顾\n\n* **[@用户X]**:...\n* **[@用户Y]**:...\n\ + \n#### \U0001F9E9 客观分析\n\n* **共识点**:...\n* **分歧点**:...\n\n#### \U0001F525\ + \ 亮点瞬间\n\n> **[@用户Z] 金句:** “**[精选金句]**”\n\n---\n\n## \U0001F4B0 交易与资源区\n\ + \n(集中收录卖货和资源分享,方便用户直接定位)\n\n* **[@用户X] 卖货**:**[商品名称 + 价格]**\n* **[@用户Y]\ + \ 分享**:[工具/文章/资源链接](推荐理由:[简要理由])\n* **[@用户Z] 提供**:**[优惠/活动信息]** (截止日期:[日期])\n\ + \n---\n\n## \U0001F396️ 今日荣誉榜\n\n### \U0001F3C6 群聊 MVP:[@用户N]\n\n* **理由**:\n\ + \ * 发起 [数量] 个话题\n * 提供 [数量] 个实用信息(资源/交易)\n * 最佳金句:“**[语录]**”\n\ + \n---\n\n✨ *本总结由 AI 自动生成,帮助你 1 分钟快速补齐群聊重点!*\n" + - id: 79bea224-b4af-4eb2-83ff-64db7356f9ff + role: user + text: '{{#1775526517808.query#}}' + retry_config: + max_retries: 2 + retry_enabled: true + retry_interval: 1000 + selected: false + title: LLM (1) + type: llm + vision: + enabled: false + height: 118 + id: '17766505156180' + position: + x: 704 + y: 175 + positionAbsolute: + x: 704 + y: 175 + selected: false + sourcePosition: right + targetPosition: left + type: custom + width: 242 + - data: + outputs: + - value_selector: + - '17766505156180' + - text + value_type: string + variable: text + selected: false + title: 输出 2 + type: end + height: 88 + id: '1776650551808' + position: + x: 1046 + y: 190 + positionAbsolute: + x: 1046 + y: 190 + selected: false + sourcePosition: right + targetPosition: left + type: custom + width: 242 + viewport: + x: 127.66537686601441 + y: 381.7866425896775 + zoom: 0.923655537541026 + rag_pipeline_variables: []