菜单

应用配置

相关源文件

本文档介绍了 Dify 网页前端的应用配置界面,这是配置 AI 应用的主要界面,包括模型设置、提示词、数据集、功能以及调试工具。该界面允许用户在发布前设置和微调他们的应用。

有关后端应用管理系统的信息,请参阅 应用管理。有关聊天和对话界面的详细信息,请参阅 聊天和对话界面

配置界面架构

应用配置界面围绕一个集中的配置组件构建,该组件管理多个配置面板和一个用于测试应用的调试界面。

主配置组件结构

来源: web/app/components/app/configuration/index.tsx1-1157 web/context/debug-configuration.ts1-264

配置数据流

来源: web/app/components/app/configuration/index.tsx515-677 web/app/components/app/configuration/debug/index.tsx202-301

配置组件

模型配置

模型配置管理 LLM 提供商设置、模型选择和完成参数。

配置类型组件目的
模型选择modelConfig.provider, modelConfig.model_id选择 LLM 提供商和特定模型
模型模式modelConfig.mode聊天或完成模式
完成参数completionParams温度、最大 token 数、top-p 等。
视觉设置visionConfig图片上传和处理设置

来源: web/app/components/app/configuration/index.tsx176-224 web/app/components/app/configuration/index.tsx419-457

提示词配置

系统支持两种提示词模式:简单模式和高级模式。

来源: web/app/components/app/configuration/index.tsx365-376 web/app/components/app/configuration/hooks/use-advanced-prompt-config

数据集配置

数据集配置管理知识库集成和检索设置。

设置类型描述
dataSetsDataSet[]选定的知识库
datasetConfigs.retrieval_modelRETRIEVE_TYPE检索策略(multiWay 等)
datasetConfigs.top_k数字检索到的 Top k 条结果数
datasetConfigs.score_threshold数字最小相似度分数
datasetConfigs.reranking_model对象重排模型配置

来源: web/app/components/app/configuration/index.tsx202-219 web/app/components/app/configuration/index.tsx241-309

功能配置

Features 系统通过 FeaturesProvider 管理可选的应用功能。

来源: web/app/components/app/configuration/index.tsx463-492 web/app/components/base/features/types

调试界面

调试界面提供发布前应用的测试能力。

调试组件架构

来源: web/app/components/app/configuration/debug/index.tsx1-562

调试工作流程

调试界面会验证输入并将测试请求发送到 API。

验证步骤功能目的
输入验证checkCanSend()验证所需的提示词变量
数据集上下文hasSetContextVar确保已设置上下文变量
API 密钥检查isAPIKeySet验证模型提供商凭据
文件上传completionFiles 验证检查文件上传完成情况

来源: web/app/components/app/configuration/debug/index.tsx144-195 web/app/components/app/configuration/debug/index.tsx202-316

状态管理

配置上下文

ConfigContext 提供所有配置数据的集中式状态管理。

来源: web/context/debug-configuration.ts31-107

状态同步

配置更改会触发格式更改通知和验证更新。

状态变更触发器效果
模型配置setModelConfig()更新完成参数、视觉配置
数据集选择handleSelect()重新计算检索配置
功能开关handleFeaturesChange()显示功能配置模态框
提示词模式setPromptMode()在简单/高级提示词之间切换

来源: web/app/components/app/configuration/index.tsx221-223 web/app/components/app/configuration/index.tsx493-497

配置工作流程

应用加载与设置

来源: web/app/components/app/configuration/index.tsx515-677

发布配置

发布工作流会验证配置并将更新发送到后端。

步骤验证操作
1. 验证提示词promptEmpty, cannotPublish检查空提示词
2. 验证上下文contextVarEmpty确保数据集上下文变量
3. 构建载荷BackendModelConfig创建 API 载荷
4. 发送更新updateAppModelConfig()更新后端配置
5. 更新状态setPublishedConfig()同步本地状态

来源: web/app/components/app/configuration/index.tsx713-808