Implementation:Langgenius Dify UpdateAppModelConfig
| Knowledge Sources | Domains | Last Updated |
|---|---|---|
| Dify | LLM_Applications, Frontend, API | 2026-02-12 00:00 GMT |
Overview
Description
updateAppModelConfig is the frontend service function for persisting changes to an application's model configuration. It sends a POST request to a dynamically constructed URL (typically apps/{appId}/model-config) with the full model configuration body. The function accepts a generic Record<string, any> body to accommodate the varying shapes of model configuration across different application modes and LLM providers.
The body payload corresponds to the ModelConfig type, which encompasses the LLM provider, model ID, model mode, prompt configuration, completion parameters, feature toggles (speech-to-text, text-to-speech, more-like-this, suggested questions), dataset configurations, agent settings, and file upload settings.
Usage
Call updateAppModelConfig after modifying any aspect of the application's model or prompt configuration in the UI. This function persists the complete configuration state to the backend. It is typically invoked when the user saves changes in the application configuration panel.
Code Reference
Source Location
web/service/apps.ts, lines 156-158
Signature
export const updateAppModelConfig = (
{ url, body }: { url: string, body: Record<string, any> }
): Promise<UpdateAppModelConfigResponse> => {
return post<UpdateAppModelConfigResponse>(url, { body })
}
Import
import { updateAppModelConfig } from '@/service/apps'
I/O Contract
Inputs
| Parameter | Type | Required | Description |
|---|---|---|---|
| url | string |
Yes | The API endpoint URL, typically apps/{appId}/model-config.
|
| body | Record<string, any> |
Yes | The full model configuration payload. Key properties include those described below. |
Key properties within the body (ModelConfig shape):
| Property | Type | Description |
|---|---|---|
| provider | string |
The LLM provider identifier (e.g., 'openai', 'anthropic', 'azure_openai').
|
| model_id | string |
The specific model name (e.g., 'gpt-3.5-turbo', 'gpt-4').
|
| mode | ModelModeType |
The model interaction mode: 'chat' or 'completion'.
|
| configs | PromptConfig |
The prompt template and variable definitions: { prompt_template: string, prompt_variables: PromptVariable[] }.
|
| completion_params | CompletionParams |
Inference parameters: max_tokens, temperature (0-2), top_p (0-1), presence_penalty (-2 to 2), frequency_penalty (-2 to 2), stop (string[]).
|
| chat_prompt_config | null | Chat-mode prompt messages array. Each entry has role and text.
|
| completion_prompt_config | null | Completion-mode prompt with conversation history role configuration. |
| opening_statement | null | Initial greeting message for chat applications. |
| more_like_this | null | Toggle for generating alternative responses. |
| suggested_questions_after_answer | null | Toggle for suggesting follow-up questions. |
| speech_to_text | null | Toggle for speech-to-text input. |
| text_to_speech | null | Text-to-speech output configuration. |
| dataset_configs | DatasetConfigs |
Retrieval strategy and connected dataset list. |
| agentConfig | AgentConfig |
Agent mode settings including strategy (function_call or react), max iterations, and tool list.
|
Outputs
| Field | Type | Description |
|---|---|---|
| (return) | Promise<UpdateAppModelConfigResponse> |
Resolves to { result: string } indicating the outcome of the update operation (e.g., 'success').
|
Usage Examples
Updating model selection and completion parameters
import { updateAppModelConfig } from '@/service/apps'
const response = await updateAppModelConfig({
url: `apps/${appId}/model-config`,
body: {
provider: 'openai',
model_id: 'gpt-4',
mode: 'chat',
configs: {
prompt_template: 'You are a helpful assistant specializing in {{domain}}.',
prompt_variables: [
{ key: 'domain', name: 'Domain', type: 'string', required: true },
],
},
completion_params: {
max_tokens: 2048,
temperature: 0.7,
top_p: 0.95,
presence_penalty: 0.0,
frequency_penalty: 0.0,
},
opening_statement: 'Hello! How can I help you today?',
more_like_this: { enabled: false },
suggested_questions_after_answer: { enabled: true },
speech_to_text: { enabled: false },
text_to_speech: { enabled: false },
},
})
console.log(response.result) // 'success'