diff --git a/web/app/components/workflow/nodes/_base/components/before-run-form/index.tsx b/web/app/components/workflow/nodes/_base/components/before-run-form/index.tsx index 689ab102d8..89c2fa7dd3 100644 --- a/web/app/components/workflow/nodes/_base/components/before-run-form/index.tsx +++ b/web/app/components/workflow/nodes/_base/components/before-run-form/index.tsx @@ -55,6 +55,8 @@ function formatValue(value: string | any, type: InputVarType) { if (type === InputVarType.singleFile) { if (Array.isArray(value)) return getProcessedFiles(value) + if (!value) + return undefined return getProcessedFiles([value])[0] } diff --git a/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts b/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts index bdc38620bc..4199266282 100644 --- a/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts +++ b/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts @@ -4,16 +4,17 @@ import { useCallback, useState } from 'react' import { TabType } from '../tab' import { useWorkflowStore } from '@/app/components/workflow/store' import type { Props as FormProps } from '@/app/components/workflow/nodes/_base/components/before-run-form/form' +import useStartSingleRunFormParams from '@/app/components/workflow/nodes/start/use-single-run-form-params' import useLLMSingleRunFormParams from '@/app/components/workflow/nodes/llm/use-single-run-form-params' -import useKnowledgeRetrievalSingleRunFormParams from '../../../../knowledge-retrieval/use-single-run-form-params' -import useCodeSingleRunFormParams from '../../../../code/use-single-run-form-params' -import useTemplateTransformSingleRunFormParams from '../../../../template-transform/use-single-run-form-params' -import useQuestionClassifierSingleRunFormParams from '../../../../question-classifier/use-single-run-form-params' -import useParameterExtractorSingleRunFormParams from '../../../../parameter-extractor/use-single-run-form-params' -import useHttpRequestSingleRunFormParams from '../../../../http/use-single-run-form-params' -import useIterationSingleRunFormParams from '../../../../iteration/use-single-run-form-params' -import useDocExtractorSingleRunFormParams from '../../../../document-extractor/use-single-run-form-params' -import useLoopSingleRunFormParams from '../../../../loop/use-single-run-form-params' +import useKnowledgeRetrievalSingleRunFormParams from '@/app/components/workflow/nodes/knowledge-retrieval/use-single-run-form-params' +import useCodeSingleRunFormParams from '@/app/components/workflow/nodes/code/use-single-run-form-params' +import useTemplateTransformSingleRunFormParams from '@/app/components/workflow/nodes/template-transform/use-single-run-form-params' +import useQuestionClassifierSingleRunFormParams from '@/app/components/workflow/nodes/question-classifier/use-single-run-form-params' +import useParameterExtractorSingleRunFormParams from '@/app/components/workflow/nodes/parameter-extractor/use-single-run-form-params' +import useHttpRequestSingleRunFormParams from '@/app/components/workflow/nodes/http/use-single-run-form-params' +import useIterationSingleRunFormParams from '@/app/components/workflow/nodes/iteration/use-single-run-form-params' +import useDocExtractorSingleRunFormParams from '@/app/components/workflow/nodes/document-extractor/use-single-run-form-params' +import useLoopSingleRunFormParams from '@/app/components/workflow/nodes/loop/use-single-run-form-params' import { BlockEnum } from '@/app/components/workflow/types' import { useNodesSyncDraft, @@ -32,12 +33,12 @@ const singleRunFormParamsHooks: Record = { [BlockEnum.Agent]: undefined, [BlockEnum.DocExtractor]: useDocExtractorSingleRunFormParams, [BlockEnum.Loop]: useLoopSingleRunFormParams, - [BlockEnum.Start]: undefined, + [BlockEnum.Start]: useStartSingleRunFormParams, + [BlockEnum.IfElse]: undefined, + [BlockEnum.VariableAggregator]: undefined, [BlockEnum.End]: undefined, [BlockEnum.Answer]: undefined, - [BlockEnum.IfElse]: undefined, [BlockEnum.VariableAssigner]: undefined, - [BlockEnum.VariableAggregator]: undefined, [BlockEnum.ListFilter]: undefined, [BlockEnum.IterationStart]: undefined, [BlockEnum.Assigner]: undefined, diff --git a/web/app/components/workflow/nodes/start/use-single-run-form-params.ts b/web/app/components/workflow/nodes/start/use-single-run-form-params.ts new file mode 100644 index 0000000000..454d8a9923 --- /dev/null +++ b/web/app/components/workflow/nodes/start/use-single-run-form-params.ts @@ -0,0 +1,47 @@ +import type { MutableRefObject } from 'react' +import { useTranslation } from 'react-i18next' +import type { Props as FormProps } from '@/app/components/workflow/nodes/_base/components/before-run-form/form' +import type { InputVar, Variable } from '@/app/components/workflow/types' +import type { StartNodeType } from './types' + +type Params = { + id: string, + payload: StartNodeType, + runInputData: Record + runInputDataRef: MutableRefObject> + getInputVars: (textList: string[]) => InputVar[] + setRunInputData: (data: Record) => void + toVarInputs: (variables: Variable[]) => InputVar[] +} +const useSingleRunFormParams = ({ + payload, + runInputData, + setRunInputData, +}: Params) => { + const { t } = useTranslation() + + const forms = (() => { + const forms: FormProps[] = [] + forms.push( + { + label: t('workflow.nodes.llm.singleRun.variable')!, + inputs: payload.variables.map((item: InputVar) => ({ + label: item.variable, + variable: item.variable, + type: item.type, + required: item.required, + })), + values: runInputData, + onChange: setRunInputData, + }, + ) + + return forms + })() + + return { + forms, + } +} + +export default useSingleRunFormParams diff --git a/web/app/components/workflow/utils/workflow.ts b/web/app/components/workflow/utils/workflow.ts index 88c31f09b5..f52d88806b 100644 --- a/web/app/components/workflow/utils/workflow.ts +++ b/web/app/components/workflow/utils/workflow.ts @@ -32,6 +32,9 @@ export const canRunBySingle = (nodeType: BlockEnum) => { || nodeType === BlockEnum.Agent || nodeType === BlockEnum.DocExtractor || nodeType === BlockEnum.Loop + || nodeType === BlockEnum.Start + || nodeType === BlockEnum.IfElse + || nodeType === BlockEnum.VariableAggregator } type ConnectedSourceOrTargetNodesChange = {