改造AI绘图插件接入统一LLM路由

1. AI绘图插件新增基于项目llm scene/backend的OpenAI兼容图片生成调用逻辑。

2. 保留pollinations旧版回退路径,避免未配置统一网关时功能中断。

3. 补充插件配置项与详细中文注释,支持图片模型、尺寸、质量和图片接口endpoint配置。
This commit is contained in:
liuwei
2026-04-28 16:01:57 +08:00
parent 3eb87478d7
commit 075fba65ec
2 changed files with 239 additions and 44 deletions

View File

@@ -6,9 +6,32 @@ command-format = """
AI绘图 描述文字
"""
# 图片生成API配置
image_api_url = "https://image.pollinations.ai/prompt/{prompt}"
# OpenAI 兼容图片生成参数。
# 如果你的网关要求特定图片模型,可把 default_model 改成对应值。
default_model = "gpt-image-1"
image_quality = "standard"
image_response_format = "b64_json"
image_count = 1
# 图片尺寸配置:
# 1. image_size 会优先直接用于 OpenAI 兼容接口;
# 2. default_width/default_height 主要用于旧版 pollinations 回退逻辑;
# 3. 为了兼容老逻辑,这两组配置同时保留。
image_size = "1024x1024"
default_width = 1024
default_height = 1024
default_model = "turbo"
default_timeout = 300
default_timeout = 300
# 旧版回退接口配置:
# 当没有配置 llm.scene且也没有单独提供网关地址/密钥时,
# 插件会继续使用原来的 pollinations 逻辑生成图片。
image_api_url = "https://image.pollinations.ai/prompt/{prompt}"
legacy_model = "turbo"
# 图片生成主配置:
# 1. 推荐通过 llm.scene 走项目统一的 LLM 配置路由;
# 2. 插件会从该 scene 对应的 backend 中复用 api_base_url / api_key
# 3. 图片接口默认请求 images/generations如需特殊网关可在这里覆盖 image_endpoint。
[AIGenImage.llm]
scene = ""
image_endpoint = "images/generations"