From 09a567a542c45e203d718789c2e682979ba94307 Mon Sep 17 00:00:00 2001 From: sion123 <450702724@qq.com> Date: Sat, 11 Apr 2026 16:22:11 +0800 Subject: [PATCH] =?UTF-8?q?feat(agent):=20=E6=94=AF=E6=8C=81=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E7=B3=BB=E7=BB=9F=E6=8F=90=E7=A4=BA=E8=AF=8D?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E5=AF=B9=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 前端 API 新增 customSystemPrompt 参数,agentId 变为可选 - 聊天抽屉支持自定义提示词时传递参数并调整宽度 - 我的收藏模态框返回提示词内容供聊天使用 - 后端 Dify 服务优先使用自定义提示词,支持无 agentId 的对话 - Dify 请求 VO 中 agentId 改为非必填,新增 customSystemPrompt 字段 --- frontend/app/web-gold/src/api/agent.js | 7 +++-- .../src/components/agents/ChatDrawer.vue | 5 ++-- .../components/agents/MyFavoritesModal.vue | 4 ++- .../tik/dify/service/DifyServiceImpl.java | 26 ++++++++++++++----- .../module/tik/dify/vo/DifyChatReqVO.java | 6 +++-- 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/frontend/app/web-gold/src/api/agent.js b/frontend/app/web-gold/src/api/agent.js index c04bcd0f81..06a92e746d 100644 --- a/frontend/app/web-gold/src/api/agent.js +++ b/frontend/app/web-gold/src/api/agent.js @@ -21,10 +21,11 @@ export function getAgentList() { /** * 流式对话(SSE) * @param {Object} options - 请求配置 - * @param {number} options.agentId - 智能体ID + * @param {number} [options.agentId] - 智能体ID(使用 customSystemPrompt 时可不传) * @param {string} options.content - 用户输入内容 * @param {string} [options.conversationId] - 会话ID(可选,首次对话不传) * @param {string} [options.modelMode] - 模型模式:pro-深度版 standard-标准版 + * @param {string} [options.customSystemPrompt] - 自定义系统提示词(使用用户自建风格时传入) * @param {AbortController} [options.ctrl] - 取消控制器 * @param {Function} options.onMessage - 消息回调 * @param {Function} [options.onError] - 错误回调 @@ -36,6 +37,7 @@ export async function sendChatStream(options) { content, conversationId, modelMode = 'pro', + customSystemPrompt, ctrl, onMessage, onError, @@ -56,7 +58,8 @@ export async function sendChatStream(options) { agentId, content, conversationId, - modelMode + modelMode, + customSystemPrompt }), onmessage: (event) => { if (typeof onMessage === 'function') { diff --git a/frontend/app/web-gold/src/components/agents/ChatDrawer.vue b/frontend/app/web-gold/src/components/agents/ChatDrawer.vue index 6e829a77af..b31bece763 100644 --- a/frontend/app/web-gold/src/components/agents/ChatDrawer.vue +++ b/frontend/app/web-gold/src/components/agents/ChatDrawer.vue @@ -123,7 +123,8 @@ const executeStreamRequest = async (prompt) => { try { await sendChatStream({ - agentId: props.agent?.id, + agentId: props.agent?.customSystemPrompt ? undefined : props.agent?.id, + customSystemPrompt: props.agent?.customSystemPrompt, content: prompt, modelMode: modelMode.value, ctrl: abortController.value, @@ -170,7 +171,7 @@ watch(() => props.visible, (val) => {