From 10218cfe8de5bced502df32c6a69b9881f788f7d Mon Sep 17 00:00:00 2001 From: JzoNg Date: Thu, 26 Dec 2024 17:33:06 +0800 Subject: [PATCH] add tool selector in agent node --- .../nodes/_base/components/agent-strategy.tsx | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/web/app/components/workflow/nodes/_base/components/agent-strategy.tsx b/web/app/components/workflow/nodes/_base/components/agent-strategy.tsx index 9523ee32b5..eaa63f3354 100644 --- a/web/app/components/workflow/nodes/_base/components/agent-strategy.tsx +++ b/web/app/components/workflow/nodes/_base/components/agent-strategy.tsx @@ -8,6 +8,7 @@ import Form from '@/app/components/header/account-setting/model-provider-page/mo import { Agent } from '@/app/components/base/icons/src/vender/workflow' import { InputNumber } from '@/app/components/base/input-number' import Slider from '@/app/components/base/slider' +import ToolSelector from '@/app/components/plugins/plugin-detail-panel/tool-selector' import Field from './field' import type { ComponentProps } from 'react' @@ -29,9 +30,10 @@ export type AgentStrategyProps = { type CustomSchema = Omit & { type: Type } & Field type MaxIterFormSchema = CustomSchema<'max-iter'> -type ToolSelectorSchema = CustomSchema<'array[tools]'> +type ToolSelectorSchema = CustomSchema<'tool-selector'> +type MultipleToolSelectorSchema = CustomSchema<'array[tools]'> -type CustomField = MaxIterFormSchema | ToolSelectorSchema +type CustomField = MaxIterFormSchema | ToolSelectorSchema | MultipleToolSelectorSchema export const AgentStrategy = (props: AgentStrategyProps) => { const { strategy, onStrategyChange, formSchema, formValue, onFormValueChange } = props @@ -61,9 +63,23 @@ export const AgentStrategy = (props: AgentStrategyProps) => { } + case 'tool-selector': { + const value = props.value[schema.variable] + const onChange = (value: any) => { + props.onChange({ ...props.value, [schema.variable]: value }) + } + return ( + + onChange(item)} + /> + + ) + } case 'array[tools]': { return - tool selector + multiple tool selector TODO } }