Skip to content

armgit / dify

Public Imported from GitHub
0

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.

feat: Retain llm setting for agent node (#21842)

Kalo Chin4e7c9dd2ae0b
diff --git a/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx b/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx
index 60c63db5eae..51702a780a6 100644
--- a/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx
@@ -25,6 +25,8 @@ import LLMParamsPanel from './llm-params-panel'
import TTSParamsPanel from './tts-params-panel'
import { useProviderContext } from '@/context/provider-context'
import cn from '@/utils/classnames'
+import Toast from '@/app/components/base/toast'
+import { fetchAndMergeValidCompletionParams } from '@/utils/completion-params'
export type ModelParameterModalProps = {
popupClassName?: string
@@ -121,17 +123,42 @@ const ModelParameterModal: FC<ModelParameterModalProps> = ({
return !isAPIKeySet || hasDeprecated || modelDisabled
}, [hasDeprecated, isAPIKeySet, modelDisabled])
- const handleChangeModel = ({ provider, model }: DefaultModel) => {
+ const handleChangeModel = async ({ provider, model }: DefaultModel) => {
const targetProvider = scopedModelList.find(modelItem => modelItem.provider === provider)
const targetModelItem = targetProvider?.models.find((modelItem: { model: string }) => modelItem.model === model)
const model_type = targetModelItem?.model_type as string
+
+ let nextCompletionParams: FormValue = {}
+
+ if (model_type === ModelTypeEnum.textGeneration) {
+ try {
+ const { params: filtered, removedDetails } = await fetchAndMergeValidCompletionParams(
+ provider,
+ model,
+ value?.completion_params,
+ )
+ nextCompletionParams = filtered
+
+ const keys = Object.keys(removedDetails || {})
+ if (keys.length) {
+ Toast.notify({
+ type: 'warning',
+ message: `${t('common.modelProvider.parametersInvalidRemoved')}: ${keys.map(k => `${k} (${removedDetails[k]})`).join(', ')}`,
+ })
+ }
+ }
+ catch (e) {
+ Toast.notify({ type: 'error', message: t('common.error') })
+ }
+ }
+
setModel({
provider,
model,
model_type,
...(model_type === ModelTypeEnum.textGeneration ? {
mode: targetModelItem?.model_properties.mode as string,
- completion_params: {},
+ completion_params: nextCompletionParams,
} : {}),
})
}