From be1cc769d5bdc7932ead60819e6bbac31f1c6239 Mon Sep 17 00:00:00 2001 From: yrk <2493404415@qq.com> Date: Thu, 16 Jul 2026 16:55:36 +0800 Subject: [PATCH] docs: refine ModelScope documentation wording --- docs/configuration.md | 4 ++-- docs/image-generation.md | 2 +- nanobot/providers/image_generation.py | 10 +++++----- tests/providers/test_image_generation.py | 20 ++++++++++++++++---- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 3f78d483..debe978c 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -254,7 +254,7 @@ Tracing covers the providers that go through nanobot's OpenAI-compatible client > - **OpenCode Zen / Go**: `providers.opencode` (canonical Zen), the legacy-compatible `providers.opencodeZen`, and `providers.opencodeGo` use the same `OPENCODE_API_KEY`, but route to different OpenCode gateways. These providers use OpenCode's OpenAI-compatible `chat/completions` endpoints; choose model IDs from that endpoint family. > - **Zhipu Coding Plan**: If you're on Zhipu's coding plan, set `"apiBase": "https://open.bigmodel.cn/api/coding/paas/v4"` in your zhipu provider config. > - **Alibaba Cloud BaiLian**: If you're using Alibaba Cloud BaiLian's OpenAI-compatible endpoint, set `"apiBase": "https://dashscope.aliyuncs.com/compatible-mode/v1"` in your dashscope provider config. -> - **ModelScope (魔搭社区)**: If you're using ModelScope's OpenAI-compatible endpoint, set `"apiBase": "https://api-inference.modelscope.cn/v1"` in your modelscope provider config. +> - **ModelScope**: If you're using ModelScope's OpenAI-compatible endpoint, set `"apiBase": "https://api-inference.modelscope.cn/v1"` in your modelscope provider config. > - **StepFun Step Plan**: If you're on StepFun's Step Plan subscription, set `"apiBase": "https://api.stepfun.ai/step_plan/v1"` in your stepfun provider config. Supported models include `step-3.5-flash`, `step-3.5-flash-2603`, and `step-router-v1`. > - **Step Fun (Mainland China)**: If your API key is from Step Fun's mainland China platform (stepfun.com), set `"apiBase": "https://api.stepfun.com/v1"` in your stepfun provider config. > - **Xiaomi MiMo thinking mode**: MiMo models (e.g. `mimo-v2.5-pro`) default to enabled thinking. Use `agents.defaults.reasoningEffort: "none"` to disable it, or `"low"` / `"medium"` / `"high"` to keep it on. Omitting the field preserves the provider's per-model default. @@ -289,7 +289,7 @@ Tracing covers the providers that go through nanobot's OpenAI-compatible client | `siliconflow` | LLM (SiliconFlow/硅基流动) | [siliconflow.cn](https://siliconflow.cn) | | `novita` | LLM (Novita AI OpenAI-compatible gateway) | [novita.ai](https://novita.ai) | | `dashscope` | LLM (Qwen) | [dashscope.console.aliyun.com](https://dashscope.console.aliyun.com) | -| `modelscope` | LLM (ModelScope/魔搭) + Image generation | [modelscope.cn](https://modelscope.cn) | +| `modelscope` | LLM (ModelScope/魔搭社区) + Image generation | [modelscope.cn](https://modelscope.cn) | | `moonshot` | LLM (Moonshot/Kimi) | [platform.kimi.com](https://platform.kimi.com?aff=nanobot) | | `kimi_coding` | LLM (Kimi Coding Plan, Anthropic Messages API) | [platform.kimi.com](https://platform.kimi.com?aff=nanobot) | | `zhipu` | LLM (Zhipu GLM) | [open.bigmodel.cn](https://open.bigmodel.cn) | diff --git a/docs/image-generation.md b/docs/image-generation.md index 4bd76348..a9185eec 100644 --- a/docs/image-generation.md +++ b/docs/image-generation.md @@ -323,7 +323,7 @@ Other supported models: `cogview-4`, `cogview-4-250304`, `cogview-3-flash`. Refe ModelScope (魔搭社区) API-Inference supports text-to-image generation and image editing via an async task pattern. -Supported aspect ratios: `1:1`, `16:9`, `9:16`, `3:4`, `4:3`. Sizes can be specified as `WIDTHxHEIGHT` (e.g. `1024x1024`, `1536x1024`) or using aspect ratio presets. +Supported aspect ratios: `1:1`, `16:9`, `9:16`, `3:4`, `4:3`. Sizes can be specified as `WIDTHxHEIGHT` (e.g. `1024x1024`, `1664x928`) or using aspect ratio presets. ```json { diff --git a/nanobot/providers/image_generation.py b/nanobot/providers/image_generation.py index 75c2cb32..04ee4631 100644 --- a/nanobot/providers/image_generation.py +++ b/nanobot/providers/image_generation.py @@ -1760,11 +1760,11 @@ _MODELSCOPE_TIMEOUT_S = 300.0 _MODELSCOPE_POLL_INTERVAL_S = 5.0 _MODELSCOPE_POLL_MAX_ATTEMPTS = 60 # 5 min at 5s intervals _MODELSCOPE_ASPECT_RATIOS = { - "1:1": "1024x1024", - "16:9": "1536x1024", - "9:16": "1024x1536", - "3:4": "1024x1536", - "4:3": "1536x1024", + "1:1": "1328x1328", + "16:9": "1664x928", + "9:16": "928x1664", + "3:4": "1140x1472", + "4:3": "1472x1140", } diff --git a/tests/providers/test_image_generation.py b/tests/providers/test_image_generation.py index 2f207f8e..cbb0f99a 100644 --- a/tests/providers/test_image_generation.py +++ b/tests/providers/test_image_generation.py @@ -1633,8 +1633,21 @@ async def test_modelscope_image_generation_with_size() -> None: assert body["size"] == "768x1024" +@pytest.mark.parametrize( + ("aspect_ratio", "expected_size"), + [ + ("1:1", "1328x1328"), + ("16:9", "1664x928"), + ("9:16", "928x1664"), + ("3:4", "1140x1472"), + ("4:3", "1472x1140"), + ], +) @pytest.mark.asyncio -async def test_modelscope_image_generation_aspect_ratio_mapping() -> None: +async def test_modelscope_image_generation_aspect_ratio_mapping( + aspect_ratio: str, + expected_size: str, +) -> None: submit = FakeResponse({"task_id": "t1"}) poll = [FakeResponse({"task_status": "SUCCEED", "output_images": ["https://cdn/img.png"]})] fake = ModelScopeFakeClient(submit, poll) @@ -1643,9 +1656,9 @@ async def test_modelscope_image_generation_aspect_ratio_mapping() -> None: client=fake, # type: ignore[arg-type] ) - await client.generate(prompt="test", model="m", aspect_ratio="16:9") + await client.generate(prompt="test", model="m", aspect_ratio=aspect_ratio) - assert fake.calls[0]["json"]["size"] == "1536x1024" + assert fake.calls[0]["json"]["size"] == expected_size @pytest.mark.asyncio @@ -1753,4 +1766,3 @@ async def test_modelscope_image_generation_poll_timeout(monkeypatch) -> None: # Should have polled up to the (patched) attempt limit. assert len(fake.get_calls) == 3 -