@ -1,4 +1,5 @@
import { useMemo } from 'react'
import { useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import {
import {
FullTextSearch ,
FullTextSearch ,
HybridSearch ,
HybridSearch ,
@ -15,57 +16,58 @@ import type {
} from './type'
} from './type'
export const useRetrievalSetting = ( indexMethod : IndexMethodEnum ) = > {
export const useRetrievalSetting = ( indexMethod : IndexMethodEnum ) = > {
const { t } = useTranslation ( )
const VectorSearchOption : Option = useMemo ( ( ) = > {
const VectorSearchOption : Option = useMemo ( ( ) = > {
return {
return {
id : RetrievalSearchMethodEnum.semantic ,
id : RetrievalSearchMethodEnum.semantic ,
icon : VectorSearch as any ,
icon : VectorSearch as any ,
title : 'Vector Search' ,
title : t ( 'dataset.retrieval.semantic_search.title' ) ,
description : 'Generate query embeddings and search for the text chunk most similar to its vector representation.' ,
description : t ( 'dataset.retrieval.semantic_search.description' ) ,
effectColor : 'purple' ,
effectColor : 'purple' ,
}
}
} , [ ] )
} , [ t ] )
const FullTextSearchOption : Option = useMemo ( ( ) = > {
const FullTextSearchOption : Option = useMemo ( ( ) = > {
return {
return {
id : RetrievalSearchMethodEnum.fullText ,
id : RetrievalSearchMethodEnum.fullText ,
icon : FullTextSearch as any ,
icon : FullTextSearch as any ,
title : 'Full-Text Search' ,
title : t ( 'dataset.retrieval.full_text_search.title' ) ,
description : 'Execute full-text search and vector searches simultaneously, re-rank to select the best match for the user\'s query. Users can choose to set weights or configure to a Rerank model.' ,
description : t ( 'dataset.retrieval.full_text_search.description' ) ,
effectColor : 'purple' ,
effectColor : 'purple' ,
}
}
} , [ ] )
} , [ t ] )
const HybridSearchOption : Option = useMemo ( ( ) = > {
const HybridSearchOption : Option = useMemo ( ( ) = > {
return {
return {
id : RetrievalSearchMethodEnum.hybrid ,
id : RetrievalSearchMethodEnum.hybrid ,
icon : HybridSearch as any ,
icon : HybridSearch as any ,
title : 'Hybrid Search' ,
title : t ( 'dataset.retrieval.hybrid_search.title' ) ,
description : 'Execute full-text search and vector searches simultaneously, re-rank to select the best match for the user\'s query. Users can choose to set weights or configure to a Rerank model.' ,
description : t ( 'dataset.retrieval.hybrid_search.description' ) ,
effectColor : 'purple' ,
effectColor : 'purple' ,
}
}
} , [ ] )
} , [ t ] )
const InvertedIndexOption : Option = useMemo ( ( ) = > {
const InvertedIndexOption : Option = useMemo ( ( ) = > {
return {
return {
id : RetrievalSearchMethodEnum.invertedIndex ,
id : RetrievalSearchMethodEnum.invertedIndex ,
icon : HybridSearch as any ,
icon : HybridSearch as any ,
title : 'Inverted Index' ,
title : t ( 'dataset.retrieval.invertedIndex.title' ) ,
description : 'Use inverted index to search for the most relevant text chunks.' ,
description : t ( 'dataset.retrieval.invertedIndex.description' ) ,
effectColor : 'purple' ,
effectColor : 'purple' ,
}
}
} , [ ] )
} , [ t ] )
const WeightedScoreModeOption : HybridSearchModeOption = useMemo ( ( ) = > {
const WeightedScoreModeOption : HybridSearchModeOption = useMemo ( ( ) = > {
return {
return {
id : HybridSearchModeEnum.WeightedScore ,
id : HybridSearchModeEnum.WeightedScore ,
title : 'Weighted Score' ,
title : t ( 'dataset.weightedScore.title' ) ,
description : 'By adjusting the weights assigned, this rerank strategy determines whether to prioritize semantic or keyword matching.' ,
description : t ( 'dataset.weightedScore.description' ) ,
}
}
} , [ ] )
} , [ t ] )
const RerankModelModeOption : HybridSearchModeOption = useMemo ( ( ) = > {
const RerankModelModeOption : HybridSearchModeOption = useMemo ( ( ) = > {
return {
return {
id : HybridSearchModeEnum.RerankingModel ,
id : HybridSearchModeEnum.RerankingModel ,
title : 'Rerank Model' ,
title : t ( 'common.modelProvider.rerankModel.key' ) ,
description : 'Rerank model will reorder the candidate document list based on the semantic match with user query, improving the results of semantic ranking.' ,
description : t ( 'common.modelProvider.rerankModel.tip' ) ,
}
}
} , [ ] )
} , [ t ] )
return useMemo ( ( ) = > ( {
return useMemo ( ( ) = > ( {
options : indexMethod === IndexMethodEnum . ECONOMICAL ? [
options : indexMethod === IndexMethodEnum . ECONOMICAL ? [