From 5e144fb481a326138deab425fd332674540ace6a Mon Sep 17 00:00:00 2001 From: liuwei Date: Tue, 28 Apr 2026 16:03:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EAI=E7=BB=98=E5=9B=BE=E7=BB=9F?= =?UTF-8?q?=E4=B8=80LLM=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 在config.yaml中新增AI绘图专用的OpenAI兼容backend,接入用户提供的网关地址与密钥。 2. 在llm.scenes中新增image.generate场景,统一路由AI绘图插件请求。 3. 将ai_gen_image插件默认scene切换为image.generate,实现开箱即用。 --- config.yaml | 17 +++++++++++++++++ plugins/ai_gen_image/config.toml | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/config.yaml b/config.yaml index 7be98f7..a1a4504 100644 --- a/config.yaml +++ b/config.yaml @@ -121,6 +121,22 @@ llm: request_timeout: 15 max_retries: 1 retry_delay_seconds: 1.0 + openai_compatible_ai_gen_image: + provider: "openai_compatible" + # AI 绘图专用网关: + # 1. 这里使用用户提供的 OpenAI 兼容服务地址; + # 2. 插件会在此 base_url 基础上请求 images/generations; + # 3. endpoint 保留为图片接口默认值,便于后续统一调整。 + api_base_url: "https://freeapi.dgbmc.top" + endpoint: "images/generations" + api_key: "sk-2XccrBRsX8OmxqCEsZjdDRczhHNaAG7Mn88mNVL7Y0w0tx72" + # 图片模型默认使用 gpt-image-1; + # 若网关只支持其他模型,可后续直接在这里替换。 + model: "gpt-image-1" + stream: false + timeout_seconds: 300 + max_retries: 2 + retry_delay_seconds: 1.0 # 场景路由层:插件建议优先使用 scene,而不是直接绑定 backend。 # 这样当模型或供应商切换时,只需要改这里,不需要逐个改插件配置。 scenes: @@ -132,3 +148,4 @@ llm: "game.task": "openai_compatible_game_task" "auto_reply.group": "dify_workflow_ai_auto_response" "member_roast": "openai_compatible_ai_auto_response" + "image.generate": "openai_compatible_ai_gen_image" diff --git a/plugins/ai_gen_image/config.toml b/plugins/ai_gen_image/config.toml index b349d80..d578690 100644 --- a/plugins/ai_gen_image/config.toml +++ b/plugins/ai_gen_image/config.toml @@ -33,5 +33,5 @@ legacy_model = "turbo" # 2. 插件会从该 scene 对应的 backend 中复用 api_base_url / api_key; # 3. 图片接口默认请求 images/generations,如需特殊网关可在这里覆盖 image_endpoint。 [AIGenImage.llm] -scene = "" +scene = "image.generate" image_endpoint = "images/generations"