This commit is contained in:
@@ -164,7 +164,7 @@ const findExceptVarInObject = (obj: any, filterVar: (payload: Var, selector: Val
|
||||
return res
|
||||
}
|
||||
|
||||
export const formatItem = (
|
||||
const formatItem = (
|
||||
item: any,
|
||||
isChatMode: boolean,
|
||||
filterVar: (payload: Var, selector: ValueSelector) => boolean,
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { BlockEnum } from '../../types'
|
||||
import type { NodeDefault, Var } from '../../types'
|
||||
import { getNotExistVariablesByText } from '../../utils/workflow'
|
||||
import type { NodeDefault } from '../../types'
|
||||
import type { AnswerNodeType } from './types'
|
||||
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/blocks'
|
||||
|
||||
@@ -32,19 +31,6 @@ const nodeDefault: NodeDefault<AnswerNodeType> = {
|
||||
errorMessage: errorMessages,
|
||||
}
|
||||
},
|
||||
checkVarValid(payload: AnswerNodeType, varMap: Record<string, Var>, t: any) {
|
||||
const errorMessageArr = []
|
||||
|
||||
const answer_warnings = getNotExistVariablesByText(payload.answer || '', varMap)
|
||||
if (answer_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.answer.answer')} ${t('workflow.common.referenceVar')}${answer_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
return {
|
||||
isValid: true,
|
||||
warning_vars: [...answer_warnings],
|
||||
errorMessage: errorMessageArr,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default nodeDefault
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { BlockEnum } from '../../types'
|
||||
import type { NodeDefault, Var } from '../../types'
|
||||
import { getNotExistVariablesByArray } from '../../utils/workflow'
|
||||
import type { NodeDefault } from '../../types'
|
||||
import { type AssignerNodeType, WriteMode } from './types'
|
||||
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/blocks'
|
||||
const i18nPrefix = 'workflow.errorMsg'
|
||||
@@ -48,24 +47,6 @@ const nodeDefault: NodeDefault<AssignerNodeType> = {
|
||||
errorMessage: errorMessages,
|
||||
}
|
||||
},
|
||||
|
||||
checkVarValid(payload: AssignerNodeType, varMap: Record<string, Var>, t: any) {
|
||||
const errorMessageArr: string[] = []
|
||||
const items = payload.items ?? []
|
||||
const variables_warnings = getNotExistVariablesByArray(items.map(item => item.variable_selector ?? []) ?? [], varMap)
|
||||
if (variables_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.assigner.assignedVariable')} ${t('workflow.common.referenceVar')}${variables_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
const value_warnings = getNotExistVariablesByArray(items.map(item => item.value ?? []) ?? [], varMap)
|
||||
if (value_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.assigner.setVariable')} ${t('workflow.common.referenceVar')}${value_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
return {
|
||||
isValid: true,
|
||||
warning_vars: [...variables_warnings, ...value_warnings],
|
||||
errorMessage: errorMessageArr,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default nodeDefault
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { BlockEnum } from '../../types'
|
||||
import type { NodeDefault, Var } from '../../types'
|
||||
import { getNotExistVariablesByArray } from '../../utils/workflow'
|
||||
import type { NodeDefault } from '../../types'
|
||||
import { CodeLanguage, type CodeNodeType } from './types'
|
||||
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/blocks'
|
||||
|
||||
@@ -38,20 +37,7 @@ const nodeDefault: NodeDefault<CodeNodeType> = {
|
||||
errorMessage: errorMessages,
|
||||
}
|
||||
},
|
||||
checkVarValid(payload: CodeNodeType, varMap: Record<string, Var>, t: any) {
|
||||
const errorMessageArr = []
|
||||
|
||||
const variables_selector = payload.variables.map(v => v.value_selector)
|
||||
const variables_selector_warnings = getNotExistVariablesByArray(variables_selector, varMap)
|
||||
if (variables_selector_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.code.inputVars')} ${t('workflow.common.referenceVar')}${variables_selector_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
return {
|
||||
isValid: true,
|
||||
warning_vars: variables_selector_warnings,
|
||||
errorMessage: errorMessageArr,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default nodeDefault
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { BlockEnum } from '../../types'
|
||||
import type { NodeDefault, Var } from '../../types'
|
||||
import { getNotExistVariablesByArray } from '../../utils/workflow'
|
||||
import type { NodeDefault } from '../../types'
|
||||
import type { DocExtractorNodeType } from './types'
|
||||
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/blocks'
|
||||
const i18nPrefix = 'workflow.errorMsg'
|
||||
@@ -32,19 +31,6 @@ const nodeDefault: NodeDefault<DocExtractorNodeType> = {
|
||||
errorMessage: errorMessages,
|
||||
}
|
||||
},
|
||||
checkVarValid(payload: DocExtractorNodeType, varMap: Record<string, Var>, t: any) {
|
||||
const errorMessageArr: string[] = []
|
||||
|
||||
const variables_warnings = getNotExistVariablesByArray([payload.variable_selector], varMap)
|
||||
if (variables_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.docExtractor.inputVar')} ${t('workflow.common.referenceVar')}${variables_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
return {
|
||||
isValid: true,
|
||||
warning_vars: variables_warnings,
|
||||
errorMessage: errorMessageArr,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default nodeDefault
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { BlockEnum } from '../../types'
|
||||
import type { NodeDefault, Var } from '../../types'
|
||||
import { getNotExistVariablesByArray, getNotExistVariablesByText } from '../../utils/workflow'
|
||||
import type { NodeDefault } from '../../types'
|
||||
import { AuthorizationType, BodyType, Method } from './types'
|
||||
import type { BodyPayload, HttpNodeType } from './types'
|
||||
import {
|
||||
@@ -51,8 +50,8 @@ const nodeDefault: NodeDefault<HttpNodeType> = {
|
||||
errorMessages = t('workflow.errorMsg.fieldRequired', { field: t('workflow.nodes.http.api') })
|
||||
|
||||
if (!errorMessages
|
||||
&& payload.body.type === BodyType.binary
|
||||
&& ((!(payload.body.data as BodyPayload)[0]?.file) || (payload.body.data as BodyPayload)[0]?.file?.length === 0)
|
||||
&& payload.body.type === BodyType.binary
|
||||
&& ((!(payload.body.data as BodyPayload)[0]?.file) || (payload.body.data as BodyPayload)[0]?.file?.length === 0)
|
||||
)
|
||||
errorMessages = t('workflow.errorMsg.fieldRequired', { field: t('workflow.nodes.http.binaryFileVariable') })
|
||||
|
||||
@@ -61,53 +60,6 @@ const nodeDefault: NodeDefault<HttpNodeType> = {
|
||||
errorMessage: errorMessages,
|
||||
}
|
||||
},
|
||||
checkVarValid(payload: HttpNodeType, varMap: Record<string, Var>, t: any) {
|
||||
const errorMessageArr: string[] = []
|
||||
const url_warnings = getNotExistVariablesByText(payload.url, varMap)
|
||||
if (url_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.http.api')} ${t('workflow.common.referenceVar')}${url_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
const headers_warnings = getNotExistVariablesByText(payload.headers, varMap)
|
||||
if (headers_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.http.headers')} ${t('workflow.common.referenceVar')}${headers_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
const params_warnings = getNotExistVariablesByText(payload.params, varMap)
|
||||
if (params_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.http.params')} ${t('workflow.common.referenceVar')}${params_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
const body_warnings: string[] = []
|
||||
|
||||
if ([BodyType.binary].includes(payload.body.type)) {
|
||||
const body_data = payload.body.data as BodyPayload
|
||||
body_data.forEach((item) => {
|
||||
const key_warnings = getNotExistVariablesByText(item.key || '', varMap)
|
||||
if (key_warnings.length)
|
||||
body_warnings.push(...key_warnings)
|
||||
const warnings = getNotExistVariablesByArray([item.file || []], varMap)
|
||||
if (warnings.length)
|
||||
body_warnings.push(...warnings)
|
||||
})
|
||||
}
|
||||
else {
|
||||
const body_data = payload.body.data as BodyPayload
|
||||
body_data.forEach((item) => {
|
||||
const key_warnings = getNotExistVariablesByText(item.key || '', varMap)
|
||||
if (key_warnings.length)
|
||||
body_warnings.push(...key_warnings)
|
||||
const value_warnings = getNotExistVariablesByText(item.value || '', varMap)
|
||||
if (value_warnings.length)
|
||||
body_warnings.push(...value_warnings)
|
||||
})
|
||||
}
|
||||
if (body_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.http.body')} ${t('workflow.common.referenceVar')}${body_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
return {
|
||||
isValid: true,
|
||||
warning_vars: [...url_warnings, ...headers_warnings, ...params_warnings, ...body_warnings],
|
||||
errorMessage: errorMessageArr,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default nodeDefault
|
||||
|
@@ -1,6 +1,4 @@
|
||||
import type { Var } from '../../types'
|
||||
import { BlockEnum, type NodeDefault } from '../../types'
|
||||
import { getNotExistVariablesByArray, getNotExistVariablesByText } from '../../utils/workflow'
|
||||
import { type IfElseNodeType, LogicalOperator } from './types'
|
||||
import { isEmptyRelatedOperator } from './utils'
|
||||
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/blocks'
|
||||
@@ -77,41 +75,6 @@ const nodeDefault: NodeDefault<IfElseNodeType> = {
|
||||
errorMessage: errorMessages,
|
||||
}
|
||||
},
|
||||
checkVarValid(payload: IfElseNodeType, varMap: Record<string, Var>, t: any) {
|
||||
const errorMessageArr = []
|
||||
|
||||
const condition_variable_selector_warnings: string[] = []
|
||||
const condition_value_warnings: string[] = []
|
||||
payload.cases.forEach((caseItem) => {
|
||||
caseItem.conditions.forEach((condition) => {
|
||||
if (!condition.variable_selector)
|
||||
return
|
||||
const selector_warnings = getNotExistVariablesByArray([condition.variable_selector], varMap)
|
||||
if (selector_warnings.length)
|
||||
condition_variable_selector_warnings.push(...selector_warnings)
|
||||
const value_warnings = Array.isArray(condition.value) ? getNotExistVariablesByArray([condition.value], varMap) : getNotExistVariablesByText(condition.value, varMap)
|
||||
if (value_warnings.length)
|
||||
condition_value_warnings.push(...value_warnings)
|
||||
condition.sub_variable_condition?.conditions.forEach((subCondition) => {
|
||||
const sub_variable_value_warnings = Array.isArray(subCondition.value) ? getNotExistVariablesByArray([subCondition.value], varMap) : getNotExistVariablesByText(subCondition.value, varMap)
|
||||
if (sub_variable_value_warnings.length)
|
||||
condition_value_warnings.push(...sub_variable_value_warnings)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
if (condition_variable_selector_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.ifElse.condition')} ${t('workflow.common.referenceVar')}${condition_variable_selector_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
if (condition_value_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.ifElse.enterValue')} ${t('workflow.common.referenceVar')}${condition_value_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
return {
|
||||
isValid: true,
|
||||
warning_vars: condition_variable_selector_warnings,
|
||||
errorMessage: errorMessageArr,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default nodeDefault
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { BlockEnum, ErrorHandleMode } from '../../types'
|
||||
import type { NodeDefault, Var } from '../../types'
|
||||
import { getNotExistVariablesByArray } from '../../utils/workflow'
|
||||
import type { NodeDefault } from '../../types'
|
||||
import type { IterationNodeType } from './types'
|
||||
import {
|
||||
ALL_CHAT_AVAILABLE_BLOCKS,
|
||||
@@ -59,19 +58,6 @@ const nodeDefault: NodeDefault<IterationNodeType> = {
|
||||
errorMessage: errorMessages,
|
||||
}
|
||||
},
|
||||
checkVarValid(payload: IterationNodeType, varMap: Record<string, Var>, t: any) {
|
||||
const errorMessageArr: string[] = []
|
||||
|
||||
const iterator_selector_warnings = getNotExistVariablesByArray([payload.iterator_selector], varMap)
|
||||
if (iterator_selector_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.iteration.input')} ${t('workflow.common.referenceVar')}${iterator_selector_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
return {
|
||||
isValid: true,
|
||||
warning_vars: iterator_selector_warnings,
|
||||
errorMessage: errorMessageArr,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default nodeDefault
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { BlockEnum } from '../../types'
|
||||
import type { NodeDefault, Var } from '../../types'
|
||||
import { getNotExistVariablesByArray } from '../../utils/workflow'
|
||||
import type { NodeDefault } from '../../types'
|
||||
import type { KnowledgeRetrievalNodeType } from './types'
|
||||
import { checkoutRerankModelConfigedInRetrievalSettings } from './utils'
|
||||
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/blocks'
|
||||
@@ -53,19 +52,6 @@ const nodeDefault: NodeDefault<KnowledgeRetrievalNodeType> = {
|
||||
errorMessage: errorMessages,
|
||||
}
|
||||
},
|
||||
checkVarValid(payload: KnowledgeRetrievalNodeType, 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.knowledgeRetrieval.queryVariable')} ${t('workflow.common.referenceVar')}${query_variable_selector_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
return {
|
||||
isValid: true,
|
||||
warning_vars: [...query_variable_selector_warnings],
|
||||
errorMessage: errorMessageArr,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default nodeDefault
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { BlockEnum, VarType } from '../../types'
|
||||
import type { NodeDefault, Var } from '../../types'
|
||||
import { getNotExistVariablesByArray } from '../../utils/workflow'
|
||||
import type { NodeDefault } from '../../types'
|
||||
import { comparisonOperatorNotRequireValue } from '../if-else/utils'
|
||||
import { type ListFilterNodeType, OrderBy } from './types'
|
||||
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/blocks'
|
||||
@@ -61,18 +60,6 @@ const nodeDefault: NodeDefault<ListFilterNodeType> = {
|
||||
errorMessage: errorMessages,
|
||||
}
|
||||
},
|
||||
checkVarValid(payload: ListFilterNodeType, varMap: Record<string, Var>, t: any) {
|
||||
const errorMessageArr = []
|
||||
|
||||
const variable_warnings = getNotExistVariablesByArray([payload.variable], varMap)
|
||||
if (variable_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.listFilter.inputVar')} ${t('workflow.common.referenceVar')}${variable_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
return {
|
||||
isValid: true,
|
||||
warning_vars: variable_warnings,
|
||||
errorMessage: errorMessageArr,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default nodeDefault
|
||||
|
@@ -1,7 +1,5 @@
|
||||
import type { Var } from '../../types'
|
||||
import { BlockEnum, EditionType, VarType } from '../../types'
|
||||
import { BlockEnum, EditionType } from '../../types'
|
||||
import { type NodeDefault, type PromptItem, PromptRole } from '../../types'
|
||||
import { getNotExistVariablesByArray, getNotExistVariablesByText } from '../../utils/workflow'
|
||||
import type { LLMNodeType } from './types'
|
||||
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/blocks'
|
||||
|
||||
@@ -88,37 +86,6 @@ const nodeDefault: NodeDefault<LLMNodeType> = {
|
||||
errorMessage: errorMessages,
|
||||
}
|
||||
},
|
||||
checkVarValid(payload: LLMNodeType, varMap: Record<string, Var>, t: any) {
|
||||
const errorMessageArr = []
|
||||
const prompt_templates_warnings: string[] = []
|
||||
if (payload.context?.enabled && payload.context?.variable_selector?.length) {
|
||||
const context_variable_selector_warnings = getNotExistVariablesByArray([payload.context.variable_selector], varMap)
|
||||
if (context_variable_selector_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.llm.context')} ${t('workflow.common.referenceVar')}${context_variable_selector_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
}
|
||||
const prompt_templates = Array.isArray(payload.prompt_template) ? payload.prompt_template : [payload.prompt_template] as PromptItem[]
|
||||
prompt_templates.forEach((v) => {
|
||||
prompt_templates_warnings.push(...getNotExistVariablesByText(v.text, { context: { variable: 'context', type: VarType.string }, ...varMap }))
|
||||
})
|
||||
if (prompt_templates_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.llm.prompt')} ${t('workflow.common.referenceVar')}${prompt_templates_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
const memory_query_prompt_template_warnings = getNotExistVariablesByText(payload.memory?.query_prompt_template || '', varMap)
|
||||
if (memory_query_prompt_template_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.common.memories.title')}USER ${t('workflow.common.referenceVar')}${memory_query_prompt_template_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
if (payload.vision?.enabled && payload.vision?.configs?.variable_selector?.length) {
|
||||
const 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')}`)
|
||||
}
|
||||
|
||||
return {
|
||||
isValid: true,
|
||||
warning_vars: [...prompt_templates_warnings, ...memory_query_prompt_template_warnings],
|
||||
errorMessage: errorMessageArr,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default nodeDefault
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { BlockEnum } from '../../types'
|
||||
import type { NodeDefault, Var } from '../../types'
|
||||
import { getNotExistVariablesByArray, getNotExistVariablesByText } from '../../utils/workflow'
|
||||
import type { NodeDefault } from '../../types'
|
||||
import { type ParameterExtractorNodeType, ReasoningModeType } from './types'
|
||||
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/blocks'
|
||||
const i18nPrefix = 'workflow'
|
||||
@@ -65,30 +64,6 @@ const nodeDefault: NodeDefault<ParameterExtractorNodeType> = {
|
||||
errorMessage: errorMessages,
|
||||
}
|
||||
},
|
||||
checkVarValid(payload: ParameterExtractorNodeType, varMap: Record<string, Var>, t: any) {
|
||||
const errorMessageArr: string[] = []
|
||||
|
||||
const variables_warnings = getNotExistVariablesByArray([payload.query], varMap)
|
||||
if (variables_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.parameterExtractor.inputVar')} ${t('workflow.common.referenceVar')}${variables_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
let vision_variable_warnings: string[] = []
|
||||
if (payload.vision?.configs?.variable_selector?.length) {
|
||||
vision_variable_warnings = getNotExistVariablesByArray([payload.vision.configs.variable_selector], varMap)
|
||||
if (vision_variable_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.llm.vision')} ${t('workflow.common.referenceVar')}${vision_variable_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
}
|
||||
|
||||
const instruction_warnings = getNotExistVariablesByText(payload.instruction, varMap)
|
||||
if (instruction_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.parameterExtractor.instruction')} ${t('workflow.common.referenceVar')}${instruction_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
return {
|
||||
isValid: true,
|
||||
warning_vars: [...variables_warnings, ...vision_variable_warnings, ...instruction_warnings],
|
||||
errorMessage: errorMessageArr,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default nodeDefault
|
||||
|
@@ -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
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { BlockEnum } from '../../types'
|
||||
import type { NodeDefault, Var } from '../../types'
|
||||
import { getNotExistVariablesByArray } from '../../utils/workflow'
|
||||
import type { NodeDefault } from '../../types'
|
||||
import type { TemplateTransformNodeType } from './types'
|
||||
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/blocks'
|
||||
const i18nPrefix = 'workflow.errorMsg'
|
||||
@@ -34,19 +33,6 @@ const nodeDefault: NodeDefault<TemplateTransformNodeType> = {
|
||||
errorMessage: errorMessages,
|
||||
}
|
||||
},
|
||||
checkVarValid(payload: TemplateTransformNodeType, varMap: Record<string, Var>, t: any) {
|
||||
const errorMessageArr = []
|
||||
|
||||
const variables_selector = payload.variables.map(v => v.value_selector)
|
||||
const variables_selector_warnings = getNotExistVariablesByArray(variables_selector, varMap)
|
||||
if (variables_selector_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.templateTransform.inputVars')} ${t('workflow.common.referenceVar')}${variables_selector_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
return {
|
||||
isValid: true,
|
||||
errorMessage: errorMessageArr,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default nodeDefault
|
||||
|
@@ -1,9 +1,8 @@
|
||||
import { BlockEnum } from '../../types'
|
||||
import type { NodeDefault, Var } from '../../types'
|
||||
import type { NodeDefault } from '../../types'
|
||||
import type { ToolNodeType } from './types'
|
||||
import { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types'
|
||||
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/blocks'
|
||||
import { getNotExistVariablesByArray, getNotExistVariablesByText } from '../../utils/workflow'
|
||||
|
||||
const i18nPrefix = 'workflow.errorMsg'
|
||||
|
||||
@@ -64,35 +63,6 @@ const nodeDefault: NodeDefault<ToolNodeType> = {
|
||||
errorMessage: errorMessages,
|
||||
}
|
||||
},
|
||||
checkVarValid(payload: ToolNodeType, varMap: Record<string, Var>, t: any) {
|
||||
const errorMessageArr = []
|
||||
const tool_parametersMap = payload.tool_parameters
|
||||
const tool_parameters_array = Object.values(tool_parametersMap)
|
||||
const tool_parameters_warnings: string[] = []
|
||||
tool_parameters_array?.forEach((item) => {
|
||||
if (!item.value)
|
||||
return
|
||||
if (Array.isArray(item.value)) {
|
||||
const warnings = getNotExistVariablesByArray([item.value], varMap)
|
||||
if (warnings.length)
|
||||
tool_parameters_warnings.push(...warnings)
|
||||
return
|
||||
}
|
||||
if (typeof item.value === 'string') {
|
||||
const warnings = getNotExistVariablesByText(item.value, varMap)
|
||||
if (warnings.length)
|
||||
tool_parameters_warnings.push(...warnings)
|
||||
}
|
||||
})
|
||||
if (tool_parameters_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.tool.inputVars')} ${t('workflow.common.referenceVar')}${tool_parameters_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
return {
|
||||
isValid: true,
|
||||
warning_vars: tool_parameters_warnings,
|
||||
errorMessage: errorMessageArr,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default nodeDefault
|
||||
|
@@ -1,7 +1,5 @@
|
||||
import type { Var } from '../../types'
|
||||
import { type NodeDefault, VarType } from '../../types'
|
||||
import { BlockEnum } from '../../types'
|
||||
import { getNotExistVariablesByArray } from '../../utils/workflow'
|
||||
import type { VariableAssignerNodeType } from './types'
|
||||
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/blocks'
|
||||
|
||||
@@ -56,18 +54,6 @@ const nodeDefault: NodeDefault<VariableAssignerNodeType> = {
|
||||
errorMessage: errorMessages,
|
||||
}
|
||||
},
|
||||
checkVarValid(payload: VariableAssignerNodeType, varMap: Record<string, Var>, t: any) {
|
||||
const errorMessageArr: string[] = []
|
||||
const variables_warnings = getNotExistVariablesByArray(payload.variables ?? [], varMap)
|
||||
if (variables_warnings.length)
|
||||
errorMessageArr.push(`${t('workflow.nodes.variableAssigner.title')} ${t('workflow.common.referenceVar')}${variables_warnings.join('、')}${t('workflow.common.noExist')}`)
|
||||
|
||||
return {
|
||||
isValid: true,
|
||||
warning_vars: variables_warnings,
|
||||
errorMessage: errorMessageArr,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default nodeDefault
|
||||
|
Reference in New Issue
Block a user