feat: AI 生图、图片下载优化

This commit is contained in:
Joey
2026-08-29 17:13:06 +08:00
parent a77ec26a02
commit 4ee667142b
20 changed files with 683 additions and 248 deletions
+5 -3
View File
@@ -28,6 +28,7 @@ from schemas.suite import (
SuiteGenerateRequest,
SuiteOut,
SuitePlanRequest,
api_model,
resolve_provider,
)
from services.generator import _image_size, GENERATORS, run_suite
@@ -98,9 +99,10 @@ async def generate_suite(req: SuiteGenerateRequest, background: BackgroundTasks)
spec = PLATFORM_SPECS[req.platform]
settings = get_settings()
# 前端只传模型名:已知模型直接路由到对应 provider(如 gpt-image-2-vip → rightapi)
# 前端只传模型名:已知模型直接路由到对应 provider(如 gpt-image-2-vip → rightapi、gpt-image-2@pcore → pcore)
provider_name = resolve_provider(req.model, None, settings.image_provider)
validate_model(provider_name, req.model)
model = api_model(req.model) # 剥 @provider 后缀,供应商侧只认裸模型名
product_id = (req.product_id or "").strip() or None
if product_id:
@@ -118,7 +120,7 @@ async def generate_suite(req: SuiteGenerateRequest, background: BackgroundTasks)
style_prompt=req.style_prompt,
requirements=req.requirements,
provider=provider_name,
model=req.model,
model=model,
total=len(jobs),
context=texts_to_raw(req.texts),
plan=jobs,
@@ -214,7 +216,7 @@ async def suite_image_edit(req: ImageEditSingleRequest) -> ImageEditSingleRespon
validate_model(provider_name, req.model)
spec = {"lang": "ru", "ratio": "3:4"} # 试算页固定 Ozon 规格(俄文图内文案 · 3:4)
model = req.model
model = api_model(req.model) # 剥 @provider 后缀,供应商侧只认裸模型名
is_wan = provider_name == "tongyi" and model.lower().startswith("wan")
# 复用套图的 prompt 家族:custom 类型装配「用户要求」为最高优先级约束,