From 01108e617265da12bfa98ea22cbd21a670fdee30 Mon Sep 17 00:00:00 2001 From: Yeuoly <45712896+Yeuoly@users.noreply.github.com> Date: Mon, 18 Mar 2024 17:01:25 +0800 Subject: [PATCH] fix/Add isModel flag to AgentTools component (#2876) --- .../config/agent/agent-tools/index.tsx | 1 + .../agent/agent-tools/setting-built-in-tool.tsx | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/web/app/components/app/configuration/config/agent/agent-tools/index.tsx b/web/app/components/app/configuration/config/agent/agent-tools/index.tsx index 95858d9540..b92ff94983 100644 --- a/web/app/components/app/configuration/config/agent/agent-tools/index.tsx +++ b/web/app/components/app/configuration/config/agent/agent-tools/index.tsx @@ -210,6 +210,7 @@ const AgentTools: FC = () => { setting={currentTool?.tool_parameters as any} collection={currentTool?.collection as Collection} isBuiltIn={currentTool?.collection?.type === CollectionType.builtIn} + isModel={currentTool?.collection?.type === CollectionType.model} onSave={handleToolSettingChange} onHide={() => setIsShowSettingTool(false)} />) diff --git a/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx b/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx index 378054aae6..9eb2657fcf 100644 --- a/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx +++ b/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx @@ -58,11 +58,16 @@ const SettingBuiltInTool: FC = ({ (async () => { setIsLoading(true) try { - const list = isBuiltIn - ? await fetchBuiltInToolList(collection.name) - : isModel - ? await fetchModelToolList(collection.name) - : await fetchCustomToolList(collection.name) + const list = await new Promise((resolve) => { + (async function () { + if (isModel) + resolve(await fetchModelToolList(collection.name)) + else if (isBuiltIn) + resolve(await fetchBuiltInToolList(collection.name)) + else + resolve(await fetchCustomToolList(collection.name)) + }()) + }) setTools(list) const currTool = list.find(tool => tool.name === toolName) if (currTool) {