mirror of https://github.com/langgenius/dify.git
fix: not show rerank modal picker
This commit is contained in:
parent
257e795ca9
commit
045156985a
|
|
@ -37,9 +37,7 @@ const ConfigContent: FC<Props> = ({
|
|||
const {
|
||||
modelList: rerankModelList,
|
||||
defaultModel: rerankDefaultModel,
|
||||
currentModel: isRerankDefaultModelVaild,
|
||||
} = useModelListAndDefaultModelAndCurrentProviderAndModel(3)
|
||||
|
||||
const rerankModel = (() => {
|
||||
if (datasetConfigs.reranking_model) {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ const ParamItem: FC<Props> = ({ className, id, name, noTooltip, tip, step = 0.1,
|
|||
</div>
|
||||
<div className="mt-2 flex items-center">
|
||||
<div className="mr-4 flex shrink-0 items-center">
|
||||
<input disabled={!enable} type="number" min={min} max={max} step={step} className="block w-[48px] h-7 text-xs leading-[18px] rounded-lg border-0 pl-1 pl py-1.5 bg-gray-50 text-gray-900 placeholder:text-gray-400 focus:ring-1 focus:ring-inset focus:ring-primary-600 disabled:opacity-60" value={value} onChange={(e) => {
|
||||
<input disabled={!enable} type="number" min={min} max={max} step={step} className="block w-[48px] h-7 text-xs leading-[18px] rounded-lg border-0 pl-1 pl py-1.5 bg-gray-50 text-gray-900 placeholder:text-gray-400 focus:ring-1 focus:ring-inset focus:ring-primary-600 disabled:opacity-60" value={(value === null || value === undefined) ? '' : value} onChange={(e) => {
|
||||
const value = parseFloat(e.target.value)
|
||||
if (value < min || value > max)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ const ModelSelector: FC<ModelSelectorProps> = ({
|
|||
)
|
||||
}
|
||||
</PortalToFollowElemTrigger>
|
||||
<PortalToFollowElemContent className={`z-[60] ${popupClassName}`}>
|
||||
<PortalToFollowElemContent className={`z-[1002] ${popupClassName}`}>
|
||||
<Popup
|
||||
defaultModel={defaultModel}
|
||||
modelList={modelList}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import {
|
|||
} from '@/app/components/base/portal-to-follow-elem'
|
||||
import ConfigRetrievalContent from '@/app/components/app/configuration/dataset-config/params-config/config-content'
|
||||
import { RETRIEVE_TYPE } from '@/types/app'
|
||||
import { DATASET_DEFAULT } from '@/config'
|
||||
import { useModelListAndDefaultModelAndCurrentProviderAndModel } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
||||
|
||||
import type {
|
||||
DatasetConfigs,
|
||||
|
|
@ -35,6 +37,11 @@ const RetrievalConfig: FC<Props> = ({
|
|||
|
||||
const [open, setOpen] = useState(false)
|
||||
|
||||
const {
|
||||
defaultModel: rerankDefaultModel,
|
||||
currentModel: isRerankDefaultModelVaild,
|
||||
} = useModelListAndDefaultModelAndCurrentProviderAndModel(3)
|
||||
|
||||
const { multiple_retrieval_config } = payload
|
||||
const handleChange = useCallback((configs: DatasetConfigs, isRetrievalModeChange?: boolean) => {
|
||||
if (isRetrievalModeChange) {
|
||||
|
|
@ -43,11 +50,18 @@ const RetrievalConfig: FC<Props> = ({
|
|||
}
|
||||
onMultipleRetrievalConfigChange({
|
||||
top_k: configs.top_k,
|
||||
score_threshold: configs.score_threshold_enabled ? configs.score_threshold : null,
|
||||
reranking_model: {
|
||||
provider: configs.reranking_model?.reranking_provider_name,
|
||||
model: configs.reranking_model?.reranking_model_name,
|
||||
},
|
||||
score_threshold: configs.score_threshold_enabled ? (configs.score_threshold || DATASET_DEFAULT.score_threshold) : null,
|
||||
reranking_model: payload.retrieval_mode === RETRIEVE_TYPE.oneWay
|
||||
? undefined
|
||||
: (!configs.reranking_model?.reranking_provider_name
|
||||
? {
|
||||
provider: rerankDefaultModel?.provider?.provider || '',
|
||||
model: rerankDefaultModel?.model || '',
|
||||
}
|
||||
: {
|
||||
provider: configs.reranking_model?.reranking_provider_name,
|
||||
model: configs.reranking_model?.reranking_model_name,
|
||||
}),
|
||||
})
|
||||
}, [onRetrievalModeChange, onMultipleRetrievalConfigChange])
|
||||
|
||||
|
|
@ -75,13 +89,18 @@ const RetrievalConfig: FC<Props> = ({
|
|||
datasetConfigs={
|
||||
{
|
||||
retrieval_model: payload.retrieval_mode,
|
||||
reranking_model: {
|
||||
reranking_provider_name: multiple_retrieval_config?.reranking_model?.provider || '',
|
||||
reranking_model_name: multiple_retrieval_config?.reranking_model?.model || '',
|
||||
},
|
||||
top_k: multiple_retrieval_config?.top_k || 5,
|
||||
reranking_model: !multiple_retrieval_config?.reranking_model?.provider
|
||||
? {
|
||||
reranking_provider_name: rerankDefaultModel?.provider?.provider || '',
|
||||
reranking_model_name: rerankDefaultModel?.model || '',
|
||||
}
|
||||
: {
|
||||
reranking_provider_name: multiple_retrieval_config?.reranking_model?.provider || '',
|
||||
reranking_model_name: multiple_retrieval_config?.reranking_model?.model || '',
|
||||
},
|
||||
top_k: multiple_retrieval_config?.top_k || DATASET_DEFAULT.top_k,
|
||||
score_threshold_enabled: !(multiple_retrieval_config?.score_threshold === undefined || multiple_retrieval_config?.score_threshold === null),
|
||||
score_threshold: multiple_retrieval_config?.score_threshold || 0.5,
|
||||
score_threshold: multiple_retrieval_config?.score_threshold,
|
||||
datasets: {
|
||||
datasets: [],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export const mockData: KnowledgeRetrievalNodeType = {
|
|||
retrieval_mode: RETRIEVE_TYPE.oneWay,
|
||||
multiple_retrieval_config: {
|
||||
top_k: 10,
|
||||
score_threshold: 0.5,
|
||||
score_threshold: null,
|
||||
reranking_model: {
|
||||
provider: '',
|
||||
model: '',
|
||||
|
|
|
|||
|
|
@ -67,21 +67,22 @@ const Panel: FC = () => {
|
|||
type: 'string',
|
||||
description: t(`${i18nPrefix}.outputVars.content`),
|
||||
},
|
||||
// url, title, link like bing search reference result: link, link page title, link page icon
|
||||
{
|
||||
name: 'title',
|
||||
type: 'string',
|
||||
description: t(`${i18nPrefix}.outputVars.title`),
|
||||
},
|
||||
// {
|
||||
// name: 'url',
|
||||
// type: 'string',
|
||||
// description: t(`${i18nPrefix}.outputVars.url`)
|
||||
// },
|
||||
// {
|
||||
// name: 'icon',
|
||||
// type: 'string',
|
||||
// description: t(`${i18nPrefix}.outputVars.icon`)
|
||||
// },
|
||||
{
|
||||
name: 'url',
|
||||
type: 'string',
|
||||
description: t(`${i18nPrefix}.outputVars.url`),
|
||||
},
|
||||
{
|
||||
name: 'icon',
|
||||
type: 'string',
|
||||
description: t(`${i18nPrefix}.outputVars.icon`),
|
||||
},
|
||||
{
|
||||
name: 'metadata',
|
||||
type: 'object',
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import type { RETRIEVE_TYPE } from '@/types/app'
|
|||
export type MultipleRetrievalConfig = {
|
||||
top_k: number
|
||||
score_threshold: number | null | undefined
|
||||
reranking_model: {
|
||||
reranking_model?: {
|
||||
provider: string
|
||||
model: string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ const translation = {
|
|||
output: 'Retrieval segmented data',
|
||||
content: 'Segmented content',
|
||||
title: 'Segmented title',
|
||||
icon: 'Segmented icon',
|
||||
url: 'Segmented URL',
|
||||
metadata: 'Other metadata',
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ const translation = {
|
|||
output: '召回的分段',
|
||||
content: '分段内容',
|
||||
title: '分段标题',
|
||||
icon: '分段图标',
|
||||
url: '分段链接',
|
||||
metadata: '其他元数据',
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ export type DatasetConfigs = {
|
|||
}
|
||||
top_k: number
|
||||
score_threshold_enabled: boolean
|
||||
score_threshold: number
|
||||
score_threshold?: number | null
|
||||
datasets: {
|
||||
datasets: {
|
||||
enabled: boolean
|
||||
|
|
|
|||
Loading…
Reference in New Issue