From bec13053aab3cd04d37f172c09196b3708d92689 Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Tue, 9 Sep 2025 17:26:07 +0800 Subject: [PATCH] perf: plan agent name --- .../core/workflow/dispatch/ai/agent/index.ts | 13 +++++++--- .../dispatch/ai/agent/sub/constants.ts | 24 +++++++++++++++++++ packages/web/i18n/en/chat.json | 2 ++ packages/web/i18n/zh-CN/chat.json | 2 ++ packages/web/i18n/zh-Hant/chat.json | 2 ++ .../core/chat/components/AIResponseBox.tsx | 18 +++++++++++--- 6 files changed, 55 insertions(+), 6 deletions(-) diff --git a/packages/service/core/workflow/dispatch/ai/agent/index.ts b/packages/service/core/workflow/dispatch/ai/agent/index.ts index a9dc830ab..b1efa2a8d 100644 --- a/packages/service/core/workflow/dispatch/ai/agent/index.ts +++ b/packages/service/core/workflow/dispatch/ai/agent/index.ts @@ -22,8 +22,15 @@ import { } from '@fastgpt/global/core/chat/adapt'; import { formatModelChars2Points } from '../../../../../support/wallet/usage/utils'; import { getHistoryPreview } from '@fastgpt/global/core/chat/utils'; -import { filterMemoryMessages, filterToolResponseToPreview, parseToolArgs } from '../utils'; -import { SubAppIds } from './sub/constants'; +import { + filterMemoryMessages, + filterToolResponseToPreview, + formatToolResponse, + getToolNodesByIds, + initToolNodes, + parseToolArgs +} from '../utils'; +import { SubAppIds, systemSubInfo } from './sub/constants'; import { getReferenceVariableValue, replaceEditorVariable, @@ -139,7 +146,7 @@ export const dispatchRunAgent = async (props: DispatchAgentModuleProps): Promise // Init tool params const toolNodesMap = new Map(runtimeSubApps.map((item) => [item.nodeId, item])); const getToolInfo = (id: string) => { - const toolNode = toolNodesMap.get(id); + const toolNode = toolNodesMap.get(id) || systemSubInfo[id]; return { name: toolNode?.name || '', avatar: toolNode?.avatar || '' diff --git a/packages/service/core/workflow/dispatch/ai/agent/sub/constants.ts b/packages/service/core/workflow/dispatch/ai/agent/sub/constants.ts index 8505bf35a..d674a9e38 100644 --- a/packages/service/core/workflow/dispatch/ai/agent/sub/constants.ts +++ b/packages/service/core/workflow/dispatch/ai/agent/sub/constants.ts @@ -1,4 +1,5 @@ import type { ChatCompletionTool } from '@fastgpt/global/core/ai/type'; +import { i18nT } from '../../../../../../../web/i18n/utils'; export enum SubAppIds { plan = 'plan_agent', @@ -7,3 +8,26 @@ export enum SubAppIds { model = 'model_agent', fileRead = 'file_read' } + +export const systemSubInfo: Record = { + [SubAppIds.plan]: { + name: i18nT('chat:plan_agent'), + avatar: 'common/detail' + }, + [SubAppIds.fileRead]: { + name: i18nT('chat:file_parse'), + avatar: 'core/workflow/template/readFiles' + }, + [SubAppIds.ask]: { + name: 'Ask Agent', + avatar: 'core/workflow/template/agent' + }, + [SubAppIds.stop]: { + name: 'Stop Agent', + avatar: 'core/workflow/template/agent' + }, + [SubAppIds.model]: { + name: 'Model Agent', + avatar: 'core/workflow/template/agent' + } +}; diff --git a/packages/web/i18n/en/chat.json b/packages/web/i18n/en/chat.json index ea59e6ec2..087b561d5 100644 --- a/packages/web/i18n/en/chat.json +++ b/packages/web/i18n/en/chat.json @@ -39,6 +39,7 @@ "file_amount_over": "Exceeded maximum file quantity {{max}}", "file_input": "File input", "file_input_tip": "You can obtain the link to the corresponding file through the \"File Link\" of the [Plug-in Start] node", + "file_parse": "File parsing", "history_slider.home.title": "chat", "home.chat_app": "HomeChat-{{name}}", "home.chat_id": "Chat ID", @@ -63,6 +64,7 @@ "no_workflow_response": "No workflow data", "not_query": "Missing query content", "not_select_file": "No file selected", + "plan_agent": "Plan agent", "plugins_output": "Plugin Output", "press_to_speak": "Hold down to speak", "query_extension_IO_tokens": "Problem Optimization Input/Output Tokens", diff --git a/packages/web/i18n/zh-CN/chat.json b/packages/web/i18n/zh-CN/chat.json index 780c686eb..de8ea0817 100644 --- a/packages/web/i18n/zh-CN/chat.json +++ b/packages/web/i18n/zh-CN/chat.json @@ -39,6 +39,7 @@ "file_amount_over": "超出最大文件数量 {{max}}", "file_input": "系统文件", "file_input_tip": "可通过【插件开始】节点的“文件链接”获取对应文件的链接", + "file_parse": "文件解析", "history_slider.home.title": "聊天", "home.chat_app": "首页聊天", "home.chat_id": "会话ID", @@ -63,6 +64,7 @@ "no_workflow_response": "没有运行数据", "not_query": "缺少查询内容", "not_select_file": "未选择文件", + "plan_agent": "任务规划", "plugins_output": "插件输出", "press_to_speak": "按住说话", "query_extension_IO_tokens": "问题优化输入/输出 Tokens", diff --git a/packages/web/i18n/zh-Hant/chat.json b/packages/web/i18n/zh-Hant/chat.json index b67743ff0..0966b4806 100644 --- a/packages/web/i18n/zh-Hant/chat.json +++ b/packages/web/i18n/zh-Hant/chat.json @@ -39,6 +39,7 @@ "file_amount_over": "超出檔案數量上限 {{max}}", "file_input": "檔案輸入", "file_input_tip": "可透過「外掛程式啟動」節點的「檔案連結」取得對應檔案的連結", + "file_parse": "文件解析", "history_slider.home.title": "聊天", "home.chat_app": "首页聊天", "home.chat_id": "會話ID", @@ -63,6 +64,7 @@ "no_workflow_response": "無工作流程資料", "not_query": "缺少查詢內容", "not_select_file": "尚未選取檔案", + "plan_agent": "任務規劃", "plugins_output": "外掛程式輸出", "press_to_speak": "按住說話", "query_extension_IO_tokens": "問題最佳化輸入/輸出 Tokens", diff --git a/projects/app/src/components/core/chat/components/AIResponseBox.tsx b/projects/app/src/components/core/chat/components/AIResponseBox.tsx index 7bfe7d91d..e14c838d2 100644 --- a/projects/app/src/components/core/chat/components/AIResponseBox.tsx +++ b/projects/app/src/components/core/chat/components/AIResponseBox.tsx @@ -16,7 +16,7 @@ import type { ToolModuleResponseItemType, UserChatItemValueItemType } from '@fastgpt/global/core/chat/type'; -import React, { useCallback, useMemo } from 'react'; +import React, { useState, useCallback, useMemo } from 'react'; import MyIcon from '@fastgpt/web/components/common/Icon'; import Avatar from '@fastgpt/web/components/common/Avatar'; import type { @@ -33,6 +33,7 @@ import { useContextSelector } from 'use-context-selector'; import { type OnOpenCiteModalProps } from '@/web/core/chat/context/chatItemContext'; import { ChatBoxContext } from '../ChatContainer/ChatBox/Provider'; import { useCreation } from 'ahooks'; +import { useSafeTranslation } from '@fastgpt/web/hooks/useSafeTranslation'; const accordionButtonStyle = { w: 'auto', @@ -131,6 +132,9 @@ const RenderTool = React.memo( showAnimation: boolean; tools: ToolModuleResponseItemType[]; }) { + const { t } = useSafeTranslation(); + const [userOnchange, setUserOnchange] = useState(false); + return ( {tools.map((tool) => { @@ -145,12 +149,20 @@ const RenderTool = React.memo( const toolResponse = formatJson(tool.response); return ( - + { + setUserOnchange(true); + }} + > - {tool.toolName} + {t(tool.toolName)} {showAnimation && !tool.response && }