feat: Retain LLM Configuration Settings When Changing Model (#21247)

This commit is contained in:
Kalo Chin
2025-07-01 12:32:46 +09:00
committed by GitHub
parent b8b9c3a783
commit 1b99e44e99
3 changed files with 128 additions and 5 deletions

View File

@@ -19,6 +19,8 @@ import Editor from '@/app/components/workflow/nodes/_base/components/prompt/edit
import StructureOutput from './components/structure-output'
import Switch from '@/app/components/base/switch'
import { RiAlertFill, RiQuestionLine } from '@remixicon/react'
import { fetchAndMergeValidCompletionParams } from '@/utils/completion-params'
import Toast from '@/app/components/base/toast'
const i18nPrefix = 'workflow.nodes.llm'
@@ -68,10 +70,27 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
modelId: string
mode?: string
}) => {
handleCompletionParamsChange({})
handleModelChanged(model)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
(async () => {
try {
const { params: filtered, removedDetails } = await fetchAndMergeValidCompletionParams(
model.provider,
model.modelId,
inputs.model.completion_params,
)
const keys = Object.keys(removedDetails)
if (keys.length)
Toast.notify({ type: 'warning', message: `${t('common.modelProvider.parametersInvalidRemoved')}: ${keys.map(k => `${k} (${removedDetails[k]})`).join(', ')}` })
handleCompletionParamsChange(filtered)
}
catch (e) {
Toast.notify({ type: 'error', message: t('common.error') })
handleCompletionParamsChange({})
}
finally {
handleModelChanged(model)
}
})()
}, [inputs.model.completion_params])
return (
<div className='mt-2'>