From d78a0e9e4b65e6e333ec8860865ecd15e4b5fe5f Mon Sep 17 00:00:00 2001 From: Ctrlz <143257420+ctrlz526@users.noreply.github.com> Date: Fri, 15 Aug 2025 14:13:14 +0800 Subject: [PATCH] feat: add toolDescription field across various schemas and update related functions (#5452) --- .../global/core/workflow/runtime/type.d.ts | 1 + .../global/core/workflow/runtime/utils.ts | 1 + packages/global/core/workflow/type/index.d.ts | 1 + packages/global/core/workflow/type/node.d.ts | 1 + .../service/core/app/plugin/controller.ts | 22 ++++++++++++++++--- packages/service/core/app/plugin/type.d.ts | 1 + .../dispatch/ai/agent/functionCall.ts | 2 +- .../workflow/dispatch/ai/agent/promptCall.ts | 2 +- .../workflow/dispatch/ai/agent/toolChoice.ts | 2 +- packages/service/package.json | 2 +- pnpm-lock.yaml | 10 ++++----- .../app/plugin/getSystemPluginTemplates.ts | 3 ++- 12 files changed, 35 insertions(+), 13 deletions(-) diff --git a/packages/global/core/workflow/runtime/type.d.ts b/packages/global/core/workflow/runtime/type.d.ts index 8b33f0ce1..e5925790c 100644 --- a/packages/global/core/workflow/runtime/type.d.ts +++ b/packages/global/core/workflow/runtime/type.d.ts @@ -101,6 +101,7 @@ export type RuntimeNodeItemType = { name: StoreNodeItemType['name']; avatar: StoreNodeItemType['avatar']; intro?: StoreNodeItemType['intro']; + toolDescription?: StoreNodeItemType['toolDescription']; flowNodeType: StoreNodeItemType['flowNodeType']; showStatus?: StoreNodeItemType['showStatus']; isEntry?: boolean; diff --git a/packages/global/core/workflow/runtime/utils.ts b/packages/global/core/workflow/runtime/utils.ts index fdebbe2e0..5ed81f7d4 100644 --- a/packages/global/core/workflow/runtime/utils.ts +++ b/packages/global/core/workflow/runtime/utils.ts @@ -252,6 +252,7 @@ export const storeNodes2RuntimeNodes = ( name: node.name, avatar: node.avatar, intro: node.intro, + toolDescription: node.toolDescription, flowNodeType: node.flowNodeType, showStatus: node.showStatus, isEntry: entryNodeIds.includes(node.nodeId), diff --git a/packages/global/core/workflow/type/index.d.ts b/packages/global/core/workflow/type/index.d.ts index de20f9aee..a9f34ad0a 100644 --- a/packages/global/core/workflow/type/index.d.ts +++ b/packages/global/core/workflow/type/index.d.ts @@ -37,6 +37,7 @@ export type WorkflowTemplateType = { avatar: string; name: I18nStringType | string; intro?: I18nStringType | string; + toolDescription?: string; author?: string; courseUrl?: string; diff --git a/packages/global/core/workflow/type/node.d.ts b/packages/global/core/workflow/type/node.d.ts index ee4d1ba1c..69a83353c 100644 --- a/packages/global/core/workflow/type/node.d.ts +++ b/packages/global/core/workflow/type/node.d.ts @@ -56,6 +56,7 @@ export type FlowNodeCommonType = { avatar?: string; name: string; intro?: string; // template list intro + toolDescription?: string; showStatus?: boolean; // chatting response step status version?: string; diff --git a/packages/service/core/app/plugin/controller.ts b/packages/service/core/app/plugin/controller.ts index e232e1065..0a8f62aa8 100644 --- a/packages/service/core/app/plugin/controller.ts +++ b/packages/service/core/app/plugin/controller.ts @@ -314,7 +314,11 @@ export async function getChildAppPreviewNode({ })) } } - : { systemTool: { toolId: app.id } }) + : { + systemTool: { + toolId: app.id + } + }) }, showSourceHandle: app.isFolder ? false : true, showTargetHandle: app.isFolder ? false : true @@ -368,6 +372,7 @@ export async function getChildAppPreviewNode({ avatar: app.avatar, name: parseI18nString(app.name, lang), intro: parseI18nString(app.intro, lang), + toolDescription: app.toolDescription, courseUrl: app.courseUrl, userGuide: app.userGuide, showStatus: true, @@ -462,8 +467,17 @@ export async function getChildAppRuntimeById({ } const dbPluginFormat = (item: SystemPluginConfigSchemaType): SystemPluginTemplateItemType => { - const { name, avatar, intro, version, weight, templateType, associatedPluginId, userGuide } = - item.customConfig!; + const { + name, + avatar, + intro, + toolDescription, + version, + weight, + templateType, + associatedPluginId, + userGuide + } = item.customConfig!; return { id: item.pluginId, @@ -475,6 +489,7 @@ const dbPluginFormat = (item: SystemPluginConfigSchemaType): SystemPluginTemplat name, avatar, intro, + toolDescription, weight, templateType, originCost: item.originCost, @@ -556,6 +571,7 @@ export const getSystemTools = async (): Promise name: item.name, avatar: item.avatar, intro: item.description, + toolDescription: item.toolDescription, author: item.author, courseUrl: item.courseUrl, instructions: dbPluginConfig?.customConfig?.userGuide, diff --git a/packages/service/core/app/plugin/type.d.ts b/packages/service/core/app/plugin/type.d.ts index 31848103a..f9de55522 100644 --- a/packages/service/core/app/plugin/type.d.ts +++ b/packages/service/core/app/plugin/type.d.ts @@ -17,6 +17,7 @@ export type SystemPluginConfigSchemaType = { name: string; avatar: string; intro?: string; + toolDescription?: string; version: string; weight?: number; templateType: string; diff --git a/packages/service/core/workflow/dispatch/ai/agent/functionCall.ts b/packages/service/core/workflow/dispatch/ai/agent/functionCall.ts index 553296ae7..9ac2479e7 100644 --- a/packages/service/core/workflow/dispatch/ai/agent/functionCall.ts +++ b/packages/service/core/workflow/dispatch/ai/agent/functionCall.ts @@ -189,7 +189,7 @@ export const runToolWithFunctionCall = async ( return { name: item.nodeId, - description: item.intro, + description: item.toolDescription || item.intro, parameters: { type: 'object', properties, diff --git a/packages/service/core/workflow/dispatch/ai/agent/promptCall.ts b/packages/service/core/workflow/dispatch/ai/agent/promptCall.ts index 5b0066e51..e7ec8bcf8 100644 --- a/packages/service/core/workflow/dispatch/ai/agent/promptCall.ts +++ b/packages/service/core/workflow/dispatch/ai/agent/promptCall.ts @@ -193,7 +193,7 @@ export const runToolWithPromptCall = async ( return { toolId: item.nodeId, - description: item.intro, + description: item.toolDescription || item.intro, parameters: { type: 'object', properties, diff --git a/packages/service/core/workflow/dispatch/ai/agent/toolChoice.ts b/packages/service/core/workflow/dispatch/ai/agent/toolChoice.ts index 846de59e8..c36a4e2fe 100644 --- a/packages/service/core/workflow/dispatch/ai/agent/toolChoice.ts +++ b/packages/service/core/workflow/dispatch/ai/agent/toolChoice.ts @@ -246,7 +246,7 @@ export const runToolWithToolChoice = async ( type: 'function', function: { name: item.nodeId, - description: item.intro || item.name, + description: item.toolDescription || item.intro || item.name, parameters: { type: 'object', properties, diff --git a/packages/service/package.json b/packages/service/package.json index 47357d134..120edf9f4 100644 --- a/packages/service/package.json +++ b/packages/service/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "type": "module", "dependencies": { - "@fastgpt-sdk/plugin": "^0.1.8", + "@fastgpt-sdk/plugin": "^0.1.9", "@fastgpt/global": "workspace:*", "@modelcontextprotocol/sdk": "^1.12.1", "@node-rs/jieba": "2.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d77757a52..5e5bb6156 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -121,8 +121,8 @@ importers: packages/service: dependencies: '@fastgpt-sdk/plugin': - specifier: ^0.1.8 - version: 0.1.8(@types/node@20.17.24) + specifier: ^0.1.9 + version: 0.1.9(@types/node@20.17.24) '@fastgpt/global': specifier: workspace:* version: link:../global @@ -1973,8 +1973,8 @@ packages: resolution: {integrity: sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - '@fastgpt-sdk/plugin@0.1.8': - resolution: {integrity: sha512-Db4wWJV/NjWcsKXXOUeNRNYeVBmW9yn9IqjYr7Mj+Z77YwN0gUFIek4tv+zQzsr9IoQgq+vptCEf6Ae9d48uaA==} + '@fastgpt-sdk/plugin@0.1.9': + resolution: {integrity: sha512-9OBflL5W9SSEnhlNR/deL7+AMVkj7DKZcHlHELZFCMX+y0dhHmpHIh5bDon3zaeny40K35iI7md6pqDZ5xp5tw==} '@fastify/accept-negotiator@1.1.0': resolution: {integrity: sha512-OIHZrb2ImZ7XG85HXOONLcJWGosv7sIvM2ifAPQVhg9Lv7qdmMBNVaai4QTdyuaqbKM5eO6sLSQOYI7wEQeCJQ==} @@ -11208,7 +11208,7 @@ snapshots: '@eslint/js@8.57.1': {} - '@fastgpt-sdk/plugin@0.1.8(@types/node@20.17.24)': + '@fastgpt-sdk/plugin@0.1.9(@types/node@20.17.24)': dependencies: '@fortaine/fetch-event-source': 3.0.6 '@ts-rest/core': 3.52.1(@types/node@20.17.24)(zod@3.25.51) diff --git a/projects/app/src/pages/api/core/app/plugin/getSystemPluginTemplates.ts b/projects/app/src/pages/api/core/app/plugin/getSystemPluginTemplates.ts index 14997a003..ae894bc7d 100644 --- a/projects/app/src/pages/api/core/app/plugin/getSystemPluginTemplates.ts +++ b/projects/app/src/pages/api/core/app/plugin/getSystemPluginTemplates.ts @@ -36,7 +36,8 @@ async function handler( flowNodeType: plugin.isFolder ? FlowNodeTypeEnum.toolSet : FlowNodeTypeEnum.tool, name: parseI18nString(plugin.name, lang), intro: parseI18nString(plugin.intro ?? '', lang), - instructions: parseI18nString(plugin.userGuide ?? '', lang) + instructions: parseI18nString(plugin.userGuide ?? '', lang), + toolDescription: plugin.toolDescription })) .filter((item) => { if (searchKey) {