From 2ac6f00efb70c1f7bd8d5faa5ffaddb2a1e5e3a1 Mon Sep 17 00:00:00 2001 From: AkaraChen Date: Mon, 30 Dec 2024 13:30:57 +0800 Subject: [PATCH] fix: agent node toolbox --- .../_base/components/agent-strategy-selector.tsx | 4 ++-- .../nodes/_base/components/agent-strategy.tsx | 3 ++- web/app/components/workflow/nodes/agent/node.tsx | 13 ++++++------- web/app/components/workflow/nodes/agent/panel.tsx | 8 +++++--- web/app/components/workflow/nodes/agent/types.ts | 4 ++-- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/web/app/components/workflow/nodes/_base/components/agent-strategy-selector.tsx b/web/app/components/workflow/nodes/_base/components/agent-strategy-selector.tsx index 4b38111b1d..638f5b7259 100644 --- a/web/app/components/workflow/nodes/_base/components/agent-strategy-selector.tsx +++ b/web/app/components/workflow/nodes/_base/components/agent-strategy-selector.tsx @@ -83,7 +83,6 @@ export const AgentStrategySelector = (props: AgentStrategySelectorProps) => { }, [query, list]) // TODO: should be replaced by real data const isExternalInstalled = true - // TODO: 验证这玩意写对了没 const icon = list?.find( coll => coll.tools?.find(tool => tool.name === value?.agent_strategy_name), )?.icon as string | undefined @@ -125,9 +124,10 @@ export const AgentStrategySelector = (props: AgentStrategySelectorProps) => { onChange({ agent_strategy_name: tool!.tool_name, agent_strategy_provider_name: tool!.provider_name, - agent_parameters: tool!.params, agent_strategy_label: tool!.tool_label, agent_output_schema: tool!.output_schema, + agent_configurations: {}, + agent_parameters: {}, }) setOpen(false) }} 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 ce0613dedf..8f10d91f9e 100644 --- a/web/app/components/workflow/nodes/_base/components/agent-strategy.tsx +++ b/web/app/components/workflow/nodes/_base/components/agent-strategy.tsx @@ -19,7 +19,8 @@ export type Strategy = { agent_strategy_provider_name: string agent_strategy_name: string agent_strategy_label: string - agent_parameters?: ToolVarInputs + agent_configurations?: Record + agent_parameters?: Record agent_output_schema: Record } diff --git a/web/app/components/workflow/nodes/agent/node.tsx b/web/app/components/workflow/nodes/agent/node.tsx index 73ea2e87f9..e007e758d3 100644 --- a/web/app/components/workflow/nodes/agent/node.tsx +++ b/web/app/components/workflow/nodes/agent/node.tsx @@ -13,7 +13,6 @@ import { FormTypeEnum } from '@/app/components/header/account-setting/model-prov const AgentNode: FC> = (props) => { const { inputs, currentStrategy } = useConfig(props.id, props.data) const { t } = useTranslation() - // TODO: Implement models const models = useMemo(() => { if (!inputs) return [] // if selected, show in node @@ -22,7 +21,7 @@ const AgentNode: FC> = (props) => { const models = currentStrategy?.parameters .filter(param => param.type === FormTypeEnum.modelSelector) .reduce((acc, param) => { - const item = inputs.agent_parameters?.[param.name] + const item = inputs.agent_configurations?.[param.name] if (!item) { if (param.required) { acc.push({ param: param.name }) @@ -41,18 +40,18 @@ const AgentNode: FC> = (props) => { currentStrategy?.parameters.forEach((param) => { if (param.type === FormTypeEnum.toolSelector) { const field = param.name - const value = inputs.agent_parameters?.[field] + const value = inputs.agent_configurations?.[field] if (value) { tools.push({ - providerName: value.provider_name, + providerName: value.provider_name as any, }) } } if (param.type === FormTypeEnum.multiToolSelector) { const field = param.name - const value = inputs.agent_parameters?.[field] + const value = inputs.agent_configurations?.[field] if (value) { - (value as any[]).forEach((item) => { + (value as unknown as any[]).forEach((item) => { tools.push({ providerName: item.provider_name, }) @@ -61,7 +60,7 @@ const AgentNode: FC> = (props) => { } }) return tools - }, [currentStrategy, inputs.agent_parameters]) + }, [currentStrategy?.parameters, inputs.agent_configurations]) return
{inputs.agent_strategy_name ? > = (props) => { strategy={inputs.agent_strategy_name ? { agent_strategy_provider_name: inputs.agent_strategy_provider_name!, agent_strategy_name: inputs.agent_strategy_name!, - agent_parameters: inputs.agent_parameters, + agent_configurations: inputs.agent_configurations, agent_strategy_label: inputs.agent_strategy_label!, agent_output_schema: inputs.output_schema, + agent_parameters: inputs.agent_parameters, } : undefined} onStrategyChange={(strategy) => { setInputs({ ...inputs, agent_strategy_provider_name: strategy?.agent_strategy_provider_name, agent_strategy_name: strategy?.agent_strategy_name, + agent_configurations: strategy?.agent_configurations, agent_parameters: strategy?.agent_parameters, agent_strategy_label: strategy?.agent_strategy_label, output_schema: strategy!.agent_output_schema, }) }} formSchema={currentStrategy?.parameters?.map(strategyParamToCredientialForm) || []} - formValue={inputs.agent_parameters || {}} + formValue={inputs.agent_configurations || {}} onFormValueChange={value => setInputs({ ...inputs, - agent_parameters: value, + agent_configurations: value, })} /> diff --git a/web/app/components/workflow/nodes/agent/types.ts b/web/app/components/workflow/nodes/agent/types.ts index c3351c1d9d..66e576cb9c 100644 --- a/web/app/components/workflow/nodes/agent/types.ts +++ b/web/app/components/workflow/nodes/agent/types.ts @@ -5,7 +5,7 @@ export type AgentNodeType = CommonNodeType & { agent_strategy_provider_name?: string agent_strategy_name?: string agent_strategy_label?: string - agent_parameters?: Record - agent_configurations?: Record + agent_parameters?: Record + agent_configurations?: Record output_schema: Record }