diff --git a/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts b/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts index 42d8cce551..5163df7e4d 100644 --- a/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts +++ b/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts @@ -12,13 +12,37 @@ import { BlockEnum, InputVarType, NodeRunningStatus, VarType } from '@/app/compo import { useStore as useAppStore } from '@/app/components/app/store' import { singleNodeRun } from '@/service/workflow' import Toast from '@/app/components/base/toast' + +import LLMDefault from '@/app/components/workflow/nodes/llm/default' +import KnowledgeRetrievalDefault from '@/app/components/workflow/nodes/knowledge-retrieval/default' +import IfElseDefault from '@/app/components/workflow/nodes/if-else/default' import CodeDefault from '@/app/components/workflow/nodes/code/default' +import TemplateTransformDefault from '@/app/components/workflow/nodes/template-transform/default' +import QuestionClassifyDefault from '@/app/components/workflow/nodes/question-classifier/default' import HTTPDefault from '@/app/components/workflow/nodes/http/default' +import ToolDefault from '@/app/components/workflow/nodes/tool/default' +import VariableAssigner from '@/app/components/workflow/nodes/variable-assigner/default' + +const { checkValid: checkLLMValid } = LLMDefault +const { checkValid: checkKnowledgeRetrievalValid } = KnowledgeRetrievalDefault +const { checkValid: checkIfElseValid } = IfElseDefault const { checkValid: checkCodeValid } = CodeDefault +const { checkValid: checkTemplateTransformValid } = TemplateTransformDefault +const { checkValid: checkQuestionClassifyValid } = QuestionClassifyDefault +const { checkValid: checkHttpValid } = HTTPDefault +const { checkValid: checkToolValid } = ToolDefault +const { checkValid: checkVariableAssignerValid } = VariableAssigner const checkValidFns: Record = { + [BlockEnum.LLM]: checkLLMValid, + [BlockEnum.KnowledgeRetrieval]: checkKnowledgeRetrievalValid, + [BlockEnum.IfElse]: checkIfElseValid, [BlockEnum.Code]: checkCodeValid, - [BlockEnum.HttpRequest]: HTTPDefault.checkValid, + [BlockEnum.TemplateTransform]: checkTemplateTransformValid, + [BlockEnum.QuestionClassifier]: checkQuestionClassifyValid, + [BlockEnum.HttpRequest]: checkHttpValid, + [BlockEnum.Tool]: checkToolValid, + [BlockEnum.VariableAssigner]: checkVariableAssignerValid, } as any type Params = { diff --git a/web/app/components/workflow/nodes/llm/default.ts b/web/app/components/workflow/nodes/llm/default.ts index 352b040e03..9ec45824db 100644 --- a/web/app/components/workflow/nodes/llm/default.ts +++ b/web/app/components/workflow/nodes/llm/default.ts @@ -3,6 +3,8 @@ import { type NodeDefault, PromptRole } from '../../types' import type { LLMNodeType } from './types' import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/constants' +const i18nPrefix = 'workflow.errorMsg' + const nodeDefault: NodeDefault = { defaultValue: { model: { @@ -43,15 +45,13 @@ const nodeDefault: NodeDefault = { const nodes = isChatMode ? ALL_CHAT_AVAILABLE_BLOCKS : ALL_COMPLETION_AVAILABLE_BLOCKS return nodes }, - checkValid(payload: LLMNodeType) { - let isValid = true + checkValid(payload: LLMNodeType, t: any) { let errorMessages = '' - if (payload.type) { - isValid = true - errorMessages = '' - } + if (!errorMessages && !payload.model.provider) + errorMessages = t(`${i18nPrefix}.fieldRequired`, { field: t(`${i18nPrefix}.fields.model`) }) + return { - isValid, + isValid: !errorMessages, errorMessage: errorMessages, } }, diff --git a/web/i18n/en-US/workflow.ts b/web/i18n/en-US/workflow.ts index f17097c3cb..8e839c6c78 100644 --- a/web/i18n/en-US/workflow.ts +++ b/web/i18n/en-US/workflow.ts @@ -34,6 +34,7 @@ const translation = { variable: 'Variable Name', variableValue: 'Variable Value', code: 'Code', + model: 'Model', }, }, singleRun: { diff --git a/web/i18n/zh-Hans/workflow.ts b/web/i18n/zh-Hans/workflow.ts index 7d3c57387d..659703a373 100644 --- a/web/i18n/zh-Hans/workflow.ts +++ b/web/i18n/zh-Hans/workflow.ts @@ -34,6 +34,7 @@ const translation = { variable: '变量名', variableValue: '变量值', code: '代码', + model: '模型', }, }, singleRun: {