mirror of
https://github.com/langgenius/dify.git
synced 2026-04-27 02:36:29 +08:00
feat: update SettingsModal to integrate keyword number handling and refactor index method logic
This commit is contained in:
parent
3e5d9884cb
commit
aba48bde0b
@ -31,6 +31,7 @@ import {
|
|||||||
import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
||||||
import { fetchMembers } from '@/service/common'
|
import { fetchMembers } from '@/service/common'
|
||||||
import type { Member } from '@/models/common'
|
import type { Member } from '@/models/common'
|
||||||
|
import { IndexingType } from '@/app/components/datasets/create/step-two'
|
||||||
|
|
||||||
type SettingsModalProps = {
|
type SettingsModalProps = {
|
||||||
currentDataset: DataSet
|
currentDataset: DataSet
|
||||||
@ -54,8 +55,6 @@ const SettingsModal: FC<SettingsModalProps> = ({
|
|||||||
const { data: embeddingsModelList } = useModelList(ModelTypeEnum.textEmbedding)
|
const { data: embeddingsModelList } = useModelList(ModelTypeEnum.textEmbedding)
|
||||||
const {
|
const {
|
||||||
modelList: rerankModelList,
|
modelList: rerankModelList,
|
||||||
defaultModel: rerankDefaultModel,
|
|
||||||
currentModel: isRerankDefaultModelValid,
|
|
||||||
} = useModelListAndDefaultModelAndCurrentProviderAndModel(ModelTypeEnum.rerank)
|
} = useModelListAndDefaultModelAndCurrentProviderAndModel(ModelTypeEnum.rerank)
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { notify } = useToastContext()
|
const { notify } = useToastContext()
|
||||||
@ -73,6 +72,7 @@ const SettingsModal: FC<SettingsModalProps> = ({
|
|||||||
|
|
||||||
const [indexMethod, setIndexMethod] = useState(currentDataset.indexing_technique)
|
const [indexMethod, setIndexMethod] = useState(currentDataset.indexing_technique)
|
||||||
const [retrievalConfig, setRetrievalConfig] = useState(localeCurrentDataset?.retrieval_model_dict as RetrievalConfig)
|
const [retrievalConfig, setRetrievalConfig] = useState(localeCurrentDataset?.retrieval_model_dict as RetrievalConfig)
|
||||||
|
const [keywordNumber, setKeywordNumber] = useState(currentDataset.keyword_number ?? 10)
|
||||||
|
|
||||||
const handleValueChange = (type: string, value: string) => {
|
const handleValueChange = (type: string, value: string) => {
|
||||||
setLocaleCurrentDataset({ ...localeCurrentDataset, [type]: value })
|
setLocaleCurrentDataset({ ...localeCurrentDataset, [type]: value })
|
||||||
@ -124,6 +124,7 @@ const SettingsModal: FC<SettingsModalProps> = ({
|
|||||||
description,
|
description,
|
||||||
permission,
|
permission,
|
||||||
indexing_technique: indexMethod,
|
indexing_technique: indexMethod,
|
||||||
|
keyword_number: keywordNumber,
|
||||||
retrieval_model: {
|
retrieval_model: {
|
||||||
...retrievalConfig,
|
...retrievalConfig,
|
||||||
score_threshold: retrievalConfig.score_threshold_enabled ? retrievalConfig.score_threshold : 0,
|
score_threshold: retrievalConfig.score_threshold_enabled ? retrievalConfig.score_threshold : 0,
|
||||||
@ -248,13 +249,15 @@ const SettingsModal: FC<SettingsModalProps> = ({
|
|||||||
<IndexMethod
|
<IndexMethod
|
||||||
disabled={!localeCurrentDataset?.embedding_available}
|
disabled={!localeCurrentDataset?.embedding_available}
|
||||||
value={indexMethod}
|
value={indexMethod}
|
||||||
onChange={v => setIndexMethod(v!)}
|
onChange={setIndexMethod}
|
||||||
currentValue={currentDataset.indexing_technique}
|
currentValue={currentDataset.indexing_technique}
|
||||||
|
keywordNumber={keywordNumber}
|
||||||
|
onKeywordNumberChange={setKeywordNumber}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{indexMethod === 'high_quality' && (
|
{indexMethod === IndexingType.QUALIFIED && (
|
||||||
<div className={cn(rowClass)}>
|
<div className={cn(rowClass)}>
|
||||||
<div className={labelClass}>
|
<div className={labelClass}>
|
||||||
<div className='system-sm-semibold text-text-secondary'>{t('datasetSettings.form.embeddingModel')}</div>
|
<div className='system-sm-semibold text-text-secondary'>{t('datasetSettings.form.embeddingModel')}</div>
|
||||||
@ -333,7 +336,7 @@ const SettingsModal: FC<SettingsModalProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{indexMethod === 'high_quality'
|
{indexMethod === IndexingType.QUALIFIED
|
||||||
? (
|
? (
|
||||||
<RetrievalMethodConfig
|
<RetrievalMethodConfig
|
||||||
value={retrievalConfig}
|
value={retrievalConfig}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user