Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions backend/app/services/mcp/image_service_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

# image-service 所有 Gemini 模型都接受的比例;Seedream 接受任意比例。
ASPECT_RATIOS = ("1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9")
# 主模型被内容审核拦截时,由 image-service 换这个模型重试一次(其他错误不切换)。
FALLBACK_MODEL = "doubao-seedream-4-5"
# image-service 结构化错误码(P0 设计 §2.1);不认识的码按通用上游失败处理。
KNOWN_ERROR_CODES = frozenset({
"invalid_params",
Expand Down Expand Up @@ -447,10 +445,10 @@ def _normalized_arguments(args: Any) -> dict[str, Any]:
regenerate = args.get("regenerate", False)
if not isinstance(regenerate, bool):
raise ImageGenerationError("invalid_arguments")
# 主力/备用模型由 image-service 的 DEFAULT_MODEL / DEFAULT_FALLBACK_MODEL 决定,便于切换。
arguments: dict[str, Any] = {
"prompt": prompt.strip(),
"aspect_ratio": aspect_ratio,
"fallback_model": FALLBACK_MODEL,
"grounding": True,
}
if regenerate:
Expand Down
3 changes: 1 addition & 2 deletions backend/test/test_image_service_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
)
from app.services.mcp.image_service_tools import ( # noqa: E402
EXECUTION_TIMEOUT_SECONDS,
FALLBACK_MODEL,
MCP_CALL_TIMEOUT_SECONDS,
ImageGenerationError,
parse_generate_image_text,
Expand Down Expand Up @@ -150,7 +149,7 @@ async def test_success_downloads_from_endpoint_origin_and_stores_for_bound_conve
self.assertEqual(client.calls[0][1], "generate_image")
self.assertEqual(
client.calls[0][2],
{"prompt": "a red fox", "aspect_ratio": "16:9", "fallback_model": FALLBACK_MODEL, "grounding": True},
{"prompt": "a red fox", "aspect_ratio": "16:9", "grounding": True},
)
self.assertEqual(client.min_timeouts, [MCP_CALL_TIMEOUT_SECONDS])
self.assertEqual(server.requested_urls, [f"http://192.168.1.11:8090/static/images/{IMAGE_NAME}"])
Expand Down
Loading