From 38bf40d71001d3ab4e519a07afdfc9b2b92d20bc Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Mon, 8 Sep 2025 17:35:51 +0800 Subject: [PATCH] add lang --- .../service/core/workflow/dispatch/ai/agent/index.ts | 9 +++++++-- .../service/core/workflow/dispatch/ai/agent/sub/index.ts | 5 ++++- .../core/workflow/dispatch/ai/agent/sub/userApp/index.ts | 0 packages/service/core/workflow/dispatch/ai/agent/type.ts | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) delete mode 100644 packages/service/core/workflow/dispatch/ai/agent/sub/userApp/index.ts diff --git a/packages/service/core/workflow/dispatch/ai/agent/index.ts b/packages/service/core/workflow/dispatch/ai/agent/index.ts index 21bf79824..5ea8bf1f4 100644 --- a/packages/service/core/workflow/dispatch/ai/agent/index.ts +++ b/packages/service/core/workflow/dispatch/ai/agent/index.ts @@ -94,6 +94,7 @@ type Response = DispatchNodeResultType<{ export const dispatchRunAgent = async (props: DispatchAgentModuleProps): Promise => { let { node: { nodeId, name, isEntry, version, inputs }, + lang, runtimeNodes, runtimeEdges, histories, @@ -160,7 +161,7 @@ export const dispatchRunAgent = async (props: DispatchAgentModuleProps): Promise }; }; - const subAppList = await getSubApps({ subApps: runtimeSubApps, urls: fileLinks }); + const subAppList = await getSubApps({ subApps: runtimeSubApps, urls: fileLinks, lang }); console.log(JSON.stringify(subAppList, null, 2)); // const combinedSystemPrompt = `${parseAgentSystem({ systemPrompt, toolNodesMap })}\n\n${getTopAgentConstantPrompt()}`; @@ -262,7 +263,11 @@ export const dispatchRunAgent = async (props: DispatchAgentModuleProps): Promise handleToolResponse: async ({ call, messages }) => { const toolId = call.function.name; - const { response, usages, isEnd } = await (async () => { + const { + response, + usages = [], + isEnd + } = await (async () => { if (toolId === SubAppIds.stop) { return { response: '', diff --git a/packages/service/core/workflow/dispatch/ai/agent/sub/index.ts b/packages/service/core/workflow/dispatch/ai/agent/sub/index.ts index 1293e2786..57f9921c2 100644 --- a/packages/service/core/workflow/dispatch/ai/agent/sub/index.ts +++ b/packages/service/core/workflow/dispatch/ai/agent/sub/index.ts @@ -16,12 +16,15 @@ import type { RuntimeNodeItemType } from '@fastgpt/global/core/workflow/runtime/ import { MongoApp } from '../../../../../app/schema'; import { getMCPChildren } from '../../../../../app/mcp'; import { getMCPToolRuntimeNode } from '@fastgpt/global/core/app/mcpTools/utils'; +import type { localeType } from '@fastgpt/global/common/i18n/type'; export const getSubApps = async ({ subApps, + lang, urls }: { subApps: RuntimeNodeItemType[]; + lang?: localeType; urls?: string[]; }): Promise => { // System Tools: Plan Agent, stop sign, model agent. @@ -101,7 +104,7 @@ export const getSubApps = async ({ if (systemToolId) { const children = await getSystemToolRunTimeNodeFromSystemToolset({ toolSetNode: node, - lang: 'en' + lang }); return getToolNode(children); } else if (mcpToolsetVal) { diff --git a/packages/service/core/workflow/dispatch/ai/agent/sub/userApp/index.ts b/packages/service/core/workflow/dispatch/ai/agent/sub/userApp/index.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/packages/service/core/workflow/dispatch/ai/agent/type.ts b/packages/service/core/workflow/dispatch/ai/agent/type.ts index a2bb58b6e..de24114ee 100644 --- a/packages/service/core/workflow/dispatch/ai/agent/type.ts +++ b/packages/service/core/workflow/dispatch/ai/agent/type.ts @@ -15,5 +15,5 @@ export type DispatchSubAppProps = { }; export type DispatchSubAppResponse = { response: string; - usages: ChatNodeUsageType[]; + usages?: ChatNodeUsageType[]; };