fix: retrieval weights default value

This commit is contained in:
StyleZhang 2024-10-22 16:23:00 +08:00
parent 9afa22a11b
commit a46a9d346f
5 changed files with 8 additions and 8 deletions

View File

@ -44,13 +44,13 @@ const DatasetConfig: FC = () => {
const hasData = dataSet.length > 0
const {
isValid: isValidRerankModel,
currentModel: currentRerankModel,
} = useModelListAndDefaultModelAndCurrentProviderAndModel(ModelTypeEnum.rerank)
const onRemove = (id: string) => {
const filteredDataSets = dataSet.filter(item => item.id !== id)
setDataSet(filteredDataSets)
const retrievalConfig = getMultipleRetrievalConfig(datasetConfigs as any, filteredDataSets, dataSet, isValidRerankModel)
const retrievalConfig = getMultipleRetrievalConfig(datasetConfigs as any, filteredDataSets, dataSet, !!currentRerankModel)
setDatasetConfigs({
...(datasetConfigs as any),
...retrievalConfig,

View File

@ -221,7 +221,7 @@ const Configuration: FC = () => {
const selectedIds = dataSets.map(item => item.id)
const [rerankSettingModalOpen, setRerankSettingModalOpen] = useState(false)
const {
isValid: isValidRerankModel,
currentModel: currentRerankModel,
} = useModelListAndDefaultModelAndCurrentProviderAndModel(ModelTypeEnum.rerank)
const handleSelect = (data: DataSet[]) => {
if (isEqual(data.map(item => item.id), dataSets.map(item => item.id))) {
@ -269,7 +269,7 @@ const Configuration: FC = () => {
reranking_mode: restConfigs.reranking_mode,
weights: restConfigs.weights,
reranking_enable: restConfigs.reranking_enable,
}, newDatasets, dataSets, isValidRerankModel)
}, newDatasets, dataSets, !!currentRerankModel)
setDatasetConfigs({
...retrievalConfig,

View File

@ -180,7 +180,6 @@ export const useModelListAndDefaultModelAndCurrentProviderAndModel = (type: Mode
defaultModel,
currentProvider,
currentModel,
isValid: !!modelList.find(provider => provider.provider === currentProvider?.provider && provider.models.find(model => model.model === currentModel?.model)),
}
}

View File

@ -63,7 +63,6 @@ const useConfig = (id: string, payload: KnowledgeRetrievalNodeType) => {
const {
modelList: rerankModelList,
defaultModel: rerankDefaultModel,
isValid: isValidRerankModel,
} = useModelListAndDefaultModelAndCurrentProviderAndModel(ModelTypeEnum.rerank)
const {
@ -232,7 +231,7 @@ const useConfig = (id: string, payload: KnowledgeRetrievalNodeType) => {
if (payload.retrieval_mode === RETRIEVE_TYPE.multiWay && newDatasets.length > 0) {
const multipleRetrievalConfig = draft.multiple_retrieval_config
draft.multiple_retrieval_config = getMultipleRetrievalConfig(multipleRetrievalConfig!, newDatasets, selectedDatasets, isValidRerankModel)
draft.multiple_retrieval_config = getMultipleRetrievalConfig(multipleRetrievalConfig!, newDatasets, selectedDatasets, !!currentRerankModel)
}
})
setInputs(newInputs)
@ -244,7 +243,7 @@ const useConfig = (id: string, payload: KnowledgeRetrievalNodeType) => {
|| (allExternal && newDatasets.length > 1)
)
setRerankModelOpen(true)
}, [inputs, setInputs, payload.retrieval_mode, selectedDatasets, isValidRerankModel])
}, [inputs, setInputs, payload.retrieval_mode, selectedDatasets, currentRerankModel])
const filterVar = useCallback((varPayload: Var) => {
return varPayload.type === VarType.string

View File

@ -158,6 +158,8 @@ export const getMultipleRetrievalConfig = (
if (shouldSetWeightDefaultValue && allHighQuality && !inconsistentEmbeddingModel && (reranking_mode === RerankingModeEnum.WeightedScore || reranking_mode === undefined || !isValidRerankModel) && allInternal && weights) {
if (!isValidRerankModel)
result.reranking_mode = RerankingModeEnum.WeightedScore
else
result.reranking_mode = RerankingModeEnum.RerankingModel
result.weights = {
vector_setting: {