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 98564e6b16..4b38111b1d 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 @@ -127,6 +127,7 @@ export const AgentStrategySelector = (props: AgentStrategySelectorProps) => { agent_strategy_provider_name: tool!.provider_name, agent_parameters: tool!.params, agent_strategy_label: tool!.tool_label, + agent_output_schema: tool!.output_schema, }) 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 c8aa80431b..c14f9a54c6 100644 --- a/web/app/components/workflow/nodes/_base/components/agent-strategy.tsx +++ b/web/app/components/workflow/nodes/_base/components/agent-strategy.tsx @@ -19,6 +19,7 @@ export type Strategy = { agent_strategy_name: string agent_strategy_label: string agent_parameters?: ToolVarInputs + agent_output_schema: Record } export type AgentStrategyProps = { @@ -37,44 +38,6 @@ type MultipleToolSelectorSchema = CustomSchema<'array[tools]'> type CustomField = ToolSelectorSchema | MultipleToolSelectorSchema const devMockForm = [{ - name: 'model', - label: { - en_US: 'Model', - zh_Hans: '模型', - pt_BR: 'Model', - ja_JP: 'Model', - }, - placeholder: null, - scope: 'tool-call&llm', - auto_generate: null, - template: null, - required: true, - default: null, - min: null, - max: null, - options: [], - type: 'model-selector', -}, -{ - name: 'tools', - label: { - en_US: 'Tools list', - zh_Hans: '工具列表', - pt_BR: 'Tools list', - ja_JP: 'Tools list', - }, - placeholder: null, - scope: null, - auto_generate: null, - template: null, - required: true, - default: null, - min: null, - max: null, - options: [], - type: 'array[tools]', -}, -{ name: 'instruction', label: { en_US: 'Instruction', diff --git a/web/app/components/workflow/nodes/_base/components/collapse/field-collapse.tsx b/web/app/components/workflow/nodes/_base/components/collapse/field-collapse.tsx index 7d2698a6d0..71ca0d28ea 100644 --- a/web/app/components/workflow/nodes/_base/components/collapse/field-collapse.tsx +++ b/web/app/components/workflow/nodes/_base/components/collapse/field-collapse.tsx @@ -1,8 +1,9 @@ +import type { ReactNode } from 'react' import Collapse from '.' type FieldCollapseProps = { title: string - children: JSX.Element + children: ReactNode } const FieldCollapse = ({ title, diff --git a/web/app/components/workflow/nodes/_base/components/output-vars.tsx b/web/app/components/workflow/nodes/_base/components/output-vars.tsx index a0d7a25c07..4a265a5a5b 100644 --- a/web/app/components/workflow/nodes/_base/components/output-vars.tsx +++ b/web/app/components/workflow/nodes/_base/components/output-vars.tsx @@ -1,5 +1,5 @@ 'use client' -import type { FC } from 'react' +import type { FC, ReactNode } from 'react' import React from 'react' import { useTranslation } from 'react-i18next' import { FieldCollapse } from '@/app/components/workflow/nodes/_base/components/collapse' @@ -7,7 +7,7 @@ import { FieldCollapse } from '@/app/components/workflow/nodes/_base/components/ type Props = { className?: string title?: string - children: JSX.Element + children: ReactNode } const OutputVars: FC = ({ diff --git a/web/app/components/workflow/nodes/_base/components/variable/utils.ts b/web/app/components/workflow/nodes/_base/components/variable/utils.ts index 7685c3e587..787ed890d9 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/utils.ts +++ b/web/app/components/workflow/nodes/_base/components/variable/utils.ts @@ -318,17 +318,23 @@ const formatItem = ( case BlockEnum.Agent: { const payload = data as AgentNodeType - if (!payload.agent_parameters) { - res.vars = [] - break - } - res.vars = Object.keys(payload.agent_parameters).map((key) => { - return { - variable: key, - // TODO: is this correct? - type: payload.agent_parameters![key].type as unknown as VarType, - } + const outputs: Var[] = [] + Object.keys(payload.output_schema.properties).forEach((outputKey) => { + const output = payload.output_schema.properties[outputKey] + outputs.push({ + variable: outputKey, + type: output.type === 'array' + ? `Array[${output.items?.type.slice(0, 1).toLocaleUpperCase()}${output.items?.type.slice(1)}]` as VarType + : `${output.type.slice(0, 1).toLocaleUpperCase()}${output.type.slice(1)}` as VarType, + // TODO: is this required? + // @ts-expect-error todo added + description: output.description, + }) }) + res.vars = [ + ...outputs, + ...TOOL_OUTPUT_STRUCT, + ] break } diff --git a/web/app/components/workflow/nodes/agent/panel.tsx b/web/app/components/workflow/nodes/agent/panel.tsx index 4b177df8c5..b9bafa78b0 100644 --- a/web/app/components/workflow/nodes/agent/panel.tsx +++ b/web/app/components/workflow/nodes/agent/panel.tsx @@ -5,11 +5,14 @@ import Field from '../_base/components/field' import { AgentStrategy } from '../_base/components/agent-strategy' import useConfig from './use-config' import { useTranslation } from 'react-i18next' +import OutputVars, { VarItem } from '../_base/components/output-vars' + +const i18nPrefix = 'workflow.nodes.agent' const AgentPanel: FC> = (props) => { const { inputs, setInputs, currentStrategy } = useConfig(props.id, props.data) const { t } = useTranslation() - return
+ return
> = (props) => { agent_strategy_name: inputs.agent_strategy_name!, agent_parameters: inputs.agent_parameters, agent_strategy_label: inputs.agent_strategy_label!, + agent_output_schema: inputs.output_schema, } : undefined} onStrategyChange={(strategy) => { setInputs({ @@ -25,6 +29,7 @@ const AgentPanel: FC> = (props) => { agent_strategy_name: strategy?.agent_strategy_name, agent_parameters: strategy?.agent_parameters, agent_strategy_label: strategy?.agent_strategy_label, + output_schema: strategy!.agent_output_schema, }) }} formSchema={currentStrategy?.parameters as any || []} @@ -35,6 +40,33 @@ const AgentPanel: FC> = (props) => { })} /> +
+ + + + + {inputs.output_schema && Object.entries(inputs.output_schema).map(([name, schema]) => ( + + ))} + +
} diff --git a/web/app/components/workflow/nodes/agent/types.ts b/web/app/components/workflow/nodes/agent/types.ts index a3301bcd62..20da43f66a 100644 --- a/web/app/components/workflow/nodes/agent/types.ts +++ b/web/app/components/workflow/nodes/agent/types.ts @@ -7,4 +7,5 @@ export type AgentNodeType = CommonNodeType & { agent_strategy_label?: string agent_parameters?: ToolVarInputs, agent_configurations?: Record + output_schema: Record } diff --git a/web/i18n/en-US/workflow.ts b/web/i18n/en-US/workflow.ts index 30e13b527d..f58bc3fdd0 100644 --- a/web/i18n/en-US/workflow.ts +++ b/web/i18n/en-US/workflow.ts @@ -728,6 +728,17 @@ const translation = { modelSelectorTooltips: { deprecated: 'This model is deprecated', }, + outputVars: { + text: 'agent generated content', + files: { + title: 'agent generated files', + type: 'Support type. Now only support image', + transfer_method: 'Transfer method.Value is remote_url or local_file', + url: 'Image url', + upload_file_id: 'Upload file id', + }, + json: 'agent generated json', + }, }, }, tracing: { diff --git a/web/i18n/zh-Hans/workflow.ts b/web/i18n/zh-Hans/workflow.ts index b4291c64fc..82c92dc983 100644 --- a/web/i18n/zh-Hans/workflow.ts +++ b/web/i18n/zh-Hans/workflow.ts @@ -728,6 +728,17 @@ const translation = { modelSelectorTooltips: { deprecated: '此模型已弃用', }, + outputVars: { + text: 'agent 生成的内容', + files: { + title: 'agent 生成的文件', + type: '支持类型。现在只支持图片', + transfer_method: '传输方式。值为 remote_url 或 local_file', + url: '图片链接', + upload_file_id: '上传文件ID', + }, + json: 'agent 生成的json', + }, }, }, tracing: {