feat: 增加gpt-image-2 模型

This commit is contained in:
R524809
2026-08-17 17:28:02 +08:00
parent 9d15d8f784
commit e9d1eef07e
11 changed files with 162 additions and 17 deletions
+6 -2
View File
@@ -7,7 +7,8 @@ from config import get_settings
from db import get_db
from models import Suite
from schemas import (
GenerateRequest, PLATFORM_SPECS, SUPPORTED_TYPES, TONGYI_MODELS, SuiteCreateResponse, TextMaterial,
GenerateRequest, PLATFORM_SPECS, SUPPORTED_TYPES, TONGYI_MODELS, RIGHTAPI_MODELS,
SuiteCreateResponse, TextMaterial, resolve_provider,
PlanRequest, PlanResponse, PlanItemOut,
)
from services.generator import run_suite
@@ -84,10 +85,13 @@ async def generate_suite(
spec = PLATFORM_SPECS[req.platform]
settings = get_settings()
provider_name = req.provider or settings.image_provider
# 插件只传模型名:已知模型直接路由到对应 providergpt-image-2 → rightapi
provider_name = resolve_provider(req.model, req.provider, settings.image_provider)
model = req.model
if provider_name == "tongyi" and model and model not in TONGYI_MODELS:
raise HTTPException(status_code=400, detail=f"不支持的模型: {model}tongyi 支持: {TONGYI_MODELS}")
if provider_name == "rightapi" and model and model not in RIGHTAPI_MODELS:
raise HTTPException(status_code=400, detail=f"不支持的模型: {model}rightapi 支持: {RIGHTAPI_MODELS}")
suite = Suite(
product_id=None,
style_set=req.style_set,
+8 -2
View File
@@ -13,7 +13,10 @@ from sqlalchemy.ext.asyncio import AsyncSession
from config import get_settings
from db import get_db
from models import Product, ProductAsset, Suite, SuiteImage, STATUS_OK
from schemas import PLATFORM_SPECS, SUPPORTED_TYPES, TONGYI_MODELS, SuiteCreateRequest, SuiteCreateResponse, SuiteImageOut, SuiteOut
from schemas import (
PLATFORM_SPECS, SUPPORTED_TYPES, TONGYI_MODELS, RIGHTAPI_MODELS,
SuiteCreateRequest, SuiteCreateResponse, SuiteImageOut, SuiteOut, resolve_provider,
)
from services import storage
from services.generator import run_suite
@@ -76,9 +79,12 @@ async def create_suite(
spec = PLATFORM_SPECS[req.platform]
settings = get_settings()
provider_name = req.provider or settings.image_provider
# 模型名优先路由:已知模型直接定位 providergpt-image-2 → rightapi
provider_name = resolve_provider(req.model, req.provider, settings.image_provider)
if provider_name == "tongyi" and req.model and req.model not in TONGYI_MODELS:
raise HTTPException(status_code=400, detail=f"不支持的模型: {req.model}tongyi 支持: {TONGYI_MODELS}")
if provider_name == "rightapi" and req.model and req.model not in RIGHTAPI_MODELS:
raise HTTPException(status_code=400, detail=f"不支持的模型: {req.model}rightapi 支持: {RIGHTAPI_MODELS}")
suite = Suite(
product_id=product.id,
style_set=req.style_set,