mirror of
https://github.com/langgenius/dify.git
synced 2026-08-03 11:46:37 +08:00
feat: retrieval check valid
This commit is contained in:
parent
a436550dff
commit
6bfd61a887
@ -4,6 +4,7 @@ import type { KnowledgeRetrievalNodeType } from './types'
|
|||||||
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/constants'
|
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/constants'
|
||||||
|
|
||||||
import { RETRIEVE_TYPE } from '@/types/app'
|
import { RETRIEVE_TYPE } from '@/types/app'
|
||||||
|
const i18nPrefix = 'workflow'
|
||||||
|
|
||||||
const nodeDefault: NodeDefault<KnowledgeRetrievalNodeType> = {
|
const nodeDefault: NodeDefault<KnowledgeRetrievalNodeType> = {
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
@ -21,15 +22,22 @@ const nodeDefault: NodeDefault<KnowledgeRetrievalNodeType> = {
|
|||||||
const nodes = isChatMode ? ALL_CHAT_AVAILABLE_BLOCKS : ALL_COMPLETION_AVAILABLE_BLOCKS
|
const nodes = isChatMode ? ALL_CHAT_AVAILABLE_BLOCKS : ALL_COMPLETION_AVAILABLE_BLOCKS
|
||||||
return nodes
|
return nodes
|
||||||
},
|
},
|
||||||
checkValid(payload: KnowledgeRetrievalNodeType) {
|
checkValid(payload: KnowledgeRetrievalNodeType, t: any) {
|
||||||
let isValid = true
|
|
||||||
let errorMessages = ''
|
let errorMessages = ''
|
||||||
if (payload.type) {
|
if (!errorMessages && (!payload.query_variable_selector || payload.query_variable_selector.length === 0))
|
||||||
isValid = true
|
errorMessages = t(`${i18nPrefix}.errorMsg.fieldRequired`, { field: t(`${i18nPrefix}.nodes.knowledgeRetrieval.queryVariable`) })
|
||||||
errorMessages = ''
|
|
||||||
}
|
if (!errorMessages && (!payload.dataset_ids || payload.dataset_ids.length === 0))
|
||||||
|
errorMessages = t(`${i18nPrefix}.errorMsg.fieldRequired`, { field: t(`${i18nPrefix}.nodes.knowledgeRetrieval.knowledge`) })
|
||||||
|
|
||||||
|
if (!errorMessages && payload.retrieval_mode === RETRIEVE_TYPE.multiWay && !payload.multiple_retrieval_config?.reranking_model?.provider)
|
||||||
|
errorMessages = t(`${i18nPrefix}.errorMsg.fieldRequired`, { field: t(`${i18nPrefix}.errorMsg.fields.rerankModel`) })
|
||||||
|
|
||||||
|
if (!errorMessages && payload.retrieval_mode === RETRIEVE_TYPE.oneWay && !payload.single_retrieval_config?.model?.provider)
|
||||||
|
errorMessages = t(`${i18nPrefix}.errorMsg.fieldRequired`, { field: t('common.modelProvider.systemReasoningModel.key') })
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isValid,
|
isValid: !errorMessages,
|
||||||
errorMessage: errorMessages,
|
errorMessage: errorMessages,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -36,6 +36,7 @@ const translation = {
|
|||||||
variableValue: 'Variable Value',
|
variableValue: 'Variable Value',
|
||||||
code: 'Code',
|
code: 'Code',
|
||||||
model: 'Model',
|
model: 'Model',
|
||||||
|
rerankModel: 'Rerank Model',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
singleRun: {
|
singleRun: {
|
||||||
|
|||||||
@ -36,6 +36,7 @@ const translation = {
|
|||||||
variableValue: '变量值',
|
variableValue: '变量值',
|
||||||
code: '代码',
|
code: '代码',
|
||||||
model: '模型',
|
model: '模型',
|
||||||
|
rerankModel: 'Rerank 模型',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
singleRun: {
|
singleRun: {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user