Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor(web): migrate code generator model storage (#37195)
lmlmd80bd2a135a0
diff --git a/eslint-suppressions.json b/eslint-suppressions.jsonindex 1ae2aea3289..39e800e1ba2 100644--- a/eslint-suppressions.json+++ b/eslint-suppressions.json@@ -438,9 +438,6 @@}},"web/app/components/app/configuration/config/code-generator/get-code-generator-res.tsx": {- "no-restricted-globals": {- "count": 6- },"react/set-state-in-effect": {"count": 4},diff --git a/web/app/components/app/configuration/config/code-generator/get-code-generator-res.tsx b/web/app/components/app/configuration/config/code-generator/get-code-generator-res.tsxindex b5e0444510f..ccc2bd4ead3 100644--- a/web/app/components/app/configuration/config/code-generator/get-code-generator-res.tsx+++ b/web/app/components/app/configuration/config/code-generator/get-code-generator-res.tsx@@ -27,6 +27,7 @@ import Loading from '@/app/components/base/loading'import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'import { useModelListAndDefaultModelAndCurrentProviderAndModel } from '@/app/components/header/account-setting/model-provider-page/hooks'import ModelParameterModal from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal'+import { useLocalStorage } from '@/hooks/use-local-storage'import { generateRule } from '@/service/debug'import { useGenerateRuleTemplate } from '@/service/use-apps'import { languageMap } from '../../../../workflow/nodes/_base/components/editor/code-editor/index'@@ -39,6 +40,17 @@ import { GeneratorType } from '../automatic/types'import useGenData from '../automatic/use-gen-data'const i18nPrefix = 'generate'+const AUTO_GEN_MODEL_STORAGE_KEY = 'auto-gen-model'+const defaultCompletionParams = {+ temperature: 0.7,+ max_tokens: 0,+ top_p: 0,+ echo: false,+ stop: [],+ presence_penalty: 0,+ frequency_penalty: 0,+}+type IGetCodeGeneratorResProps = {flowId: stringnodeId: string@@ -63,19 +75,8 @@ export const GetCodeGeneratorResModal: FC<IGetCodeGeneratorResProps> = (},) => {const { t } = useTranslation()- const defaultCompletionParams = {- temperature: 0.7,- max_tokens: 0,- top_p: 0,- echo: false,- stop: [],- presence_penalty: 0,- frequency_penalty: 0,- }- const localModel = localStorage.getItem('auto-gen-model')- ? JSON.parse(localStorage.getItem('auto-gen-model') as string) as Model- : null- const [model, setModel] = React.useState<Model>(localModel || {+ const [storedModel, setStoredModel] = useLocalStorage<Model>(AUTO_GEN_MODEL_STORAGE_KEY)+ const [model, setModel] = React.useState<Model>(storedModel || {name: '',provider: '',mode: mode as unknown as ModelModeType,@@ -122,8 +123,8 @@ export const GetCodeGeneratorResModal: FC<IGetCodeGeneratorResProps> = (mode: newValue.mode as ModelModeType,}setModel(newModel)- localStorage.setItem('auto-gen-model', JSON.stringify(newModel))- }, [model, setModel])+ setStoredModel(newModel)+ }, [model, setModel, setStoredModel])const handleCompletionParamsChange = useCallback((newParams: FormValue) => {const newModel = {@@ -131,8 +132,8 @@ export const GetCodeGeneratorResModal: FC<IGetCodeGeneratorResProps> = (completion_params: newParams as CompletionParams,}setModel(newModel)- localStorage.setItem('auto-gen-model', JSON.stringify(newModel))- }, [model, setModel])+ setStoredModel(newModel)+ }, [model, setModel, setStoredModel])const onGenerate = async () => {if (!isValid())@@ -172,15 +173,12 @@ export const GetCodeGeneratorResModal: FC<IGetCodeGeneratorResProps> = (useEffect(() => {if (defaultModel) {- const localModel = localStorage.getItem('auto-gen-model')- ? JSON.parse(localStorage.getItem('auto-gen-model') || '')- : null- if (localModel) {+ if (storedModel) {setModel({- ...localModel,+ ...storedModel,completion_params: {...defaultCompletionParams,- ...localModel.completion_params,+ ...storedModel.completion_params,},})}@@ -192,7 +190,7 @@ export const GetCodeGeneratorResModal: FC<IGetCodeGeneratorResProps> = (}))}}- }, [defaultModel])+ }, [defaultModel, storedModel])const renderLoading = (<div className="flex h-full w-0 grow flex-col items-center justify-center space-y-3">