feat: add checkvalid empty fn

This commit is contained in:
Joel
2024-03-14 20:44:51 +08:00
parent ae6a558662
commit ac675c4443
13 changed files with 140 additions and 2 deletions

View File

@ -1,10 +1,10 @@
import type { NodeDefault } from '../../types'
import { type NodeDefault, VarType } from '../../types'
import type { VariableAssignerNodeType } from './types'
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/constants'
const nodeDefault: NodeDefault<VariableAssignerNodeType> = {
defaultValue: {
output_type: 'string',
output_type: VarType.string,
variables: [],
},
getAvailablePrevNodes(isChatMode: boolean) {
@ -15,6 +15,18 @@ const nodeDefault: NodeDefault<VariableAssignerNodeType> = {
const nodes = isChatMode ? ALL_CHAT_AVAILABLE_BLOCKS : ALL_COMPLETION_AVAILABLE_BLOCKS
return nodes
},
checkValid(payload: VariableAssignerNodeType) {
let isValid = true
let errorMessages = ''
if (payload.type) {
isValid = true
errorMessages = ''
}
return {
isValid,
errorMessage: errorMessages,
}
},
}
export default nodeDefault