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 d83fcb3637..35cee8eefc 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 @@ -92,7 +92,7 @@ const AgentTools: FC = () => { tool_name: tool.tool_name, tool_label: tool.tool_label, tool_parameters: tool.params, - notAuthor: !(tool as ToolDefaultValue & { is_team_authorization: boolean }).is_team_authorization, + notAuthor: !tool.is_team_authorization, enabled: true, }) }) diff --git a/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx b/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx index b1788b89bc..e6ce15d696 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx @@ -114,7 +114,7 @@ const Form: FC = ({ const disabled = readonly || (isEditMode && (variable === '__model_type' || variable === '__model_name')) return (
-
+
{label[language] || label.en_US} { required && ( @@ -155,7 +155,7 @@ const Form: FC = ({ return (
-
+
{label[language] || label.en_US} { required && ( @@ -211,7 +211,7 @@ const Form: FC = ({ return (
-
+
{label[language] || label.en_US} { @@ -254,7 +254,7 @@ const Form: FC = ({ return (
-
+
{label[language] || label.en_US} { @@ -287,7 +287,7 @@ const Form: FC = ({ return (
-
+
{label[language] || label.en_US} { required && ( diff --git a/web/app/components/plugins/plugin-detail-panel/endpoint-modal.tsx b/web/app/components/plugins/plugin-detail-panel/endpoint-modal.tsx index 63b580429f..342b66e948 100644 --- a/web/app/components/plugins/plugin-detail-panel/endpoint-modal.tsx +++ b/web/app/components/plugins/plugin-detail-panel/endpoint-modal.tsx @@ -40,7 +40,10 @@ const EndpointModal: FC = ({ onSaved(tempCredential) } - const [mockTool, setTool] = useState() + const [mockTool, setTool] = useState({ + provider: 'langgenius/google/google', + tool_name: 'google_search', + }) return ( = ({ value, disabled, placement = 'bottom', - offset = 0, + offset = 4, onSelect, }) => { const { t } = useTranslation() @@ -45,6 +50,7 @@ const ToolSelector: FC = ({ if (disabled) return onShowChange(true) } + const { data: buildInTools } = useAllBuiltInTools() const { data: customTools } = useAllCustomTools() const { data: workflowTools } = useAllWorkflowTools() @@ -55,24 +61,29 @@ const ToolSelector: FC = ({ }) }, [value, buildInTools, customTools, workflowTools]) const [isShowChooseTool, setIsShowChooseTool] = useState(false) - const [isShowSettingAuth, setShowSettingAuth] = useState(false) - - const handleToolAuthSetting = (value: any) => { - // const newModelConfig = produce(modelConfig, (draft) => { - // const tool = (draft.agentConfig.tools).find((item: any) => item.provider_id === value?.collection?.id && item.tool_name === value?.tool_name) - // if (tool) - // (tool as AgentTool).notAuthor = false - // }) - // setModelConfig(newModelConfig) - } - const handleSelectTool = (tool: ToolDefaultValue) => { const toolValue = { provider: tool.provider_id, tool_name: tool.tool_name, } onSelect(toolValue) + setIsShowChooseTool(false) + if (tool.provider_type === CollectionType.builtIn && tool.is_team_authorization) + onShowChange(false) } + const { isCurrentWorkspaceManager } = useAppContext() + const [authLoading, setAuthLoading] = useState(false) + + // const [isShowSettingAuth, setShowSettingAuth] = useState(false) + + // const handleToolAuthSetting = (value: any) => { + // const newModelConfig = produce(modelConfig, (draft) => { + // const tool = (draft.agentConfig.tools).find((item: any) => item.provider_id === value?.collection?.id && item.tool_name === value?.tool_name) + // if (tool) + // (tool as AgentTool).notAuthor = false + // }) + // setModelConfig(newModelConfig) + // } return ( <> @@ -86,15 +97,26 @@ const ToolSelector: FC = ({ className='w-full' onClick={handleTriggerClick} > - +
-
Tool
+
{t('tools.toolSelector.label')}
} + offset={offset} + trigger={ + + } isShow={isShowChooseTool} onShowChange={setIsShowChooseTool} disabled={false} @@ -102,6 +124,37 @@ const ToolSelector: FC = ({ onSelect={handleSelectTool} />
+ {/* authorization panel */} + {authLoading && ( +
+ )} + {!authLoading && currentProvider && currentProvider.type === CollectionType.builtIn && currentProvider.is_team_authorization && currentProvider.allow_delete && ( +
+
{t('tools.toolSelector.auth')}
+ {isCurrentWorkspaceManager && ( + + )} +
+ )} + {!authLoading && currentProvider && currentProvider.type === CollectionType.builtIn && !currentProvider.is_team_authorization && currentProvider.allow_delete && ( +
+ +
+ )}
diff --git a/web/app/components/tools/tool-selector/tool-trigger.tsx b/web/app/components/tools/tool-selector/tool-trigger.tsx index 79efa4a06a..e481448bcd 100644 --- a/web/app/components/tools/tool-selector/tool-trigger.tsx +++ b/web/app/components/tools/tool-selector/tool-trigger.tsx @@ -1,5 +1,6 @@ 'use client' import React from 'react' +import { useTranslation } from 'react-i18next' import { RiArrowDownSLine, } from '@remixicon/react' @@ -22,20 +23,27 @@ const ToolTrigger = ({ provider, value, }: Props) => { + const { t } = useTranslation() return ( -
+
{value && provider && ( - +
+ +
)} {value && ( -
{value.tool_name}
+
{value.tool_name}
)} {!value && ( -
Select a tool ...
+
{t('tools.toolSelector.placeholder')}
)}
diff --git a/web/app/components/workflow/block-selector/tool-picker.tsx b/web/app/components/workflow/block-selector/tool-picker.tsx index 1990c6daca..60de09d3e6 100644 --- a/web/app/components/workflow/block-selector/tool-picker.tsx +++ b/web/app/components/workflow/block-selector/tool-picker.tsx @@ -106,7 +106,7 @@ const ToolPicker: FC = ({ -
+
void + onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void } const ToolItem: FC = ({ diff --git a/web/app/components/workflow/block-selector/types.ts b/web/app/components/workflow/block-selector/types.ts index 9bdbf5cb3c..ffe6cc627c 100644 --- a/web/app/components/workflow/block-selector/types.ts +++ b/web/app/components/workflow/block-selector/types.ts @@ -25,5 +25,6 @@ export type ToolDefaultValue = { tool_name: string tool_label: string title: string + is_team_authorization: boolean params: Record } diff --git a/web/i18n/en-US/tools.ts b/web/i18n/en-US/tools.ts index 9c2d22b711..37250473d6 100644 --- a/web/i18n/en-US/tools.ts +++ b/web/i18n/en-US/tools.ts @@ -149,6 +149,11 @@ const translation = { openInStudio: 'Open in Studio', toolNameUsageTip: 'Tool call name for agent reasoning and prompting', copyToolName: 'Copy Name', + toolSelector: { + label: 'TOOL', + placeholder: 'Select a tool...', + auth: 'AUTHORIZATION', + }, } export default translation diff --git a/web/i18n/zh-Hans/tools.ts b/web/i18n/zh-Hans/tools.ts index fa1e8344a7..f3ec76aa97 100644 --- a/web/i18n/zh-Hans/tools.ts +++ b/web/i18n/zh-Hans/tools.ts @@ -149,6 +149,10 @@ const translation = { openInStudio: '在工作室中打开', toolNameUsageTip: '工具调用名称,用于 Agent 推理和提示词', copyToolName: '复制名称', + toolSelector: { + label: '工具', + placeholder: '选择一个工具...', + }, } export default translation