From 95da3a4cf196ad98592381812ba3f74cd3c8efd8 Mon Sep 17 00:00:00 2001 From: JzoNg Date: Thu, 26 Dec 2024 18:58:01 +0800 Subject: [PATCH] tool credential panel --- .../plugins/plugin-detail-panel/index.tsx | 14 +- .../tool-selector/index.tsx | 220 ++++++++++-------- .../tool-selector/tool-credentials-form.tsx | 50 ++-- .../tool-selector/tool-trigger.tsx | 8 +- 4 files changed, 156 insertions(+), 136 deletions(-) diff --git a/web/app/components/plugins/plugin-detail-panel/index.tsx b/web/app/components/plugins/plugin-detail-panel/index.tsx index 3e746741cc..3378d75b5b 100644 --- a/web/app/components/plugins/plugin-detail-panel/index.tsx +++ b/web/app/components/plugins/plugin-detail-panel/index.tsx @@ -59,14 +59,12 @@ const PluginDetailPanel: FC = ({ {!!detail.declaration.agent_strategy && } {!!detail.declaration.endpoint && } {!!detail.declaration.model && } - {false && ( -
- testChange(item)} - /> -
- )} +
+ 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 a1d7573c8b..732c94103f 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 @@ -3,6 +3,7 @@ import type { FC } from 'react' import React, { useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' import { + RiArrowLeftLine, RiArrowRightUpLine, } from '@remixicon/react' import { @@ -39,7 +40,7 @@ import cn from '@/utils/classnames' type Props = { value?: { - provider: string + provider_name: string tool_name: string parameters?: Record extra?: Record @@ -48,7 +49,7 @@ type Props = { placement?: Placement offset?: OffsetOptions onSelect: (tool: { - provider: string + provider_name: string tool_name: string parameters?: Record extra?: Record @@ -79,7 +80,7 @@ const ToolSelector: FC = ({ const currentProvider = useMemo(() => { const mergedTools = [...(buildInTools || []), ...(customTools || []), ...(workflowTools || [])] return mergedTools.find((toolWithProvider) => { - return toolWithProvider.id === value?.provider && toolWithProvider.tools.some(tool => tool.name === value?.tool_name) + return toolWithProvider.id === value?.provider_name && toolWithProvider.tools.some(tool => tool.name === value?.tool_name) }) }, [value, buildInTools, customTools, workflowTools]) @@ -87,10 +88,12 @@ const ToolSelector: FC = ({ const handleSelectTool = (tool: ToolDefaultValue) => { const paramValues = addDefaultValue(tool.params, toolParametersToFormSchemas(tool.paramSchemas as any)) const toolValue = { - provider: tool.provider_id, + provider_name: tool.provider_id, tool_name: tool.tool_name, - description: '', parameters: paramValues, + extra: { + description: '', + }, } onSelect(toolValue) setIsShowChooseTool(false) @@ -160,75 +163,122 @@ const ToolSelector: FC = ({ /> -
-
{t('plugin.detailPanel.toolSelector.title')}
- {/* base form */} -
-
-
{t('plugin.detailPanel.toolSelector.toolLabel')}
- + {!isShowSettingAuth && ( + <> +
{t('plugin.detailPanel.toolSelector.title')}
+ {/* base form */} +
+
+
{t('plugin.detailPanel.toolSelector.toolLabel')}
+ + } + isShow={isShowChooseTool} + onShowChange={setIsShowChooseTool} + disabled={false} + supportAddCustomTool + onSelect={handleSelectTool} + scope={scope} /> - } - isShow={isShowChooseTool} - onShowChange={setIsShowChooseTool} - disabled={false} - supportAddCustomTool - onSelect={handleSelectTool} - scope={scope} - /> -
-
-
{t('plugin.detailPanel.toolSelector.descriptionLabel')}
-