上线版: 产品表单统一+form嵌套修复+用户管理+部署+三套叙事
- 产品编辑入口统一走 ProductFormFull(卖点/风格/人群/品牌词全字段); 修复开任务页 <form> 套 <form> 致"编辑产品"报错、改不了、跳回首个产品 - dashboard 入口卡片对齐实际路由: 系统管理(/config) 与 工作配置(/settings) 分开; settings ?tab=products 直达改用挂载后读 URL, 消除 hydration mismatch - 新增用户管理(users API/admin service/改密页) + alembic 022/023/024 - 上线部署: Dockerfile / docker-compose.prod+https / nginx https / .env.example - A8 三套正交叙事(痛点/场景/成分背书) + beige 调色去AI化 + 飞轮 text_import 高权重信号 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
64
backend/tests/test_image_provider_routing.py
Normal file
64
backend/tests/test_image_provider_routing.py
Normal file
@@ -0,0 +1,64 @@
|
||||
import asyncio
|
||||
import base64
|
||||
|
||||
from app.services.ai_engine.gemini_factory import AIClients
|
||||
|
||||
|
||||
class _Resp:
|
||||
def __init__(self, payload):
|
||||
self.payload = payload
|
||||
|
||||
def raise_for_status(self):
|
||||
return None
|
||||
|
||||
def json(self):
|
||||
return self.payload
|
||||
|
||||
|
||||
class _Client:
|
||||
def __init__(self, payload):
|
||||
self.payload = payload
|
||||
self.calls = []
|
||||
|
||||
async def post(self, url, **kwargs):
|
||||
self.calls.append({"url": url, **kwargs})
|
||||
return _Resp(self.payload)
|
||||
|
||||
|
||||
def test_apiports_image_edit_uses_chat_completions(monkeypatch):
|
||||
img = base64.b64encode(b"image-bytes").decode()
|
||||
fake = _Client({
|
||||
"choices": [{
|
||||
"message": {
|
||||
"images": [{"b64_json": img}],
|
||||
},
|
||||
}],
|
||||
})
|
||||
client = AIClients(_gpt_token="apiports-token", _gpt_base="https://apiports.example")
|
||||
monkeypatch.setattr(client, "_gpt_target", lambda provider: ("https://apiports.example", "apiports-token", fake))
|
||||
|
||||
out = asyncio.run(client.gpt_edits("keep bottle", [b"ref"], "1024x1536", provider="apiports"))
|
||||
|
||||
assert out == b"image-bytes"
|
||||
assert fake.calls[0]["url"] == "https://apiports.example/chat/completions"
|
||||
payload = fake.calls[0]["json"]
|
||||
assert payload["model"] == client._model_image
|
||||
content = payload["messages"][0]["content"]
|
||||
assert content[0]["type"] == "text"
|
||||
assert content[1]["type"] == "image_url"
|
||||
assert content[1]["image_url"]["url"].startswith("data:image/png;base64,")
|
||||
|
||||
|
||||
def test_codeproxy_image_edit_keeps_images_edits(monkeypatch):
|
||||
img = base64.b64encode(b"codeproxy-image").decode()
|
||||
fake = _Client({"data": [{"b64_json": img}]})
|
||||
client = AIClients(_alt_token="codeproxy-token", _alt_base="https://codeproxy.example")
|
||||
monkeypatch.setattr(client, "_gpt_target", lambda provider: ("https://codeproxy.example", "codeproxy-token", fake))
|
||||
|
||||
out = asyncio.run(client.gpt_edits("keep bottle", [b"ref"], "1024x1536", provider="codeproxy"))
|
||||
|
||||
assert out == b"codeproxy-image"
|
||||
assert fake.calls[0]["url"] == "https://codeproxy.example/images/edits"
|
||||
files = fake.calls[0]["files"]
|
||||
assert any(part[0] == "image[]" for part in files)
|
||||
assert any(part[0] == "prompt" for part in files)
|
||||
Reference in New Issue
Block a user