From 460238c715d846070bf91a6577775c7e47c45527 Mon Sep 17 00:00:00 2001 From: StyleZhang Date: Tue, 2 Jan 2024 20:06:50 +0800 Subject: [PATCH] fix: model-parameter inital value --- .../model-parameter-modal/index.tsx | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/web/app/components/header/account-setting/model-provider-page/model-parameter-modal/index.tsx b/web/app/components/header/account-setting/model-provider-page/model-parameter-modal/index.tsx index 8f32ea0ed1e770..aed8a5b1ce980b 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-parameter-modal/index.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-parameter-modal/index.tsx @@ -1,5 +1,5 @@ import type { FC } from 'react' -import { useMemo, useState } from 'react' +import { useEffect, useMemo, useState } from 'react' import useSWR from 'swr' import { useTranslation } from 'react-i18next' import type { @@ -122,6 +122,22 @@ const ModelParameterModal: FC = ({ } } + const handleInitialParams = () => { + if (parameterRules.length) { + const newCompletionParams = { ...completionParams } + Object.keys(newCompletionParams).forEach((key) => { + if (!parameterRules.find(item => item.name === key)) + delete newCompletionParams[key] + }) + + onCompletionParamsChange(newCompletionParams) + } + } + + useEffect(() => { + handleInitialParams() + }, [parameterRules]) + return ( = ({ } { isLoading && ( - +
) } {