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:
@@ -34,7 +34,8 @@ familiarity_hint = "有亲和力,但不越界装熟"
|
||||
aliases = ["林志玲", "lingzhiling", "温柔", "温柔版"]
|
||||
|
||||
[api]
|
||||
backend = "dify_workflow_ai_auto_response"
|
||||
# 群聊自动回复统一走 auto_reply.group 场景,便于灰度切换不同供应商。
|
||||
scene = "auto_reply.group"
|
||||
|
||||
[runtime]
|
||||
llm_max_concurrency = 3
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
[Dify]
|
||||
enable = true
|
||||
# 业务场景优先:聊天插件只关心 chat.main,由全局 llm.scenes 决定具体后端。
|
||||
scene = "chat.main"
|
||||
# 兼容字段保留:旧版本仍可读取 backend,新版本会优先走 scene 路由。
|
||||
backend = "dify_workflow_chat"
|
||||
|
||||
commands = ["聊天"]
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -27,7 +27,10 @@ daily_report_send_image = true
|
||||
audience_stats_sample_interval_seconds = 0
|
||||
|
||||
[Douyu.report_api]
|
||||
# 切换到 Dify 斗鱼日报专用工作流;对应配置位于根目录 config.yaml 的 llm.backends。
|
||||
# 切换到“场景路由”模式:日报插件只关心 douyu.daily_report,
|
||||
# 具体绑定哪个后端由根目录 config.yaml 的 llm.scenes 统一维护。
|
||||
scene = "douyu.daily_report"
|
||||
# 兼容旧配置:保留 backend 作为回退字段。
|
||||
backend = "dify_workflow_douyu_daily_report"
|
||||
# 是否把完整结构化 payload(JSON 大对象)作为输入传给 Dify。
|
||||
# 某些 Workflow 对复杂输入类型校验严格,会导致 400,默认关闭以保证可用性。
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
[GameTask]
|
||||
enable = true
|
||||
# 通过 scene 绑定后端,便于后台统一切换百科出题与判分模型。
|
||||
scene = "game.task"
|
||||
backend = "openai_compatible_game_task"
|
||||
command = ["/t", "/a", "/s", "/r", "/l", "/h"]
|
||||
command-format = """
|
||||
|
||||
@@ -86,6 +86,8 @@ class GameTaskPlugin(MessagePluginInterface):
|
||||
llm_config = plugin_config.get("llm", {}) or {}
|
||||
if not llm_config:
|
||||
llm_config = {
|
||||
# 场景路由优先,后台改 scene 即可替换出题/判分模型。
|
||||
"scene": plugin_config.get("scene", ""),
|
||||
"backend": plugin_config.get("backend", ""),
|
||||
"provider": "openai_compatible",
|
||||
"authorization": self.authorization,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
[GlobalNews]
|
||||
enable = true
|
||||
command = ["全球新闻", "国际新闻", "环球新闻", "政经新闻", "政治经济新闻"]
|
||||
# 通过 scene 绑定后端,便于后台统一切换新闻分析模型。
|
||||
scene = "news.global"
|
||||
backend = "dify_chat_global_news"
|
||||
command-format = """
|
||||
🌍全球新闻指令:
|
||||
|
||||
@@ -79,6 +79,8 @@ class GlobalNewsPlugin(MessagePluginInterface):
|
||||
llm_config = plugin_config.get("llm", {}) or {}
|
||||
if not llm_config:
|
||||
llm_config = {
|
||||
# 场景路由优先,便于后台统一切换新闻分析后端。
|
||||
"scene": plugin_config.get("scene", ""),
|
||||
"backend": plugin_config.get("backend", ""),
|
||||
"provider": "dify",
|
||||
"mode": "chat",
|
||||
|
||||
@@ -3,7 +3,8 @@ enable = true
|
||||
|
||||
[api]
|
||||
enable = true
|
||||
backend = "dify_workflow_member_context"
|
||||
# 成员画像提炼改为场景路由,便于后续替换成更强结构化模型。
|
||||
scene = "member.profile"
|
||||
request_timeout = 240
|
||||
|
||||
[profile]
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
enabled = true
|
||||
|
||||
[api]
|
||||
backend = "dify_workflow_message_summary"
|
||||
# 群总结能力改为场景路由,后台切换 summary.daily 即可统一切换实现。
|
||||
scene = "summary.daily"
|
||||
connect_timeout_seconds = 10
|
||||
retry_delays_seconds = [10, 20]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user