mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-07-15 19:21:51 +08:00
feat: enhance index type handling and add error notification for missing embedding model (#16836)
This commit is contained in:
parent
be3ebea45b
commit
cd7ac20d80
@ -169,12 +169,11 @@ const StepTwo = ({
|
|||||||
const [rules, setRules] = useState<PreProcessingRule[]>([])
|
const [rules, setRules] = useState<PreProcessingRule[]>([])
|
||||||
const [defaultConfig, setDefaultConfig] = useState<Rules>()
|
const [defaultConfig, setDefaultConfig] = useState<Rules>()
|
||||||
const hasSetIndexType = !!indexingType
|
const hasSetIndexType = !!indexingType
|
||||||
const [indexType, setIndexType] = useState<IndexingType>(
|
const [indexType, setIndexType] = useState<IndexingType>(() => {
|
||||||
(indexingType
|
if (hasSetIndexType)
|
||||||
|| isAPIKeySet)
|
return indexingType
|
||||||
? IndexingType.QUALIFIED
|
return isAPIKeySet ? IndexingType.QUALIFIED : IndexingType.ECONOMICAL
|
||||||
: IndexingType.ECONOMICAL,
|
})
|
||||||
)
|
|
||||||
|
|
||||||
const [previewFile, setPreviewFile] = useState<DocumentItem>(
|
const [previewFile, setPreviewFile] = useState<DocumentItem>(
|
||||||
(datasetId && documentDetail)
|
(datasetId && documentDetail)
|
||||||
@ -421,6 +420,13 @@ const StepTwo = ({
|
|||||||
}
|
}
|
||||||
else { // create
|
else { // create
|
||||||
const indexMethod = getIndexing_technique()
|
const indexMethod = getIndexing_technique()
|
||||||
|
if (indexMethod === IndexingType.QUALIFIED && (!embeddingModel.model || !embeddingModel.provider)) {
|
||||||
|
Toast.notify({
|
||||||
|
type: 'error',
|
||||||
|
message: t('appDebug.datasetConfig.embeddingModelRequired'),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
!isReRankModelSelected({
|
!isReRankModelSelected({
|
||||||
rerankModelList,
|
rerankModelList,
|
||||||
@ -568,7 +574,6 @@ const StepTwo = ({
|
|||||||
// get indexing type by props
|
// get indexing type by props
|
||||||
if (indexingType)
|
if (indexingType)
|
||||||
setIndexType(indexingType as IndexingType)
|
setIndexType(indexingType as IndexingType)
|
||||||
|
|
||||||
else
|
else
|
||||||
setIndexType(isAPIKeySet ? IndexingType.QUALIFIED : IndexingType.ECONOMICAL)
|
setIndexType(isAPIKeySet ? IndexingType.QUALIFIED : IndexingType.ECONOMICAL)
|
||||||
}, [isAPIKeySet, indexingType, datasetId])
|
}, [isAPIKeySet, indexingType, datasetId])
|
||||||
@ -848,9 +853,8 @@ const StepTwo = ({
|
|||||||
description={t('datasetCreation.stepTwo.qualifiedTip')}
|
description={t('datasetCreation.stepTwo.qualifiedTip')}
|
||||||
icon={<Image src={indexMethodIcon.high_quality} alt='' />}
|
icon={<Image src={indexMethodIcon.high_quality} alt='' />}
|
||||||
isActive={!hasSetIndexType && indexType === IndexingType.QUALIFIED}
|
isActive={!hasSetIndexType && indexType === IndexingType.QUALIFIED}
|
||||||
disabled={!isAPIKeySet || hasSetIndexType}
|
disabled={hasSetIndexType}
|
||||||
onSwitched={() => {
|
onSwitched={() => {
|
||||||
if (isAPIKeySet)
|
|
||||||
setIndexType(IndexingType.QUALIFIED)
|
setIndexType(IndexingType.QUALIFIED)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@ -894,10 +898,9 @@ const StepTwo = ({
|
|||||||
description={t('datasetCreation.stepTwo.economicalTip')}
|
description={t('datasetCreation.stepTwo.economicalTip')}
|
||||||
icon={<Image src={indexMethodIcon.economical} alt='' />}
|
icon={<Image src={indexMethodIcon.economical} alt='' />}
|
||||||
isActive={!hasSetIndexType && indexType === IndexingType.ECONOMICAL}
|
isActive={!hasSetIndexType && indexType === IndexingType.ECONOMICAL}
|
||||||
disabled={!isAPIKeySet || hasSetIndexType || docForm !== ChunkingMode.text}
|
disabled={hasSetIndexType || docForm !== ChunkingMode.text}
|
||||||
ref={economyDomRef}
|
ref={economyDomRef}
|
||||||
onSwitched={() => {
|
onSwitched={() => {
|
||||||
if (isAPIKeySet && docForm === ChunkingMode.text)
|
|
||||||
setIndexType(IndexingType.ECONOMICAL)
|
setIndexType(IndexingType.ECONOMICAL)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -483,6 +483,7 @@ const translation = {
|
|||||||
title: 'Multi-path retrieval',
|
title: 'Multi-path retrieval',
|
||||||
description: 'Based on user intent, queries across all Knowledge, retrieves relevant text from multi-sources, and selects the best results matching the user query after reranking.',
|
description: 'Based on user intent, queries across all Knowledge, retrieves relevant text from multi-sources, and selects the best results matching the user query after reranking.',
|
||||||
},
|
},
|
||||||
|
embeddingModelRequired: 'A configured Embedding Model is required',
|
||||||
rerankModelRequired: 'A configured Rerank Model is required',
|
rerankModelRequired: 'A configured Rerank Model is required',
|
||||||
params: 'Params',
|
params: 'Params',
|
||||||
top_k: 'Top K',
|
top_k: 'Top K',
|
||||||
|
@ -475,6 +475,7 @@ const translation = {
|
|||||||
title: '多路召回',
|
title: '多路召回',
|
||||||
description: '根据用户意图同时匹配所有知识库,从多路知识库查询相关文本片段,经过重排序步骤,从多路查询结果中选择匹配用户问题的最佳结果。',
|
description: '根据用户意图同时匹配所有知识库,从多路知识库查询相关文本片段,经过重排序步骤,从多路查询结果中选择匹配用户问题的最佳结果。',
|
||||||
},
|
},
|
||||||
|
embeddingModelRequired: '未配置 Embedding 模型',
|
||||||
rerankModelRequired: '未配置 Rerank 模型',
|
rerankModelRequired: '未配置 Rerank 模型',
|
||||||
params: '参数设置',
|
params: '参数设置',
|
||||||
top_k: 'Top K',
|
top_k: 'Top K',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user