import type { IThinkingModelParams } from '@/service/modelConfig'; import { updateThinkingConfig } from '@/service/modelConfig'; import { useModelConfigStore } from '@/store/useModelConfigStore'; import { Input, message, Modal } from 'antd'; import { useEffect, useState } from 'react'; interface IProps { open: boolean; onClose: () => void; } const ThinkingModelModal = (props: IProps) => { const { open, onClose: handleCancel } = props; const fetchModelConfig = useModelConfigStore((store) => store.fetchModelConfig); const [thinkingModelParams, setThinkingModelParams] = useState( {} as IThinkingModelParams ); const updateThinkingModelConfig = useModelConfigStore((store) => store.updateThinkingModelConfig); const thinkingModelConfig = useModelConfigStore((store) => store.thinkingModelConfig); useEffect(() => { if (open) { fetchModelConfig(); } }, [open]); useEffect(() => { setThinkingModelParams(thinkingModelConfig); }, [thinkingModelConfig]); const handleUpdate = () => { const thinkingConfigComplete = !!thinkingModelParams.thinking_model_name && !!thinkingModelParams.thinking_api_key && !!thinkingModelParams.thinking_endpoint; if (!thinkingConfigComplete) { message.error('Please fill in all thinking model configuration fields'); return; } updateThinkingConfig(thinkingModelParams) .then((res) => { if (res.data.code == 0) { updateThinkingModelConfig(thinkingModelParams); handleCancel(); } else { throw new Error(res.data.message); } }) .catch((error) => { console.error(error.message || 'Failed to update model config'); }); }; return ( { handleUpdate(); }} open={open} >
Thinking model
Currently only supports DeepSeek
setThinkingModelParams({ ...thinkingModelParams, thinking_model_name: e.target.value }) } value={thinkingModelParams.thinking_model_name} />
{/* form is to disable autoComplete */}
setThinkingModelParams({ ...thinkingModelParams, thinking_api_key: e.target.value }) } value={thinkingModelParams.thinking_api_key} />
setThinkingModelParams({ ...thinkingModelParams, thinking_endpoint: e.target.value }) } value={thinkingModelParams.thinking_endpoint} />
); }; export default ThinkingModelModal;