You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 36445c7
Browse filesBrowse the repository at this point in the historyBrowse files
* feat: allow custom models
* refactor: align custom model API with JS SDK shape
Drop the `models.custom(...)` factory in favor of constructing
`ModelDefinition(...)` directly, matching how the JS SDK exposes
custom models via the `CustomModelDefinition` type.
- `input_schema` becomes truly optional (`Optional[type[BaseModel]] = None`)
instead of using `BaseModel` as a sentinel.
- Add `queue_url_path` to `ModelDefinition`; populate it on the video
and image registry entries and use it from `submit_job`. Submitting a
model without `queue_url_path` raises `InvalidInputError` (mirrors the
JS check in `queue/request.ts`).
- Video registry `url_path` flips to `/v1/generate/<name>` to align
with the JS SDK; queue submissions now go through `queue_url_path`.
* refactor: collapse queue_url_path into url_path
Each model now has a single `url_path` field that points at its primary
endpoint:
- realtime: `/v1/stream`
- image: `/v1/generate/<name>`
- video: `/v1/jobs/<name>`
Queue, process, and realtime clients all submit/connect to
`{base_url}{model.url_path}`. This drops the JS-style split between
`urlPath` and `queueUrlPath` — JS only carries both because TypeScript
forces every model to have a `urlPath`. In Python a single field
suffices, since video models are queue-only and image models are
process-only via the registry.
Custom models continue to work: pass whichever endpoint is appropriate
for the API you intend to call (e.g. `url_path="/v1/jobs/<name>"` for a
custom queue model).
* fix: drop remaining models.custom() references
The realtime unit test and two docstrings still referenced the removed
`models.custom()` factory. Switch the test to constructing
`ModelDefinition` directly and update the docstrings to match.
Resolves the CI failure on Python 3.11 (and the Cursor Bugbot review).
* refactor: trim added comments and docstring chatter
Drop the "Custom models can omit an input schema..." comments — the
`if model.input_schema is None:` branch is self-explanatory.
Also tighten docstrings the PR over-extended:
- `DecartClient.queue` / `QueueClient`: drop the second-line "SDK accepts
any model definition..." preamble
- `DecartClient.process`: drop the "backend validates whether the model
supports this API" line and over-broad model list
- `QueueClient.submit`: drop the "Video models and custom queue model
definitions are supported" line
- `CustomModelDefinition`: collapse the two-paragraph docstring to one line
* test: drop cross-bucket model passthrough tests
Remove four tests that asserted process() accepts video/realtime
ModelDefinitions and queue.submit() accepts image/realtime
ModelDefinitions. They mocked the underlying request layer to pin
"the SDK does not gate by registry bucket", but they don't reflect
real usage — those calls would 404 against the backend because the
url_path of one model is wrong for the other API.
* test: clean up new tests added by the custom-model PR
- test_models.py: drop the validates-required-shape test (Pydantic's
own concern), and trim the over-asserting custom-model test to the
meaningful invariants (str name accepted, input_schema defaults None).
- test_process.py: drop test_process_allows_custom_model_definition_for_realtime_url_path,
same cross-bucket weirdness as the tests just removed.
- test_queue.py: drop test_queue_custom_model_uses_url_path (URL
construction is identical for registry and custom models, already
covered by test_queue_includes_user_agent_header). Refocus the
bouncer-error test as test_queue_submit_surfaces_backend_error using
a registry video model — the "custom" framing was incidental.
- Drop the misleading "accepts any model definition" file-level notes.
* docs: drop Custom Models README section
0 commit comments