From 611bf064fd53b6c18e953df277c25d6118c4f586 Mon Sep 17 00:00:00 2001 From: Yige Date: Sat, 7 Nov 2026 01:19:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9B=BE=E7=89=87=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=8A=80=E8=83=BD=E9=81=B5=E5=BE=AA=E5=AE=9E=E9=99=85=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E7=9B=AE=E5=BD=95=E4=B8=8E=E5=B7=B2=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=20(#253)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 图片生成技能会把用户已保存的模型覆盖为固定旧型号,并在失败后自动切换其他模型。本次将中英文规则与目录描述改为依照显式选择、已保存的图片供应商/模型绑定和当前运行时能力;适用时可直接使用现有 GenerateImage,原始 API 路径继续保留。失败保留实际服务来源,不再承诺静态型号一定可用或自动跨模型回退。版本更新至 1.4.3。 验证:技能定向 i18n 校验、翻译新鲜度检查、完整 sidecar 契约检查均通过(0 errors,既有目录证据 warnings 保留);语义核对中英文一致,公开内容与私有凭据扫描通过。实际模型可用性由产品侧独立运行复验记录,不以 schema 校验替代服务成功。 The image skill previously replaced the saved model with a fixed legacy default and automatically switched models after failures. Both locales and catalog metadata now follow explicit choices, the saved image provider/model binding and current runtime capabilities. The existing GenerateImage tool can handle suitable requests, while direct API operations remain available. Errors retain their actual service attribution without a guaranteed static model list or unconditional cross-model fallback. Version: 1.4.3. Validation: focused skill validation, translation freshness and strict complete sidecar validation passed with zero errors (existing catalog evidence warnings remain). Bilingual semantic review and public-content/private-credential scan passed. Actual service availability is verified separately in the consuming product runtime. --- skills/dashscope-image-gen/SKILL.md | 216 +++++------------- skills/dashscope-image-gen/SKILL.zh-CN.md | 187 ++++----------- .../catalog-metadata.v1.json | 14 +- 3 files changed, 106 insertions(+), 311 deletions(-) diff --git a/skills/dashscope-image-gen/SKILL.md b/skills/dashscope-image-gen/SKILL.md index 4346b0a..e7ed01b 100644 --- a/skills/dashscope-image-gen/SKILL.md +++ b/skills/dashscope-image-gen/SKILL.md @@ -1,14 +1,9 @@ --- name: dashscope-image-gen description: >- - Use this skill when the user wants to generate images. Supports multiple - models: gpt-image-2 (default, via DesireCore Cloud), wan2.7-image-pro and - wan2.7-image (when user has DashScope configured). Uses OpenAI-compatible - /images/generations API for synchronous image generation. - Use when the user mentions: generate image, draw, text-to-image, create image, - AI painting, illustration, design picture. + Generate images using the user’s explicit choice or saved image-generation default and the current runtime catalog. Requires an enabled provider, model access and quota; provider terms and separate usage charges apply. Use for drawing, illustrations, text-to-image and AI image creation. license: MIT -version: 1.4.2 +version: 1.4.3 type: procedural risk_level: low status: enabled @@ -25,7 +20,7 @@ requires: - Bash metadata: author: desirecore - updated_at: '2026-07-14' + updated_at: '2026-11-07' i18n: default_locale: en-US source_locale: zh-CN @@ -34,21 +29,18 @@ metadata: - en-US zh-CN: name: AI 文生图 - short_desc: AI 文本生成图片技能(支持 GPT Image / 通义万相) + short_desc: 遵循已配置默认与实际模型目录生成图片 description: >- - 当用户希望生成图片时使用此技能。支持多种模型:gpt-image-2(默认,通过 - DesireCore Cloud)、wan2.7-image-pro / wan2.7-image(用户自行配置阿里云 - DashScope 时可用)。通过 OpenAI 兼容的 /images/generations API 同步生成图片。 - 用户提到 生成图片、画图、文生图、创建图片、AI 绘画、生成插图、画一张、帮我画、设计图片。 + 按用户明确选择或已保存的图片生成默认与当前运行时目录生成图片。需要已启用的供应商、模型访问权限及额度;供应商条款与单独使用费用仍适用。适用于画图、插画、文生图与 AI 图片创作。 body: ./SKILL.zh-CN.md - source_hash: sha256:b3d5f7a91c2e4068 + source_hash: sha256:77a264d25e3bed8c translated_by: human en-US: name: AI Image Generation - short_desc: AI text-to-image generation (GPT Image / Wan models) - description: "Use this skill when the user wants to generate images. Supports multiple models: gpt-image-2 (default via DesireCore Cloud), wan2.7-image-pro / wan2.7-image (when user has DashScope configured). Uses the OpenAI-compatible /images/generations API. Trigger keywords: generate image, draw, text-to-image, create image, AI painting, illustration, design picture." + short_desc: Generate images with configured defaults and the runtime catalog + description: "Generate images using the user’s explicit choice or saved image-generation default and the current runtime catalog. Requires an enabled provider, model access and quota; provider terms and separate usage charges apply. Use for drawing, illustrations, text-to-image and AI image creation." body: ./SKILL.md - source_hash: sha256:8398726504b70586 + source_hash: sha256:77a264d25e3bed8c translated_by: human market: icon: >- @@ -59,181 +51,83 @@ market: fill-opacity="0.4" stroke="#34C759" stroke-width="1.2" stroke-linejoin="round"/> - short_desc: AI text-to-image generation (GPT Image / Wan models) + short_desc: Generate images with configured defaults and the runtime catalog category: media maintainer: name: DesireCore Official verified: true channel: latest +compatibility: Requires a running DesireCore agent-service and an enabled image_gen provider with model access and quota. Hosted services are external and subject to provider terms and separate usage charges. --- # dashscope-image-gen Skill -## Mandatory Rules (violations cause failure) +## Scope and prerequisites -1. **STRICTLY follow the execution steps below** — do NOT improvise, explore alternative endpoints, or try models not listed in this document -2. **Must access agent-service over HTTPS** — the API address is already provided in the system prompt under the local API section (e.g. `https://127.0.0.1:PORT`); use it directly with `-k` to skip certificate verification -3. **Must upload to media-store via `/api/media/upload`** — `/tmp` is only a transient download/decode location, never use a local path as the final output -4. **Must use the `dc-media://` protocol to display images** — the only form the frontend can render correctly -5. **Use Bash curl throughout** — do not use the HttpRequest tool or Python -6. **Use `/images/generations` endpoint** — synchronous call; the response contains b64_json image data -7. **Only use models listed below** — do NOT try dall-e-3, qwen-vl, or any model not in the Model Selection table +Generate and deliver images with a configured image-generation service. This skill does not provide a hosted model, credentials, quota, or a subscription. The user needs an enabled `image_gen` provider and access to the selected model; provider terms and separate usage charges apply. A catalog entry is not proof that an upstream channel is currently available. -## Provider & Default Compute +## Model and provider selection -You do NOT need to specify a provider — just pass `"serviceType": "image_gen"` and the system will automatically route to the correct provider. +1. Honor the user's explicit model/provider choice. Check the current runtime catalog and applicable API contract rather than guessing from a model family or this skill's name. +2. When the user does not name a model, use the saved `defaultServiceMap.image_gen` binding, including its provider. Do not replace it with a model named in an example. If no usable default exists, inspect currently enabled image-generation capabilities and choose within the user's requirements; clarify when a choice would change their requested service or cost constraints. +3. Resolve a binding through available compute-inspection tools or `GET /api/compute/config` on the current agent-service. The configuration API masks keys; extract only the default binding, provider ID/enabled state, and image-model metadata needed for the request. Never request or print credentials. Model `serviceType` can be `image_gen` or an array containing it. For raw API calls, resolve the upstream model ID as `userOverrides.apiModelId`, then `apiModelId`, then `modelName`. +4. Availability comes from the actual selected provider and response. There is no static model whitelist or guaranteed default in this skill. For example, a Wan model may be offered through an official gateway or a user's own DashScope connection; its name alone does not determine the route. -**Never** try to query provider lists, read compute.json, or explore available models through API calls. The models listed below are guaranteed to work. +## Choose an execution path -## Model Selection +Use the current tool/API contract that fits the request. When available and suitable, `GenerateImage` handles provider adaptation, generation, media persistence, and dimension receipts in one call. Discover its current schema if needed. For a saved default, pass its provider ID as `provider` and omit `model` so the tool resolves the saved model; for an explicit model, pass the verified model ID and provider. Preserve the user's prompt, reference images, quantity, and requested dimensions. -| Model | Characteristics | When to use | -|-------|----------------|-------------| -| gpt-image-2 | High quality, fast, versatile styles | **Default** — use when user does not specify a model | -| wan2.7-image | Standard high quality (requires DashScope provider) | Only when user explicitly asks for Wan / DashScope | -| wan2.7-image-pro | Flagship, 4K resolution (requires DashScope provider) | Only when user explicitly asks for top quality Wan model | - -**Default rule**: if the user does not specify a model, use `gpt-image-2`. - -**Note**: `wan2.7-image` and `wan2.7-image-pro` only work when the user has configured their own Alibaba Cloud DashScope provider. If you get an error with these models, fall back to `gpt-image-2`. - -## Full Execution Flow (strictly follow these steps) - -### How to get the API address - -The system prompt already contains the agent-service API address under the local API section (e.g. `Agent Service: https://127.0.0.1:61000`). Extract the URL from there and use it directly. - -If for any reason you cannot find it in the system prompt, use this fallback: - -```bash -PORT=$(cat "${DESIRECORE_HOME:-$HOME/.desirecore}/agent-service.port") -# Then use https://127.0.0.1:${PORT} -``` - -### Step 1: Generate the image (single curl command) - -Call `/images/generations` through media-proxy. **You MUST use this exact request structure** — do not add `messages`, `response_format`, or any other parameters not shown here: - -```bash -# Save response to a temp file to avoid base64 flooding the terminal -curl -sk -X POST "https://127.0.0.1:${PORT}/api/media-proxy" \ - -H "Content-Type: application/json" \ - -d '{ - "serviceType": "image_gen", - "endpoint": "/images/generations", - "body": { - "model": "gpt-image-2", - "prompt": "Replace this with the image description (English usually gives better results)", - "size": "1024x1024", - "n": 1 - }, - "responseType": "json" - }' -o /tmp/dashscope-response.json - -# Check success and extract b64_json directly to image file (NEVER cat the response to stdout) -python3 -c " -import json, base64, sys -with open('/tmp/dashscope-response.json') as f: - resp = json.load(f) -if not resp.get('success'): - print('ERROR:', json.dumps(resp, ensure_ascii=False)[:500]) - sys.exit(1) -b64 = resp['data']['data'][0]['b64_json'] -with open('/tmp/dashscope-gen.png', 'wb') as f: - f.write(base64.b64decode(b64)) -print('OK: saved to /tmp/dashscope-gen.png') -" -``` - -**CRITICAL**: The response contains a large base64 image (~2MB). NEVER print the raw response or b64_json to the terminal. Always save to file with `-o` and extract with the python3 script above. - -**Response format** (saved in `/tmp/dashscope-response.json`): -```json -{ - "success": true, - "data": { - "created": 1781060911, - "data": [{"b64_json": ""}], - "size": "1024x1024" - } -} -``` - -### Step 2: Upload to media-store - -```bash -curl -sk -X POST "https://127.0.0.1:${PORT}/api/media/upload" \ - -F "file=@/tmp/dashscope-gen.png;type=image/png" -``` - -Pick the `mediaId` field from the JSON response (format `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.png`). - -### Step 3: Render the image via the dc-media protocol - -In your reply text, write Markdown image syntax directly: - -``` -![Image description](dc-media://replace-with-mediaId) -``` - -For example: `![White fox in a forest](dc-media://a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6.png)` - -The frontend will translate `dc-media://` into a reachable image URL and render it. - -## Parameter Mapping - -### Size selection - -Pass `size` in the `body` object: +Example tool arguments after resolving the saved provider (replace the placeholder, do not send it literally): ```json { - "model": "gpt-image-2", - "prompt": "your image description", - "size": "1024x1024", + "provider": "", + "prompt": "A warm, quiet library illustration, without lettering", "n": 1 } ``` -| User intent | size value | -|-------------|-----------| -| Square / avatar / default | "1024x1024" | -| Landscape / scenery / wallpaper | "1536x1024" | -| Portrait / mobile / poster | "1024x1536" | +The raw API path below remains available for supported native operations or providers that need it. Do not interpret this example as a requirement to bypass a suitable generation tool. -### Optional parameters (top-level body fields) +## Raw API path -| Parameter | Description | -|-----------|-------------| -| `n` | Number of images, 1-4, default 1 | -| `size` | Image size, e.g. "1024x1024" | +### Resolve the local service and request -## Multiple Image Generation +Use the current agent-service address and caller authentication from the system's local API instructions, including the current isolated home. Do not guess another instance's port or obtain an upstream key. For a self-signed local HTTPS certificate, curl can use `-k` as directed by that local API contract. -When `n > 1`, download and upload each image, then render them one by one: +For an OpenAI-compatible image-generation provider, submit `POST /api/media-proxy` with the resolved provider ID and upstream model ID. The proxy injects upstream authentication. This request is an example structure; model-specific endpoints, supported sizes/counts, and response fields must follow that provider's current contract: -``` -![Image 1 description](dc-media://mediaId1) -![Image 2 description](dc-media://mediaId2) +```json +{ + "providerId": "", + "serviceType": "image_gen", + "endpoint": "/images/generations", + "body": { + "model": "", + "prompt": "A warm, quiet library illustration, without lettering", + "n": 1 + }, + "responseType": "json" +} ``` -## Error Handling +`serviceType` alone selects a provider; it does not populate `body.model`. Keep the resolved provider/model binding together. If the saved provider or model is missing, disabled, or unsupported by the chosen path, explain the actual limitation rather than silently choosing a different one. Native DashScope and other protocols may require a different documented request; do not send an OpenAI-compatible payload to an unrelated endpoint. -| Error | Meaning | Action | -|-------|---------|--------| -| `"No matching provider"` | No enabled provider supports `image_gen` | Tell user to enable a provider with image_gen support in settings | -| `"API Key not configured"` | API Key missing | Tell user to configure API key | -| `statusCode: 401` | API Key invalid or expired | Tell user to check API key | -| `statusCode: 429` | Rate limited | Wait and retry once | -| `statusCode: 400` + `model_price_error` | Model not available on current provider | Switch to `gpt-image-2` and retry | -| `statusCode: 400` | Other bad parameters | Check model name and size are from the tables above | +### Persist and display the result -**On model error**: If `wan2.7-image` or `wan2.7-image-pro` fails with `model_price_error`, automatically retry with `gpt-image-2`. Do NOT ask the user before retrying. +Save a potentially large response to a unique temporary file (`mktemp` or equivalent). Do not print raw responses, base64 image data, authorization headers, or signed download URLs. Check the proxy's `success` and the provider's actual response. Decode `b64_json` or download returned image URLs as appropriate; Python may be used for local JSON/base64 handling. A failed request is not an image. -**On other errors**: Report the error to the user clearly. Do NOT try alternative endpoints or read config files. +Upload each resulting image through `POST /api/media/upload` using multipart field `file`, then read the returned `mediaId`. Temporary paths are staging locations, not final deliverables. Display the persisted image using the actual returned ID: -## Notes +```text +![Image description](dc-media://) +``` -- Image generation calls are synchronous and typically return in 10-60 seconds -- English prompts usually produce the best results; Chinese is also supported -- When the user does not specify a model or size, default to `gpt-image-2` + `1024x1024` +When using `GenerateImage`, consume its persisted image content/metadata directly; an additional manual upload is unnecessary. Check the actual image and dimension receipt before claiming the requested size, aspect ratio, lettering constraints, or visual content was achieved. + +## Failures and recovery + +- Report the selected provider/model, whether the failure was local validation or an upstream response, and a bounded, sanitized error code/message. Do not expose credentials or raw response bodies. +- Missing configuration, missing credentials, authentication failures, quota/rate limits, unsupported parameters, and upstream channel failures are different conditions. Diagnose from actual evidence; an HTTP status alone does not establish which model or account is at fault. +- `model_not_found`, `model_price_error`, or “No available channel” can indicate that the selected gateway lacks an authorized route. Recheck the current binding/catalog and report that service limitation. Do not automatically switch to another model or provider, including a model mentioned in an older example. +- Retry or choose an alternative only when the response and the user's authorization support it. Preserve explicit model/provider and cost constraints; request the user's choice if a different service is needed. Do not claim success until an image has been generated and persisted. diff --git a/skills/dashscope-image-gen/SKILL.zh-CN.md b/skills/dashscope-image-gen/SKILL.zh-CN.md index 304457d..b4ac48c 100644 --- a/skills/dashscope-image-gen/SKILL.zh-CN.md +++ b/skills/dashscope-image-gen/SKILL.zh-CN.md @@ -2,171 +2,72 @@ # dashscope-image-gen 技能 -## 强制规则(违反将导致功能失败) +## 范围与前提 -1. **严格按下方步骤执行** — 禁止自行探索其他端点、尝试本文档未列出的模型、或读取配置文件 -2. **必须用 HTTPS 访问 agent-service** — API 地址已在系统提示词的"本机 API"部分提供(如 `https://127.0.0.1:PORT`),直接使用,加 `-k` 跳过证书验证 -3. **必须通过 `/api/media/upload` 上传到 media-store** — 禁止保存到本地路径 -4. **必须使用 `dc-media://` 协议展示图片** — 唯一能让前端正确渲染的方式 -5. **全程使用 Bash curl** — 不要使用 HttpRequest 工具或 Python -6. **使用 `/images/generations` 端点** — 同步调用,响应包含 b64_json 图片数据 -7. **只能使用下方模型列表中的模型** — 禁止尝试 dall-e-3、qwen-vl 或任何未列出的模型 +使用已配置的图片生成服务生成并交付图片。本技能不提供托管模型、凭据、额度或订阅。用户需要启用 `image_gen` 供应商,并拥有所选模型的访问权限;供应商条款及单独的使用费用仍适用。目录中存在模型不代表上游通道当前可用。 -## 供应商与默认算力 +## 模型与供应商选择 -**无需指定供应商**,只需传 `"serviceType": "image_gen"`,系统会自动路由到正确的供应商。 +1. 尊重用户明确指定的模型与供应商。根据当前运行时目录和对应 API 契约核实,不凭模型家族或本技能名称猜测。 +2. 用户未指定模型时,使用已保存的 `defaultServiceMap.image_gen` 绑定,包括其供应商。不要用示例中的型号覆盖默认值。如果没有可用默认,检查当前启用的图片生成能力,在用户要求内选择;选择会改变用户指定服务或费用约束时先澄清。 +3. 通过可用的算力查询工具,或当前 agent-service 的 `GET /api/compute/config` 解析绑定。配置 API 对密钥做掩码;只提取请求所需的默认绑定、供应商 ID/启用状态和图片模型元数据,不索取或输出凭据。模型 `serviceType` 可以是 `image_gen`,也可以是包含它的数组。原始 API 请求的上游模型 ID 依次取 `userOverrides.apiModelId`、`apiModelId`、`modelName`。 +4. 可用性以实际选中供应商和响应为准。本技能没有静态模型白名单或保证可用的默认型号。例如万相模型既可能由官方网关提供,也可能来自用户自己的 DashScope 连接;不能仅凭名称决定路由。 -**禁止**尝试查询供应商列表、读取 compute.json、或通过 API 探索可用模型。下方列出的模型保证可用。 +## 选择执行方式 -## 模型选择指南 +选择适合本次请求的当前工具/API 契约。`GenerateImage` 可用且满足需求时,一次调用即可完成供应商适配、生成、媒体持久化与尺寸回执;必要时先发现其当前 Schema。使用已保存默认时,将其供应商 ID 作为 `provider`,省略 `model`,让工具解析已保存型号;显式指定型号时,传入已核实的模型 ID 和供应商。保留用户的提示词、参考图、数量与尺寸要求。 -| 模型 | 特点 | 适用场景 | -|------|------|---------| -| gpt-image-2 | 高画质,速度快,风格多样 | **默认首选** — 用户未指定模型时使用 | -| wan2.7-image | 标准高画质(需配置阿里云 DashScope) | 仅当用户明确要求万相 / DashScope 时 | -| wan2.7-image-pro | 旗舰,4K 分辨率(需配置阿里云 DashScope) | 仅当用户明确要求最高画质万相模型时 | - -**默认规则**:用户未指定模型时,使用 `gpt-image-2`。 - -**注意**:`wan2.7-image` 和 `wan2.7-image-pro` 仅在用户自行配置了阿里云 DashScope 供应商时可用。如果使用这些模型出错,自动降级到 `gpt-image-2`。 - -## 完整执行流程(严格按此步骤执行) - -### 获取 API 地址 - -系统提示词中"本机 API"部分已包含 agent-service 的地址(如 `Agent Service: https://127.0.0.1:61000`)。直接从中提取 URL 使用。 - -如果无法从系统提示词中找到,使用以下兜底方式: - -```bash -PORT=$(cat "${DESIRECORE_HOME:-$HOME/.desirecore}/agent-service.port") -# 然后使用 https://127.0.0.1:${PORT} -``` - -### 第一步:生成图片(单次 curl 调用) - -通过 media-proxy 调用 `/images/generations` 端点。**必须严格使用以下请求结构** — 禁止添加 `messages`、`response_format` 或任何未在此处列出的参数: - -```bash -# 将响应保存到临时文件,避免 base64 数据灌入终端 -curl -sk -X POST "https://127.0.0.1:${PORT}/api/media-proxy" \ - -H "Content-Type: application/json" \ - -d '{ - "serviceType": "image_gen", - "endpoint": "/images/generations", - "body": { - "model": "gpt-image-2", - "prompt": "这里替换为图片描述(建议英文效果更好)", - "size": "1024x1024", - "n": 1 - }, - "responseType": "json" - }' -o /tmp/dashscope-response.json - -# 检查成功并直接将 b64_json 提取为图片文件(禁止将响应内容输出到终端) -python3 -c " -import json, base64, sys -with open('/tmp/dashscope-response.json') as f: - resp = json.load(f) -if not resp.get('success'): - print('ERROR:', json.dumps(resp, ensure_ascii=False)[:500]) - sys.exit(1) -b64 = resp['data']['data'][0]['b64_json'] -with open('/tmp/dashscope-gen.png', 'wb') as f: - f.write(base64.b64decode(b64)) -print('OK: saved to /tmp/dashscope-gen.png') -" -``` - -**关键警告**:响应包含大约 2MB 的 base64 图片数据。**禁止**将原始响应或 b64_json 打印到终端。始终使用 `-o` 保存到文件,再用上面的 python3 脚本提取。 - -**响应格式**(保存在 `/tmp/dashscope-response.json` 中): -```json -{ - "success": true, - "data": { - "created": 1781060911, - "data": [{"b64_json": "<非常大的 base64 字符串>"}], - "size": "1024x1024" - } -} -``` - -### 第二步:上传到 media-store - -```bash -curl -sk -X POST "https://127.0.0.1:${PORT}/api/media/upload" \ - -F "file=@/tmp/dashscope-gen.png;type=image/png" -``` - -从上传 JSON 响应中提取 `mediaId` 字段(格式如 `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.png`)。 - -### 第三步:用 dc-media 协议展示图片 - -在你的回复文本中直接写 Markdown 图片语法: - -``` -![图片描述](dc-media://这里替换为mediaId) -``` - -例如:`![森林中的白色狐狸](dc-media://a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6.png)` - -前端会自动将 `dc-media://` 转为可访问的图片 URL 并渲染出来。 - -## 参数映射 - -### 尺寸选择 - -`size` 放在 `body` 对象中: +解析默认供应商后的工具参数示例(先替换占位符,不要原样发送): ```json { - "model": "gpt-image-2", - "prompt": "图片描述", - "size": "1024x1024", + "provider": "", + "prompt": "A warm, quiet library illustration, without lettering", "n": 1 } ``` -| 用户意图 | size 参数 | -|---------|-----------| -| 正方形/头像/默认 | "1024x1024" | -| 横版/风景/壁纸 | "1536x1024" | -| 竖版/手机/海报 | "1024x1536" | +下方原始 API 路径仍可用于其支持的原生操作或需要它的供应商。不要把该示例理解为必须绕过适用的生成工具。 -### 可选参数(加入请求体顶层) +## 原始 API 路径 -| 参数 | 说明 | -|------|------| -| `n` | 生成数量 1-4,默认 1 | -| `size` | 图片尺寸,如 "1024x1024" | +### 解析本机服务与请求 -## 多图生成 +使用系统“本机 API”指引提供的当前 agent-service 地址与调用方认证,包括当前隔离 home。不要猜测其他实例端口,也不要获取上游密钥。本机 HTTPS 使用自签证书时,可按该本机 API 契约为 curl 使用 `-k`。 -当 `n > 1` 时,为每张图片执行下载+上传,然后逐一展示: +对于兼容 OpenAI 图片生成协议的供应商,向 `POST /api/media-proxy` 提交已解析的供应商 ID 和上游模型 ID,代理负责注入上游认证。下方仅为请求结构示例;模型专用端点、支持的尺寸/数量和响应字段必须遵循该供应商当前契约: -``` -![图片1描述](dc-media://mediaId1) -![图片2描述](dc-media://mediaId2) +```json +{ + "providerId": "", + "serviceType": "image_gen", + "endpoint": "/images/generations", + "body": { + "model": "", + "prompt": "A warm, quiet library illustration, without lettering", + "n": 1 + }, + "responseType": "json" +} ``` -## 错误处理 +仅传 `serviceType` 会选择供应商,不会自动填写 `body.model`。保持已解析的供应商/模型绑定一致。如果保存的供应商或模型缺失、被禁用,或所选路径不支持它,说明实际限制,不静默另选。原生 DashScope 等协议可能需要不同的文档化请求,不要向不相干的端点发送 OpenAI 兼容载荷。 -| 错误 | 含义 | 处理方式 | -|------|------|---------| -| `"未找到匹配的供应商"` | 没有启用的供应商支持 `image_gen` | 告知用户在设置中启用支持 image_gen 的供应商 | -| `"未配置 API Key"` | 未填写 API Key | 告知用户配置 API Key | -| `statusCode: 401` | API Key 无效或过期 | 告知用户检查 API Key | -| `statusCode: 429` | 频率限制 | 等待后重试一次 | -| `statusCode: 400` + `model_price_error` | 模型在当前供应商不可用 | 切换到 `gpt-image-2` 重试 | -| `statusCode: 400` | 其他参数错误 | 检查模型名和尺寸是否在上表中 | +### 持久化与展示结果 -**模型出错时**:如果 `wan2.7-image` 或 `wan2.7-image-pro` 报 `model_price_error`,自动切换到 `gpt-image-2` 重试。无需询问用户。 +将可能很大的响应保存至唯一临时文件(`mktemp` 或等价方式)。不打印原始响应、base64 图片数据、认证头或带签名下载 URL。检查代理的 `success` 与供应商实际响应,按实际格式解码 `b64_json` 或下载返回的图片 URL;可用 Python 处理本地 JSON/base64。失败请求不是图片。 -**其他错误时**:直接向用户清晰报告错误。禁止尝试其他端点或读取配置文件。 +通过 `POST /api/media/upload` 的 multipart `file` 字段上传每张图片,读取返回的 `mediaId`。临时路径只用于中转,不是最终交付物。用实际返回的 ID 展示持久化图片: -## 注意事项 +```text +![Image description](dc-media://) +``` -- 图片生成调用是同步的,通常 10-60 秒返回 -- 提示词建议用英文以获得最佳效果,中文也支持 -- 如果用户未明确要求模型/尺寸,默认使用 `gpt-image-2` + `1024x1024` +使用 `GenerateImage` 时直接使用其持久化图片内容/元数据,无需再手动上传。核对实际图片与尺寸回执后,再声明请求的尺寸、比例、无字约束或画面内容是否达成。 + +## 失败与恢复 + +- 说明本次选中的供应商/模型、失败来自本地校验还是上游响应,以及有界、脱敏的错误码/信息。不暴露凭据或原始响应体。 +- 配置缺失、凭据缺失、认证失败、额度/限流、参数不支持和上游通道故障是不同情况。依据实际证据诊断,不能仅凭 HTTP 状态判定哪个模型或账号有问题。 +- `model_not_found`、`model_price_error` 或“No available channel”可能表示选中的网关没有授权路由。核对当前绑定/目录,说明该服务限制;不要自动切换其他模型或供应商,包括旧示例提及的型号。 +- 只有响应证据和用户授权支持时才重试或另选方案。保留显式模型/供应商和费用约束;需要不同服务时让用户选择。图片实际生成并持久化之前不得宣称成功。 diff --git a/skills/dashscope-image-gen/catalog-metadata.v1.json b/skills/dashscope-image-gen/catalog-metadata.v1.json index 77f462e..f055e8c 100644 --- a/skills/dashscope-image-gen/catalog-metadata.v1.json +++ b/skills/dashscope-image-gen/catalog-metadata.v1.json @@ -10,13 +10,13 @@ "i18n": { "zh-CN": { "name": "AI 文生图", - "summary": "AI 文本生成图片技能(支持 GPT Image / 通义万相)", - "description": "当用户希望生成图片时使用此技能。支持多种模型:gpt-image-2(默认,通过 DesireCore Cloud)、wan2.7-image-pro / wan2.7-image(用户自行配置阿里云 DashScope 时可用)。通过 OpenAI 兼容的 /images/generations API 同步生成图片。 用户提到 生成图片、画图、文生图、创建图片、AI 绘画、生成插图、画一张、帮我画、设计图片。" + "summary": "遵循已配置默认与实际模型目录生成图片", + "description": "按用户明确选择或已保存的图片生成默认与当前运行时目录生成图片。需要已启用的供应商、模型访问权限及额度;供应商条款与单独使用费用仍适用。适用于画图、插画、文生图与 AI 图片创作。" }, "en-US": { "name": "AI Image Generation", - "summary": "AI text-to-image generation (GPT Image / Wan models)", - "description": "Use this skill when the user wants to generate images. Supports multiple models: gpt-image-2 (default via DesireCore Cloud), wan2.7-image-pro / wan2.7-image (when user has DashScope configured). Uses the OpenAI-compatible /images/generations API. Trigger keywords: generate image, draw, text-to-image, create image, AI painting, illustration, design picture." + "summary": "Generate images with configured defaults and the runtime catalog", + "description": "Generate images using the user’s explicit choice or saved image-generation default and the current runtime catalog. Requires an enabled provider, model access and quota; provider terms and separate usage charges apply. Use for drawing, illustrations, text-to-image and AI image creation." } }, "category": "media", @@ -30,14 +30,14 @@ }, "release": { "state": "known", - "version": "1.4.2", + "version": "1.4.3", "versionScheme": "semver" }, "timestamps": { "catalogUpdatedAt": { "state": "known", - "value": "2026-07-14T03:55:22Z", - "precision": "second" + "value": "2026-11-07", + "precision": "day" }, "releasePublishedAt": { "state": "unknown"