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 2bcfc3eab9..dcddb9829c 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 @@ -80,7 +80,7 @@ const useOneStepRun = ({ moreDataForCheckValid, }: Params) => { const { t } = useTranslation() - const { getBeforeNodesInSameBranch } = useWorkflow() + const { getBeforeNodesInSameBranch } = useWorkflow() as any const isChatMode = useIsChatMode() const allOutputVars = toNodeOutputVars(getBeforeNodesInSameBranch(id), isChatMode) diff --git a/web/app/components/workflow/nodes/question-classifier/default.ts b/web/app/components/workflow/nodes/question-classifier/default.ts index a8af8be940..a059401e0e 100644 --- a/web/app/components/workflow/nodes/question-classifier/default.ts +++ b/web/app/components/workflow/nodes/question-classifier/default.ts @@ -3,6 +3,8 @@ import { BlockEnum } from '../../types' import type { QuestionClassifierNodeType } from './types' import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/constants' +const i18nPrefix = 'workflow' + const nodeDefault: NodeDefault = { defaultValue: { query_variable_selector: [], @@ -26,15 +28,19 @@ const nodeDefault: NodeDefault = { const nodes = isChatMode ? ALL_CHAT_AVAILABLE_BLOCKS : ALL_COMPLETION_AVAILABLE_BLOCKS return nodes.filter(type => type !== BlockEnum.VariableAssigner) }, - checkValid(payload: QuestionClassifierNodeType) { - let isValid = true + checkValid(payload: QuestionClassifierNodeType, t: any) { let errorMessages = '' - if (payload.type) { - isValid = true - errorMessages = '' - } + if (!errorMessages && (!payload.query_variable_selector || payload.query_variable_selector.length === 0)) + errorMessages = t(`${i18nPrefix}.errorMsg.fieldRequired`, { field: t(`${i18nPrefix}.nodes.questionClassifiers.inputVars`) }) + + if (!errorMessages && !payload.model.provider) + errorMessages = t(`${i18nPrefix}.errorMsg.fieldRequired`, { field: t(`${i18nPrefix}.nodes.questionClassifiers.model`) }) + + if (!errorMessages && (!payload.classes || payload.classes.length === 0)) + errorMessages = t(`${i18nPrefix}.errorMsg.fieldRequired`, { field: t(`${i18nPrefix}.nodes.questionClassifiers.class`) }) + return { - isValid, + isValid: !errorMessages, errorMessage: errorMessages, } }, diff --git a/web/app/components/workflow/nodes/question-classifier/panel.tsx b/web/app/components/workflow/nodes/question-classifier/panel.tsx index 95bafb0ac8..6c8126b4f7 100644 --- a/web/app/components/workflow/nodes/question-classifier/panel.tsx +++ b/web/app/components/workflow/nodes/question-classifier/panel.tsx @@ -56,6 +56,7 @@ const Panel: FC> = ({ value={inputs.query_variable_selector} onChange={handleQueryVarChange} filterVar={filterVar} + width={387} />