mirror of
https://github.com/langgenius/dify.git
synced 2026-04-13 22:57:26 +08:00
Merge branch 'feat/rag-2' of https://github.com/langgenius/dify into feat/rag-2
This commit is contained in:
commit
cc911f46f2
@ -639,7 +639,8 @@ class PipelineGenerator(BaseAppGenerator):
|
||||
raise GenerateTaskStoppedError()
|
||||
else:
|
||||
logger.exception(
|
||||
f"Fails to process generate task pipeline, task_id: {application_generate_entity.task_id}"
|
||||
"Fails to process generate task pipeline, task_id: %r",
|
||||
application_generate_entity.task_id,
|
||||
)
|
||||
raise e
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ def generate_provider_name(
|
||||
f"{credential_type.get_name()}",
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(f"Error generating next provider name for {fallback_context}: {str(e)}")
|
||||
logger.warning("Error generating next provider name for %r: %r", fallback_context, e)
|
||||
return f"{credential_type.get_name()} 1"
|
||||
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ class RemotePipelineTemplateRetrieval(PipelineTemplateRetrievalBase):
|
||||
try:
|
||||
result = self.fetch_pipeline_template_detail_from_dify_official(pipeline_id)
|
||||
except Exception as e:
|
||||
logger.warning(f"fetch recommended app detail from dify official failed: {e}, switch to built-in.")
|
||||
logger.warning("fetch recommended app detail from dify official failed: %r, switch to built-in.", e)
|
||||
result = BuildInRecommendAppRetrieval.fetch_recommended_app_detail_from_builtin(pipeline_id)
|
||||
return result
|
||||
|
||||
@ -28,7 +28,7 @@ class RemotePipelineTemplateRetrieval(PipelineTemplateRetrievalBase):
|
||||
try:
|
||||
result = self.fetch_pipeline_templates_from_dify_official(language)
|
||||
except Exception as e:
|
||||
logger.warning(f"fetch pipeline templates from dify official failed: {e}, switch to built-in.")
|
||||
logger.warning("fetch pipeline templates from dify official failed: %r, switch to built-in.", e)
|
||||
result = BuildInRecommendAppRetrieval.fetch_recommended_apps_from_builtin(language)
|
||||
return result
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ export const useRetrievalSetting = (indexMethod?: IndexMethodEnum) => {
|
||||
}, [t])
|
||||
const InvertedIndexOption: Option = useMemo(() => {
|
||||
return {
|
||||
id: RetrievalSearchMethodEnum.keywordSearch,
|
||||
id: RetrievalSearchMethodEnum.invertedIndex,
|
||||
icon: HybridSearch as any,
|
||||
title: t('dataset.retrieval.invertedIndex.title'),
|
||||
description: t('dataset.retrieval.invertedIndex.description'),
|
||||
|
||||
@ -194,7 +194,7 @@ const SearchMethodOption = ({
|
||||
isScoreThresholdEnabled={isScoreThresholdEnabled}
|
||||
onScoreThresholdEnabledChange={onScoreThresholdEnabledChange}
|
||||
readonly={readonly}
|
||||
hiddenScoreThreshold={searchMethod === RetrievalSearchMethodEnum.keywordSearch}
|
||||
hiddenScoreThreshold={searchMethod === RetrievalSearchMethodEnum.invertedIndex}
|
||||
/>
|
||||
</div>
|
||||
</OptionCard>
|
||||
|
||||
@ -15,6 +15,7 @@ import type {
|
||||
KnowledgeBaseNodeType,
|
||||
RerankingModel,
|
||||
} from '../types'
|
||||
import { isHighQualitySearchMethod } from '../utils'
|
||||
|
||||
export const useConfig = (id: string) => {
|
||||
const store = useStoreApi()
|
||||
@ -36,10 +37,18 @@ export const useConfig = (id: string) => {
|
||||
|
||||
const handleChunkStructureChange = useCallback((chunkStructure: ChunkStructureEnum) => {
|
||||
const nodeData = getNodeData()
|
||||
const { indexing_technique } = nodeData?.data
|
||||
const {
|
||||
indexing_technique,
|
||||
retrieval_model,
|
||||
} = nodeData?.data
|
||||
const { search_method } = retrieval_model || {}
|
||||
handleNodeDataUpdate({
|
||||
chunk_structure: chunkStructure,
|
||||
indexing_technique: (chunkStructure === ChunkStructureEnum.parent_child || chunkStructure === ChunkStructureEnum.question_answer) ? IndexMethodEnum.QUALIFIED : indexing_technique,
|
||||
retrieval_model: {
|
||||
...retrieval_model,
|
||||
search_method: ((chunkStructure === ChunkStructureEnum.parent_child || chunkStructure === ChunkStructureEnum.question_answer) && !isHighQualitySearchMethod(search_method)) ? RetrievalSearchMethodEnum.semantic : search_method,
|
||||
},
|
||||
})
|
||||
}, [handleNodeDataUpdate, getNodeData])
|
||||
|
||||
@ -50,7 +59,7 @@ export const useConfig = (id: string) => {
|
||||
draft.indexing_technique = indexMethod
|
||||
|
||||
if (indexMethod === IndexMethodEnum.ECONOMICAL)
|
||||
draft.retrieval_model.search_method = RetrievalSearchMethodEnum.keywordSearch
|
||||
draft.retrieval_model.search_method = RetrievalSearchMethodEnum.invertedIndex
|
||||
else if (indexMethod === IndexMethodEnum.QUALIFIED)
|
||||
draft.retrieval_model.search_method = RetrievalSearchMethodEnum.semantic
|
||||
}))
|
||||
|
||||
@ -13,6 +13,6 @@ export const useSettingsDisplay = () => {
|
||||
[RetrievalSearchMethodEnum.semantic]: t('dataset.retrieval.semantic_search.title'),
|
||||
[RetrievalSearchMethodEnum.fullText]: t('dataset.retrieval.full_text_search.title'),
|
||||
[RetrievalSearchMethodEnum.hybrid]: t('dataset.retrieval.hybrid_search.title'),
|
||||
[RetrievalSearchMethodEnum.keywordSearch]: t('dataset.retrieval.invertedIndex.title'),
|
||||
[RetrievalSearchMethodEnum.invertedIndex]: t('dataset.retrieval.invertedIndex.title'),
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
import {
|
||||
RetrievalSearchMethodEnum,
|
||||
} from './types'
|
||||
|
||||
export const isHighQualitySearchMethod = (searchMethod: RetrievalSearchMethodEnum) => {
|
||||
return searchMethod === RetrievalSearchMethodEnum.semantic
|
||||
|| searchMethod === RetrievalSearchMethodEnum.hybrid
|
||||
|| searchMethod === RetrievalSearchMethodEnum.fullText
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user