Repository navigation
Add media generation endpoints and local asset storage - #98
Merged
Merged
Conversation
… page - /v1/images/generations, /v1/images/edits (JSON), /v1/videos submit/query/content backed by upstream /v2/images/* and /v2/videos/*; chat endpoints reject media models with a pointer to the media API - Media routing: cn-cli whitelist, catalog membership with static fallback, positive balance; replay only on 401/403/429 or unsent bodies, 5xx/timeout never replayed; 401 alone cools accounts; video tasks stay account-bound - media.sqlite3 + media/ store: header-sniffed file whitelist, atomic commits, TTL and capacity eviction, CSP-sandboxed public serving at /v1/media/* - media_public_base_url / media_max_total_mb / media_ttl_hours settings with WebUI media page (library, tasks, models, settings drawer), admin /admin/media API, logs protocol badges, preview simulation and seeds, tests and docs
- Contract layer mirrors the CLI ImageService body: three-family branches, default 1024x1024 size, exact catalog tags, multiline prompts (32000-char shared bound), business-error envelope checks (MediaUpstreamError → 502 with upstream code, never replayed) - Media catalog scope reads the account root table (serves); CatalogIndex builds media_kinds for O(1) chat-guard and model-table lookups; preview moves media models to the root list with real tags - Store: payload staged in media/.incoming outside the lock, TTL derived from created + current setting (expires column dropped, schema v1), explicit task-error clearing; admin media routes answer 503 when the store is missing and serialize created_at/expires_at/updated_at - Gateway flow: image validation 400s, per-task refresh locks (one download), retryable vs deterministic download failures, concurrent multi-image downloads with partial-failure results and no orphans, store pre-check before billed upstream rounds, expired reads 404 - WebUI: created_at/expires_at/updated_at fields, catalog source labels, picture-style icon, i18n copy-failure text, warn hint on in-flight tasks with download retries; docs updated in pairs
- Image references get their own 20 MiB bound so data: URIs fit; prompts keep the 32000-char bound and blank prompts are rejected again - Video downloads fail permanently only on 403/404/410, refused types or over-quota payloads; other statuses and local store errors stay retryable - Store: best-effort unlink without shard rmdir, stale .incoming sweep, TTL-filtered listing and usage; control chars checked with one regex - Multi-image replies count every failed item, including unexpected exceptions, against the processed items only - Admin media routes keep the generic error envelope; TTL and quota come from the gateway helpers; tasks swept mid-refresh answer 404 - WebUI flags deferred downloads and localizes remaining-time labels
- Media replies carrying an account-restriction code, as an HTTP error or a non-zero business envelope, disable the account through note_restriction; codes in NO_FAILOVER_UPSTREAM_CODES are never replayed - Other media refusals keep their health isolation: only 401 reaches the cooldown path - Extract _apply_session_headers from _cred_for and use it for media leases, so media requests carry the same conversation and trace headers
|
Sorry @maiphucgiang, your pull request is larger than the review limit of 150,000 diff characters |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
enable_audiotypes are rejected instead of coerced.