From 469ce0f23dfb8f1f9cc90e6a96a4a74287685c0e Mon Sep 17 00:00:00 2001 From: JzoNg Date: Thu, 26 Dec 2024 15:29:00 +0800 Subject: [PATCH] add tool description --- .../plugins/plugin-detail-panel/index.tsx | 6 +- .../tool-selector/index.tsx | 73 +++++++++++++------ .../tool-selector/tool-trigger.tsx | 22 ++++-- web/i18n/en-US/plugin.ts | 12 +++ web/i18n/en-US/tools.ts | 5 -- web/i18n/zh-Hans/plugin.ts | 12 +++ web/i18n/zh-Hans/tools.ts | 4 - 7 files changed, 94 insertions(+), 40 deletions(-) diff --git a/web/app/components/plugins/plugin-detail-panel/index.tsx b/web/app/components/plugins/plugin-detail-panel/index.tsx index c977eeeef2..3378d75b5b 100644 --- a/web/app/components/plugins/plugin-detail-panel/index.tsx +++ b/web/app/components/plugins/plugin-detail-panel/index.tsx @@ -28,8 +28,10 @@ const PluginDetailPanel: FC = ({ onUpdate() } + const [value, setValue] = React.useState(undefined) const testChange = (val: any) => { console.log('tool change', val) + setValue(val) } if (!detail) @@ -57,9 +59,9 @@ const PluginDetailPanel: FC = ({ {!!detail.declaration.agent_strategy && } {!!detail.declaration.endpoint && } {!!detail.declaration.model && } -
+
testChange(item)} />
diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/index.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/index.tsx index 4b95e13727..54e3fdba59 100644 --- a/web/app/components/plugins/plugin-detail-panel/tool-selector/index.tsx +++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/index.tsx @@ -13,6 +13,7 @@ import Button from '@/app/components/base/button' import Indicator from '@/app/components/header/indicator' import ToolCredentialForm from '@/app/components/plugins/plugin-detail-panel/tool-selector/tool-credentials-form' import Toast from '@/app/components/base/toast' +import Textarea from '@/app/components/base/textarea' import { useAppContext } from '@/context/app-context' import { @@ -34,6 +35,8 @@ type Props = { value?: { provider: string tool_name: string + description?: string + parameters?: Record } disabled?: boolean placement?: Placement @@ -41,6 +44,8 @@ type Props = { onSelect: (tool: { provider: string tool_name: string + description?: string + parameters?: Record }) => void supportAddCustomTool?: boolean scope?: string @@ -80,9 +85,18 @@ const ToolSelector: FC = ({ } onSelect(toolValue) setIsShowChooseTool(false) - if (tool.provider_type === CollectionType.builtIn && tool.is_team_authorization) - onShowChange(false) + // if (tool.provider_type === CollectionType.builtIn && tool.is_team_authorization) + // onShowChange(false) } + + const handleDescriptionChange = (e: React.ChangeEvent) => { + onSelect({ + ...value, + description: e.target.value || '', + } as any) + } + + // authorization const { isCurrentWorkspaceManager } = useAppContext() const [isShowSettingAuth, setShowSettingAuth] = useState(false) const handleCredentialSettingUpdate = () => { @@ -112,32 +126,45 @@ const ToolSelector: FC = ({ onClick={handleTriggerClick} > -
-
-
{t('tools.toolSelector.label')}
- - } - isShow={isShowChooseTool} - onShowChange={setIsShowChooseTool} - disabled={false} - supportAddCustomTool - onSelect={handleSelectTool} - scope={scope} - /> +
+
{t('plugin.detailPanel.toolSelector.title')}
+
+
+
{t('plugin.detailPanel.toolSelector.toolLabel')}
+ + } + isShow={isShowChooseTool} + onShowChange={setIsShowChooseTool} + disabled={false} + supportAddCustomTool + onSelect={handleSelectTool} + scope={scope} + /> +
+
+
{t('plugin.detailPanel.toolSelector.descriptionLabel')}
+