Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
test(image-generation): tighten zhipu provider coverage
Xubin Ren5937236f9dce
diff --git a/docs/configuration.md b/docs/configuration.mdindex e4fbe83eb..0622c404d 100644--- a/docs/configuration.md+++ b/docs/configuration.md@@ -1195,7 +1195,7 @@ If you want to always use the local conversion, you can force it using:## Image Generation-Image generation is configured under `tools.imageGeneration` and uses provider credentials from `providers.openrouter` or `providers.aihubmix`.+Image generation is configured under `tools.imageGeneration` and uses credentials from the selected provider's `providers.<name>` block.See [Image Generation](./image-generation.md) for WebUI usage, provider examples, artifact storage, and troubleshooting.diff --git a/docs/image-generation.md b/docs/image-generation.mdindex 374b1cb17..77f431dc0 100644--- a/docs/image-generation.md+++ b/docs/image-generation.md@@ -255,7 +255,7 @@ Supported aspect ratios: `1:1`, `16:9`, `9:16`, `3:4`, `4:3`. Sizes can be speci{"providers": {"zhipu": {- "apiKey": "${ZHIPU_API_KEY}"+ "apiKey": "${ZAI_API_KEY}"}},"tools": {@@ -328,4 +328,3 @@ Use the reference image. Keep the same robot and composition, change the palette| AIHubMix says `Incorrect model ID` | Use `model: "gpt-image-2-free"`; nanobot expands it to the required `openai/gpt-image-2-free` model path internally || Generation times out | Try a smaller/default image size, set AIHubMix `extraBody.quality` to `"low"`, or retry later || Reference image rejected | Reference image paths must be inside the workspace or nanobot media directory and must be valid image files |-diff --git a/nanobot/providers/image_generation.py b/nanobot/providers/image_generation.pyindex 0fa604936..ff5911b01 100644--- a/nanobot/providers/image_generation.py+++ b/nanobot/providers/image_generation.py@@ -1504,7 +1504,6 @@ class ZhipuImageGenerationClient(ImageGenerationProvider):"prompt": prompt,}- # Resolve sizesize = _zhipu_size(aspect_ratio, image_size)if size:body["size"] = size@@ -1517,10 +1516,6 @@ class ZhipuImageGenerationClient(ImageGenerationProvider):try:return await self._generate_with_client(client,- prompt=prompt,- model=model,- aspect_ratio=aspect_ratio,- image_size=image_size,headers=headers,body=body,url=url,@@ -1533,10 +1528,6 @@ class ZhipuImageGenerationClient(ImageGenerationProvider):self,client: httpx.AsyncClient,*,- prompt: str,- model: str,- aspect_ratio: str | None,- image_size: str | None,headers: dict[str, str],body: dict[str, Any],url: str,diff --git a/tests/tools/test_image_generation_tool.py b/tests/tools/test_image_generation_tool.pyindex 23f207de1..d2ee28388 100644--- a/tests/tools/test_image_generation_tool.py+++ b/tests/tools/test_image_generation_tool.py@@ -172,16 +172,7 @@ async def test_generate_image_tool_allows_ollama_without_api_key(@pytest.mark.asyncio-async def test_generate_image_tool_allows_zhipu_without_api_key(- tmp_path: Path,- monkeypatch: pytest.MonkeyPatch,-) -> None:- set_config_path(tmp_path / "config.json")- FakeImageClient.instances = []- monkeypatch.setattr(- "nanobot.agent.tools.image_generation.get_image_gen_provider",- lambda name: FakeImageClient if name == "zhipu" else None,- )+async def test_generate_image_tool_reports_missing_zhipu_key(tmp_path: Path) -> None:tool = ImageGenerationTool(workspace=tmp_path,config=ImageGenerationToolConfig(@@ -194,14 +185,7 @@ async def test_generate_image_tool_allows_zhipu_without_api_key(result = await tool.execute(prompt="draw a cat")- payload = json.loads(result)- assert len(payload["artifacts"]) == 1-- fake = FakeImageClient.instances[0]- assert fake.kwargs["api_key"] is None- assert fake.kwargs["api_base"] == "https://open.bigmodel.cn/api/paas/v4"- assert fake.calls[0]["aspect_ratio"] == "1:1"- assert fake.calls[0]["image_size"] == "1K"+ assert result.startswith("Error: Zhipu API key is not configured")@pytest.mark.asyncio