mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-17 04:23:16 +08:00
初始化:独立 oclaw 仓库首提交
- 在 oclaw/ 下重新初始化 Git 仓库 - 补齐子仓库 .gitignore,避免提交本地运行态数据(_local、node_modules、logs 等) - 提交当前工程代码与配置 Made-with: Cursor
This commit is contained in:
commit
ba3836f00f
579 changed files with 83112 additions and 0 deletions
59
docs/GATEWAY_IMAGE_GENERATE.md
Normal file
59
docs/GATEWAY_IMAGE_GENERATE.md
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
# Gateway `image.generate` Contract
|
||||
|
||||
This document describes the Python gateway method `image.generate`.
|
||||
|
||||
## Method
|
||||
|
||||
- Name: `image.generate`
|
||||
- Handler: `oclaw/gateway/server_methods/image.py`
|
||||
|
||||
## Input Params
|
||||
|
||||
- `prompt` (required, non-empty string)
|
||||
- `provider` (optional, non-empty string)
|
||||
- `size` (optional, non-empty string)
|
||||
- `quality` (optional, non-empty string)
|
||||
- `idempotencyKey` (optional, non-empty string; used as `requestId` when provided)
|
||||
|
||||
## Behavior
|
||||
|
||||
1. If `context.image_generate` exists, it is used as the primary backend hook.
|
||||
2. Otherwise, the handler falls back to `extensions/image-generation-core/api.py::generate_image`.
|
||||
3. Provider resolution uses:
|
||||
- `context.image_generation_providers` first
|
||||
- then `context.get_runtime_snapshot()["image_generation_providers"]` (if available)
|
||||
4. Provider selection order:
|
||||
- explicit `provider` param
|
||||
- `context.config.image.defaultProvider`
|
||||
- first matched entry in `context.config.image.providerPriority`
|
||||
- first available capable provider
|
||||
5. Capability filter:
|
||||
- providers are considered image-capable when any of the following is true:
|
||||
- `capabilities.image_generation == true`
|
||||
- `capabilities` list contains `image` / `image_generation`
|
||||
- `kind` is `image` / `image_generation`
|
||||
- provider exposes callable `generate`
|
||||
|
||||
## Error Semantics
|
||||
|
||||
- `INVALID_REQUEST`:
|
||||
- missing/blank `prompt`
|
||||
- invalid optional parameter types/empty strings
|
||||
- `NOT_FOUND`:
|
||||
- explicit `provider` is not registered
|
||||
- `UNAVAILABLE`:
|
||||
- runtime/image backend failure
|
||||
|
||||
## Success Payload (normalized)
|
||||
|
||||
Success responses include normalized fields:
|
||||
|
||||
- `ok: true`
|
||||
- `status: "succeeded"`
|
||||
- `requestId: string`
|
||||
- `provider: string`
|
||||
- `model: string | null`
|
||||
- `prompt: string`
|
||||
|
||||
Provider-specific fields are preserved and merged into the payload.
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue