From 605085bddfed5ea154d4cd8cab6c4d30cf043e29 Mon Sep 17 00:00:00 2001 From: AkaraChen Date: Thu, 26 Dec 2024 16:42:34 +0800 Subject: [PATCH 1/5] chore: remove max_iterations for agent node --- web/app/components/workflow/nodes/agent/default.ts | 1 - web/app/components/workflow/nodes/agent/panel.tsx | 6 ------ web/app/components/workflow/nodes/agent/types.ts | 1 - 3 files changed, 8 deletions(-) diff --git a/web/app/components/workflow/nodes/agent/default.ts b/web/app/components/workflow/nodes/agent/default.ts index f5300cbe77..979df87f49 100644 --- a/web/app/components/workflow/nodes/agent/default.ts +++ b/web/app/components/workflow/nodes/agent/default.ts @@ -4,7 +4,6 @@ import type { AgentNodeType } from './types' const nodeDefault: NodeDefault = { defaultValue: { - max_iterations: 3, }, getAvailablePrevNodes(isChatMode) { return isChatMode diff --git a/web/app/components/workflow/nodes/agent/panel.tsx b/web/app/components/workflow/nodes/agent/panel.tsx index 4dee90370d..4b177df8c5 100644 --- a/web/app/components/workflow/nodes/agent/panel.tsx +++ b/web/app/components/workflow/nodes/agent/panel.tsx @@ -9,12 +9,6 @@ import { useTranslation } from 'react-i18next' const AgentPanel: FC> = (props) => { const { inputs, setInputs, currentStrategy } = useConfig(props.id, props.data) const { t } = useTranslation() - const [iter, setIter] = [inputs.max_iterations, (value: number) => { - setInputs({ - ...inputs, - max_iterations: value, - }) - }] return
Date: Thu, 26 Dec 2024 14:28:31 +0800 Subject: [PATCH 2/5] tool selector support scope --- .../model-provider-page/model-modal/Form.tsx | 6 ++- .../plugins/plugin-detail-panel/index.tsx | 11 ++++++ .../tool-selector/index.tsx | 7 +++- .../workflow/block-selector/tool-picker.tsx | 39 +++++++++++++++++-- 4 files changed, 57 insertions(+), 6 deletions(-) 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 fdb7aece0f..5bd79a5cef 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 @@ -275,7 +275,10 @@ function Form< if (formSchema.type === FormTypeEnum.toolSelector) { const { - variable, label, required, + variable, + label, + required, + scope, } = formSchema as (CredentialFormSchemaTextInput | CredentialFormSchemaSecretInput) return ( @@ -288,6 +291,7 @@ function Form< {tooltipContent}
handleFormChange(variable, item as any)} /> diff --git a/web/app/components/plugins/plugin-detail-panel/index.tsx b/web/app/components/plugins/plugin-detail-panel/index.tsx index 4d20c0877d..c977eeeef2 100644 --- a/web/app/components/plugins/plugin-detail-panel/index.tsx +++ b/web/app/components/plugins/plugin-detail-panel/index.tsx @@ -7,6 +7,7 @@ import ActionList from './action-list' import ModelList from './model-list' import AgentStrategyList from './agent-strategy-list' import Drawer from '@/app/components/base/drawer' +import ToolSelector from '@/app/components/plugins/plugin-detail-panel/tool-selector' import type { PluginDetail } from '@/app/components/plugins/types' import cn from '@/utils/classnames' @@ -27,6 +28,10 @@ const PluginDetailPanel: FC = ({ onUpdate() } + const testChange = (val: any) => { + console.log('tool change', val) + } + if (!detail) return null @@ -52,6 +57,12 @@ 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 eab0dd94d2..4b95e13727 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 @@ -43,13 +43,15 @@ type Props = { tool_name: string }) => void supportAddCustomTool?: boolean + scope?: string } const ToolSelector: FC = ({ value, disabled, - placement = 'bottom', + placement = 'left', offset = 4, onSelect, + scope, }) => { const { t } = useTranslation() const [isShow, onShowChange] = useState(false) @@ -73,6 +75,8 @@ const ToolSelector: FC = ({ const toolValue = { provider: tool.provider_id, tool_name: tool.tool_name, + description: '', + parameters: {}, } onSelect(toolValue) setIsShowChooseTool(false) @@ -132,6 +136,7 @@ const ToolSelector: FC = ({ disabled={false} supportAddCustomTool onSelect={handleSelectTool} + scope={scope} /> {/* authorization panel */} diff --git a/web/app/components/workflow/block-selector/tool-picker.tsx b/web/app/components/workflow/block-selector/tool-picker.tsx index 60de09d3e6..8cab803be0 100644 --- a/web/app/components/workflow/block-selector/tool-picker.tsx +++ b/web/app/components/workflow/block-selector/tool-picker.tsx @@ -1,7 +1,7 @@ 'use client' import type { FC } from 'react' import React from 'react' -import { useState } from 'react' +import { useMemo, useState } from 'react' import { PortalToFollowElem, PortalToFollowElemContent, @@ -34,6 +34,7 @@ type Props = { onShowChange: (isShow: boolean) => void onSelect: (tool: ToolDefaultValue) => void supportAddCustomTool?: boolean + scope?: string } const ToolPicker: FC = ({ @@ -45,6 +46,7 @@ const ToolPicker: FC = ({ onShowChange, onSelect, supportAddCustomTool, + scope = 'all', }) => { const { t } = useTranslation() const [searchText, setSearchText] = useState('') @@ -55,6 +57,35 @@ const ToolPicker: FC = ({ const invalidateCustomTools = useInvalidateAllCustomTools() const { data: workflowTools } = useAllWorkflowTools() + const { builtinToolList, customToolList, workflowToolList } = useMemo(() => { + if (scope === 'plugins') { + return { + builtinToolList: buildInTools, + customToolList: [], + workflowToolList: [], + } + } + if (scope === 'custom') { + return { + builtinToolList: [], + customToolList: customTools, + workflowToolList: [], + } + } + if (scope === 'workflow') { + return { + builtinToolList: [], + customToolList: [], + workflowToolList: workflowTools, + } + } + return { + builtinToolList: buildInTools, + customToolList: customTools, + workflowToolList: workflowTools, + } + }, [scope, buildInTools, customTools, workflowTools]) + const handleAddedCustomTool = invalidateCustomTools const handleTriggerClick = () => { @@ -122,9 +153,9 @@ const ToolPicker: FC = ({ tags={tags} searchText={searchText} onSelect={handleSelect} - buildInTools={buildInTools || []} - customTools={customTools || []} - workflowTools={workflowTools || []} + buildInTools={builtinToolList || []} + customTools={customToolList || []} + workflowTools={workflowToolList || []} supportAddCustomTool={supportAddCustomTool} onAddedCustomTool={handleAddedCustomTool} onShowAddCustomCollectionModal={showEditCustomCollectionModal} From 469ce0f23dfb8f1f9cc90e6a96a4a74287685c0e Mon Sep 17 00:00:00 2001 From: JzoNg Date: Thu, 26 Dec 2024 15:29:00 +0800 Subject: [PATCH 3/5] 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')}
+