From 4af71b5b52e0ca7cbb0b39b603f0c3e1a1f4986e Mon Sep 17 00:00:00 2001 From: jialin Date: Fri, 31 Oct 2025 17:34:01 +0800 Subject: [PATCH] chore: speculative_config init in updating --- .../llmodels/components/update-modal.tsx | 7 ++++++- .../llmodels/forms/speculative-decode.tsx | 20 +++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/pages/llmodels/components/update-modal.tsx b/src/pages/llmodels/components/update-modal.tsx index 95a30fe5..d146d55c 100644 --- a/src/pages/llmodels/components/update-modal.tsx +++ b/src/pages/llmodels/components/update-modal.tsx @@ -70,7 +70,12 @@ const UpdateModal: React.FC = (props) => { enabled: false }; } - // TODO: set speculative_config + + if (!originFormData.current.speculative_config?.enabled) { + originFormData.current.speculative_config = { + enabled: false + }; + } } }; diff --git a/src/pages/llmodels/forms/speculative-decode.tsx b/src/pages/llmodels/forms/speculative-decode.tsx index 7f9bd6f5..f660dec3 100644 --- a/src/pages/llmodels/forms/speculative-decode.tsx +++ b/src/pages/llmodels/forms/speculative-decode.tsx @@ -6,7 +6,7 @@ import SealSelect from '@/components/seal-form/seal-select'; import useAppUtils from '@/hooks/use-app-utils'; import { useIntl } from '@umijs/max'; import { Form } from 'antd'; -import { useEffect, useState } from 'react'; +import { useEffect, useRef, useState } from 'react'; import { queryDraftModelList } from '../apis'; import { FormData } from '../config/types'; @@ -28,6 +28,7 @@ const SpeculativeDecode = () => { const [draftModelList, setDraftModelList] = useState< Global.BaseOption[] >([]); + const speculativeConfigRef = useRef({}); const fetchDraftModels = async () => { const response = await queryDraftModelList({ @@ -42,17 +43,20 @@ const SpeculativeDecode = () => { }; const handleSpeculativeEnabledChange = (e: any) => { - const speculativeConfig = form.getFieldValue('speculative_config'); - if (e.target.checked) { form.setFieldValue('speculative_config', { enabled: true, - algorithm: speculativeConfig.algorithm || AlgorithmMap.Eagle3, - draft_model: speculativeConfig.draft_model || '', - num_draft_tokens: speculativeConfig.num_draft_tokens || 3, - ngram_min_match_length: speculativeConfig.ngram_min_match_length || 1, - ngram_max_match_length: speculativeConfig.ngram_max_match_length || 10 + algorithm: + speculativeConfigRef.current.algorithm || AlgorithmMap.Eagle3, + draft_model: speculativeConfigRef.current.draft_model || '', + num_draft_tokens: speculativeConfigRef.current.num_draft_tokens || 3, + ngram_min_match_length: + speculativeConfigRef.current.ngram_min_match_length || 1, + ngram_max_match_length: + speculativeConfigRef.current.ngram_max_match_length || 10 }); + } else { + speculativeConfigRef.current = form.getFieldValue('speculative_config'); } };