refactor: 移除LLM旧兼容入口并统一scene单路由
变更项: 1. LLMRegistry 仅保留 scene 入口,删除 backend_name/backend_ref/scene_ref 等兼容解析分支,未声明 scene 时仅保留直连配置。 2. Dify/GlobalNews/GameTask 插件初始化改为仅传 scene,不再拼接 backend/provider/url 等旧兼容字段。 3. 清理插件配置冗余:dify/global_news/game_task/douyu 的 config.toml 删除 backend 字段,统一由 scene 映射后端。 4. 后台 system API 调整为严格模式:插件依赖扫描仅采集 scene;scene 保存时必须绑定有效 backend。 5. 后台页面去除拓扑中的配置Backend冗余列,并新增前端校验,禁止提交空场景或未绑定后端。
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
enable = true
|
||||
# 业务场景优先:聊天插件只关心 chat.main,由全局 llm.scenes 决定具体后端。
|
||||
scene = "chat.main"
|
||||
# 兼容字段保留:旧版本仍可读取 backend,新版本会优先走 scene 路由。
|
||||
backend = "dify_workflow_chat"
|
||||
|
||||
commands = ["聊天"]
|
||||
command-tip = """
|
||||
|
||||
@@ -98,25 +98,15 @@ class DifyPlugin(MessagePluginInterface):
|
||||
self._commands = dify_config.get("commands", ["ai", "dify", "聊天", "AI"])
|
||||
self.command_format = dify_config.get("command-tip", "聊天 请求内容")
|
||||
self.enable = dify_config.get("enable", True)
|
||||
raw_api_key = dify_config.get("api-key", "")
|
||||
raw_base_url = dify_config.get("base-url", "")
|
||||
self.price = dify_config.get("price", 0)
|
||||
self.admin_ignore = dify_config.get("admin_ignore", False)
|
||||
self.whitelist_ignore = dify_config.get("whitelist_ignore", False)
|
||||
self.http_proxy = dify_config.get("http-proxy", "")
|
||||
llm_config = dify_config.get("llm", {}) or {}
|
||||
if not llm_config:
|
||||
# 严格场景路由:插件初始化只传 scene,不再拼接 backend 兼容字段。
|
||||
llm_config = {
|
||||
# 优先支持场景路由:后台改 scene 绑定即可切换供应商/模型。
|
||||
"scene": dify_config.get("scene", ""),
|
||||
"backend": dify_config.get("backend", ""),
|
||||
"provider": "dify",
|
||||
"mode": "workflow",
|
||||
"api-key": raw_api_key,
|
||||
"base-url": raw_base_url,
|
||||
"endpoint": "workflows/run",
|
||||
"response_mode": "blocking",
|
||||
"request_timeout": 40,
|
||||
}
|
||||
self.llm_client = UnifiedLLMClient(llm_config)
|
||||
self.api_key = self.llm_client.api_key
|
||||
|
||||
@@ -30,8 +30,6 @@ audience_stats_sample_interval_seconds = 0
|
||||
# 切换到“场景路由”模式:日报插件只关心 douyu.daily_report,
|
||||
# 具体绑定哪个后端由根目录 config.yaml 的 llm.scenes 统一维护。
|
||||
scene = "douyu.daily_report"
|
||||
# 兼容旧配置:保留 backend 作为回退字段。
|
||||
backend = "dify_workflow_douyu_daily_report"
|
||||
# 是否把完整结构化 payload(JSON 大对象)作为输入传给 Dify。
|
||||
# 某些 Workflow 对复杂输入类型校验严格,会导致 400,默认关闭以保证可用性。
|
||||
include_structured_inputs = false
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
enable = true
|
||||
# 通过 scene 绑定后端,便于后台统一切换百科出题与判分模型。
|
||||
scene = "game.task"
|
||||
backend = "openai_compatible_game_task"
|
||||
command = ["/t", "/a", "/s", "/r", "/l", "/h"]
|
||||
command-format = """
|
||||
🎮 百科问答指令:
|
||||
|
||||
@@ -80,22 +80,11 @@ class GameTaskPlugin(MessagePluginInterface):
|
||||
/h - 查看未完成任务
|
||||
""")
|
||||
plugin_config = self._config.get("GameTask", {})
|
||||
self.authorization = plugin_config.get("authorization", "")
|
||||
self.url = plugin_config.get("url", "")
|
||||
self.model = plugin_config.get("model", "")
|
||||
llm_config = plugin_config.get("llm", {}) or {}
|
||||
if not llm_config:
|
||||
# 严格场景路由:仅通过 scene 映射具体后端与模型参数。
|
||||
llm_config = {
|
||||
# 场景路由优先,后台改 scene 即可替换出题/判分模型。
|
||||
"scene": plugin_config.get("scene", ""),
|
||||
"backend": plugin_config.get("backend", ""),
|
||||
"provider": "openai_compatible",
|
||||
"authorization": self.authorization,
|
||||
"url": self.url,
|
||||
"model": self.model,
|
||||
"stream": False,
|
||||
"temperature": 0.2,
|
||||
"max_tokens": 1000,
|
||||
}
|
||||
self.llm_client = UnifiedLLMClient(llm_config)
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ enable = true
|
||||
command = ["全球新闻", "国际新闻", "环球新闻", "政经新闻", "政治经济新闻"]
|
||||
# 通过 scene 绑定后端,便于后台统一切换新闻分析模型。
|
||||
scene = "news.global"
|
||||
backend = "dify_chat_global_news"
|
||||
command-format = """
|
||||
🌍全球新闻指令:
|
||||
全球新闻 - 获取最新的全球政治经济新闻
|
||||
|
||||
@@ -78,15 +78,9 @@ class GlobalNewsPlugin(MessagePluginInterface):
|
||||
self.enable = plugin_config.get("enable", True)
|
||||
llm_config = plugin_config.get("llm", {}) or {}
|
||||
if not llm_config:
|
||||
# 严格场景路由:仅由 scene 决定使用哪个后端。
|
||||
llm_config = {
|
||||
# 场景路由优先,便于后台统一切换新闻分析后端。
|
||||
"scene": plugin_config.get("scene", ""),
|
||||
"backend": plugin_config.get("backend", ""),
|
||||
"provider": "dify",
|
||||
"mode": "chat",
|
||||
"authorization": plugin_config.get("authorization", ""),
|
||||
"url": plugin_config.get("url", ""),
|
||||
"response_mode": "blocking",
|
||||
}
|
||||
self.llm_client = UnifiedLLMClient(llm_config)
|
||||
self.LOG.debug(f"[{self.name}] 插件初始化完成,指令:{self._commands}")
|
||||
|
||||
Reference in New Issue
Block a user