feat: 引入LLM场景路由与后台拓扑管理能力

变更项:

1. 新增 llm.scenes 场景路由层,支持 scene->backend 统一映射,并补充默认场景配置。

2. 扩展 LLMRegistry,新增 scene 解析逻辑;当声明 scene 时强制按场景路由结果生效,保持旧 backend 配置兼容。

3. 扩展后台 /api/system/llm_config 读写能力,支持 scenes 配置保存;新增插件 LLM 依赖扫描与拓扑数据输出。

4. 升级 system_llm 页面:新增场景路由管理区、插件依赖拓扑表,支持可视化查看 插件->scene->backend->provider。

5. 迁移核心插件配置到 scene 模式(保留兼容字段):dify/global_news/game_task/message_summary/ai_auto_response/member_context/douyu。

6. 调整部分插件初始化默认 llm_config,补充 scene 字段,确保后台场景切换可直接生效。
This commit is contained in:
liuwei
2026-04-20 14:36:56 +08:00
parent 09daaf956c
commit 7b6bd19781
14 changed files with 351 additions and 6 deletions
+3
View File
@@ -1,5 +1,8 @@
[Dify]
enable = true
# 业务场景优先:聊天插件只关心 chat.main,由全局 llm.scenes 决定具体后端。
scene = "chat.main"
# 兼容字段保留:旧版本仍可读取 backend,新版本会优先走 scene 路由。
backend = "dify_workflow_chat"
commands = ["聊天"]
+2
View File
@@ -107,6 +107,8 @@ class DifyPlugin(MessagePluginInterface):
llm_config = dify_config.get("llm", {}) or {}
if not llm_config:
llm_config = {
# 优先支持场景路由:后台改 scene 绑定即可切换供应商/模型。
"scene": dify_config.get("scene", ""),
"backend": dify_config.get("backend", ""),
"provider": "dify",
"mode": "workflow",