fix: model parameter default value (#3841)

This commit is contained in:
zxhlyh 2024-04-25 18:04:37 +08:00 committed by GitHub
parent 12435774ca
commit cde87cb225
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,7 +2,7 @@ import type {
FC,
ReactNode,
} from 'react'
import { useEffect, useMemo, useState } from 'react'
import { useMemo, useState } from 'react'
import useSWR from 'swr'
import { useTranslation } from 'react-i18next'
import cn from 'classnames'
@ -16,7 +16,6 @@ import ModelSelector from '../model-selector'
import {
useTextGenerationCurrentProviderAndModelAndModelList,
} from '../hooks'
import { isNullOrUndefined } from '../utils'
import ParameterItem from './parameter-item'
import type { ParameterValue } from './parameter-item'
import Trigger from './trigger'
@ -139,26 +138,6 @@ const ModelParameterModal: FC<ModelParameterModalProps> = ({
}
}
const handleInitialParams = () => {
const newCompletionParams = { ...completionParams }
if (parameterRules.length) {
parameterRules.forEach((parameterRule) => {
if (!newCompletionParams[parameterRule.name]) {
if (!isNullOrUndefined(parameterRule.default))
newCompletionParams[parameterRule.name] = parameterRule.default
else
delete newCompletionParams[parameterRule.name]
}
})
onCompletionParamsChange(newCompletionParams)
}
}
useEffect(() => {
handleInitialParams()
}, [parameterRules])
const handleSelectPresetParameter = (toneId: number) => {
const tone = TONE_LIST.find(tone => tone.id === toneId)
if (tone) {