feat(ai): ImageRef enum with sync URL/path/bytes resolution #129
No reviewers
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_lib!129
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "development_ai_imageref"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
ImageRef— caller-intent enum withUrl(String),Path(PathBuf), andBytes { mime, data }variants — plusImageGenerationRequest::add_image_ref{,_with}builder methods that resolve the ref synchronously through the sharedimage_iopipeline.ureqclient (no new deps, no tokio). Downstream callers (hero_slides) can drop their ownreqwest/imagedeps.load_image_from_bytesfromload_image_from_pathso URL and pre-loaded bytes share the resize/transcode path.Design
See docs/adr/0001-imageref-abstraction-for-image-request-builder.md for the rationale — in short, the existing
ImageInputenum stays (it's the "what gets sent to the API" representation and legitimately passes URLs through).ImageRefis the new "what the caller has" layer on top;add_image_reffetches URLs / reads paths / re-encodes bytes, then attaches the result asImageInput::Bytes.Dependency
This PR depends on #125 — it is branched off
development_ai_image_generationand extends the builder introduced there. Please merge #125 first, then rebase/re-target this PR ontodevelopment.Closes #128.
Test plan
cargo test -p herolib_ai --lib— 64 passed (3 new ImageRef tests)cargo check --workspacein siblinghero_slides2repo still green via path-patch🤖 Generated with Claude Code
Adds `ImageRef` — a caller-intent enum with `Url(String)`, `Path(PathBuf)`, and `Bytes { mime, data }` variants — plus `ImageGenerationRequest:: add_image_ref{,_with}` methods that resolve the ref synchronously through the shared `image_io` pipeline. URL fetching uses the already-bundled blocking `ureq` client, so downstream callers (hero_slides) can drop their own `reqwest` / `image` dependencies. Also factors out `load_image_from_bytes` from `load_image_from_path` so URL and pre-loaded bytes share the resize/transcode path. See docs/adr/0001-imageref-abstraction-for-image-request-builder.md. Closes lhumina_code/hero_lib#128Consumer side proven: hero_slides commit
0251648on PR 21 adoptsImageRef/add_image_ref_withvia the../hero_libpath-patch. Workspace compiles green and all 47hero_slides_libtests pass. Validates the API surface proposed here (Url/Path/Bytes { mime, data }+ sync URL fetch).🤖 via Claude
Pull request closed