This commit is contained in:
crazywoola
2025-05-15 22:39:35 +08:00
committed by GitHub
parent 8081aec730
commit 4dc06ee43f
27 changed files with 23 additions and 525 deletions

View File

@@ -1,6 +1,5 @@
import type { NodeDefault, Var } from '../../types'
import type { NodeDefault } from '../../types'
import { BlockEnum } from '../../types'
import { getNotExistVariablesByArray, getNotExistVariablesByText } from '../../utils/workflow'
import type { QuestionClassifierNodeType } from './types'
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/blocks'
@@ -72,30 +71,6 @@ const nodeDefault: NodeDefault<QuestionClassifierNodeType> = {
errorMessage: errorMessages,
}
},
checkVarValid(payload: QuestionClassifierNodeType, varMap: Record<string, Var>, t: any) {
const errorMessageArr = []
const query_variable_selector_warnings = getNotExistVariablesByArray([payload.query_variable_selector], varMap)
if (query_variable_selector_warnings.length)
errorMessageArr.push(`${t('workflow.nodes.questionClassifiers.inputVars')} ${t('workflow.common.referenceVar')}${query_variable_selector_warnings.join('、')}${t('workflow.common.noExist')}`)
let vision_variable_selector_warnings: string[] = []
if (payload.vision?.configs?.variable_selector?.length) {
vision_variable_selector_warnings = getNotExistVariablesByArray([payload.vision?.configs?.variable_selector], varMap)
if (vision_variable_selector_warnings.length)
errorMessageArr.push(`${t('workflow.nodes.llm.vision')} ${t('workflow.common.referenceVar')}${vision_variable_selector_warnings.join('、')}${t('workflow.common.noExist')}`)
}
const instruction_warnings: string[] = getNotExistVariablesByText(payload.instruction, varMap)
if (instruction_warnings.length)
errorMessageArr.push(`${t('workflow.nodes.questionClassifiers.advancedSetting')}-${t('workflow.nodes.questionClassifiers.instruction')} ${t('workflow.common.referenceVar')}${instruction_warnings.join('、')}${t('workflow.common.noExist')}`)
return {
isValid: true,
warning_vars: [...query_variable_selector_warnings, ...vision_variable_selector_warnings, ...instruction_warnings],
errorMessage: errorMessageArr,
}
},
}
export default nodeDefault