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 01aed3728b..4ec46a6d61 100644 --- a/web/app/components/workflow/nodes/_base/components/agent-strategy.tsx +++ b/web/app/components/workflow/nodes/_base/components/agent-strategy.tsx @@ -17,6 +17,8 @@ import { useDefaultModel } from '@/app/components/header/account-setting/model-p import Editor from './prompt/editor' import { useWorkflowStore } from '../../../store' import { useRenderI18nObject } from '@/hooks/use-i18n' +import type { NodeOutPutVar } from '../../../types' +import type { Node } from 'reactflow' export type Strategy = { agent_strategy_provider_name: string @@ -32,6 +34,8 @@ export type AgentStrategyProps = { formSchema: CredentialFormSchema[] formValue: ToolVarInputs onFormValueChange: (value: ToolVarInputs) => void + nodeOutputVars?: NodeOutPutVar[], + availableNodes?: Node[], } type CustomSchema = Omit & { type: Type } & Field @@ -50,7 +54,7 @@ type StringSchema = CustomSchema<'string', { type CustomField = ToolSelectorSchema | MultipleToolSelectorSchema | StringSchema export const AgentStrategy = memo((props: AgentStrategyProps) => { - const { strategy, onStrategyChange, formSchema, formValue, onFormValueChange } = props + const { strategy, onStrategyChange, formSchema, formValue, onFormValueChange, nodeOutputVars, availableNodes } = props const { t } = useTranslation() const defaultModel = useDefaultModel(ModelTypeEnum.textGeneration) const renderI18nObject = useRenderI18nObject() @@ -151,6 +155,8 @@ export const AgentStrategy = memo((props: AgentStrategyProps) => { isSupportPromptGenerator={!!schema.auto_generate?.type} titleTooltip={schema.tooltip && renderI18nObject(schema.tooltip)} editorContainerClassName='px-0' + availableNodes={availableNodes} + nodesOutputVars={nodeOutputVars} isSupportJinja={schema.template?.enabled} varList={[]} modelConfig={ diff --git a/web/app/components/workflow/nodes/agent/panel.tsx b/web/app/components/workflow/nodes/agent/panel.tsx index 1843031d42..ab8ff1c4b9 100644 --- a/web/app/components/workflow/nodes/agent/panel.tsx +++ b/web/app/components/workflow/nodes/agent/panel.tsx @@ -33,6 +33,9 @@ const AgentPanel: FC> = (props) => { formData, onFormChange, + availableNodesWithParent, + availableVars, + isShowSingleRun, hideSingleRun, runningStatus, @@ -90,6 +93,8 @@ const AgentPanel: FC> = (props) => { formSchema={currentStrategy?.parameters?.map(strategyParamToCredientialForm) || []} formValue={formData} onFormValueChange={onFormChange} + nodeOutputVars={availableVars} + availableNodes={availableNodesWithParent} />
diff --git a/web/app/components/workflow/nodes/agent/use-config.ts b/web/app/components/workflow/nodes/agent/use-config.ts index e880b90e1c..0714309d18 100644 --- a/web/app/components/workflow/nodes/agent/use-config.ts +++ b/web/app/components/workflow/nodes/agent/use-config.ts @@ -6,9 +6,12 @@ import type { AgentNodeType } from './types' import { useNodesReadOnly, } from '@/app/components/workflow/hooks' -import { useMemo } from 'react' +import { useCallback, useMemo } from 'react' import { type ToolVarInputs, VarType } from '../tool/types' import { useCheckInstalled } from '@/service/use-plugins' +import type { Var } from '../../types' +import { VarType as VarKindType } from '../../types' +import useAvailableVarList from '../_base/hooks/use-available-var-list' const useConfig = (id: string, payload: AgentNodeType) => { const { nodesReadOnly: readOnly } = useNodesReadOnly() @@ -56,6 +59,30 @@ const useConfig = (id: string, payload: AgentNodeType) => { }) } + // vars + + const filterMemoryPromptVar = useCallback((varPayload: Var) => { + return [ + VarKindType.arrayObject, + VarKindType.array, + VarKindType.number, + VarKindType.string, + VarKindType.secret, + VarKindType.arrayString, + VarKindType.arrayNumber, + VarKindType.file, + VarKindType.arrayFile, + ].includes(varPayload.type) + }, []) + + const { + availableVars, + availableNodesWithParent, + } = useAvailableVarList(id, { + onlyLeafNodeVar: false, + filterVar: filterMemoryPromptVar, + }) + // single run const { isShowSingleRun, @@ -97,6 +124,8 @@ const useConfig = (id: string, payload: AgentNodeType) => { currentStrategyStatus, strategyProvider: strategyProvider.data, pluginDetail: pluginDetail.data?.plugins.at(0), + availableVars, + availableNodesWithParent, isShowSingleRun, showSingleRun,