diff --git a/web/app/components/workflow/nodes/agent/node.tsx b/web/app/components/workflow/nodes/agent/node.tsx index 2a55566f58..c64baf3b19 100644 --- a/web/app/components/workflow/nodes/agent/node.tsx +++ b/web/app/components/workflow/nodes/agent/node.tsx @@ -9,6 +9,7 @@ import { ToolIcon } from './components/tool-icon' import useConfig from './use-config' import { useTranslation } from 'react-i18next' import { useInstalledPluginList } from '@/service/use-plugins' +import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations' const AgentNode: FC> = (props) => { const { inputs, currentStrategy } = useConfig(props.id, props.data) @@ -16,11 +17,28 @@ const AgentNode: FC> = (props) => { const pluginList = useInstalledPluginList() // TODO: Implement models const models = useMemo(() => { - const models = [] + if (!inputs) return [] + const models = currentStrategy?.parameters + .filter(param => param.type === FormTypeEnum.modelSelector) + .flatMap((param) => { + const item = inputs.agent_parameters?.[param.name] + if (!item) { + if (param.required) + return null + else + return [] + } + return { + provider: item.provider, + model: item.model, + param: param.name, + } + }) || [] + return models // if selected, show in node // if required and not selected, show empty selector // if not required and not selected, show nothing - }, [currentStrategy, inputs.agent_parameters]) + }, [currentStrategy, inputs]) const tools = useMemo(() => { const tools: Array = [] @@ -49,24 +67,20 @@ const AgentNode: FC> = (props) => { {inputs.agent_strategy_label} : } - {t('workflow.nodes.agent.model')} } > - - - - + {models.map((model) => { + return + })} + } {t('workflow.nodes.agent.toolbox')} }> diff --git a/web/app/components/workflow/nodes/agent/types.ts b/web/app/components/workflow/nodes/agent/types.ts index 20da43f66a..c3351c1d9d 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?: ToolVarInputs, + agent_parameters?: Record agent_configurations?: Record output_schema: Record }