Skip to content

feat(api): add Gemini video metadata controls#161

Merged
seanbrar merged 4 commits intomainfrom
feat/gemini-video-metadata
Mar 21, 2026
Merged

feat(api): add Gemini video metadata controls#161
seanbrar merged 4 commits intomainfrom
feat/gemini-video-metadata

Conversation

@seanbrar
Copy link
Copy Markdown
Owner

@seanbrar seanbrar commented Mar 21, 2026

Summary

Add Source.with_gemini_video_settings(start_offset, end_offset, fps) for Gemini-specific video clipping and frame sampling. Settings are stored as generic provider hints so Gemini-isms stay behind a uniform wall in the core model, threaded through the pipeline, and materialized only in the Gemini adapter.

Related issue

None

Test plan

Three test boundaries exercised, all passing via just check:

  • Source boundary (test_source.py): validation (non-video rejection, invalid fps, blank offsets, at-least-one-value), provider scoping (Gemini returns settings, OpenAI/None return None), immutability, hashability, and payload isolation
  • Pipeline boundary (test_pipeline.py): video settings survive upload substitution end-to-end; cache identity varies with Gemini video settings but stays stable for non-Gemini providers
  • Provider characterization (test_providers.py): Gemini adapter attaches VideoMetadata to generate, create_cache, and deferred submission paths

Docs build verified clean (just docs-build).

Notes

  • ProviderHint is intentionally generic rather than a typed GeminiVideoSettings field on Source. This keeps provider-specific concerns behind a uniform wall and prevents Gemini-isms from drifting into the core model over time.
  • content_hash() was made private (_content_hash()) since callers should use cache_identity_hash() which incorporates provider context.
  • The Gemini adapter trusts Source-level validation and only does type narrowing (not full re-validation) before passing values to the SDK.

Sean Brar added 4 commits March 20, 2026 23:39
Introduce ProviderHint as a generic, provider-scoped extension on Source
so provider-specific metadata stays behind a uniform wall rather than
leaking Gemini-isms into the core model.

Add Source.with_gemini_video_settings() for validated clip windows and
FPS controls on video sources. Make content_hash() private since callers
should use cache_identity_hash() which incorporates provider context.
build_shared_parts now accepts a provider parameter and attaches
provider hints to transport dicts. Upload substitution in both the
execute and cache paths preserves hints through the file-to-URI
conversion. Cache identity uses cache_identity_hash so Gemini video
settings fragment Gemini cache keys without affecting other providers.
Translate provider hints into types.VideoMetadata in _convert_parts,
create_cache, and deferred request resolution. Source-level validation
is trusted; the adapter only does type narrowing and lets the SDK
try/except catch any remaining mismatches.
…pers

Add Gemini video clipping example to sending-content, note cache
identity behavior in caching docs, and reference the feature in the
portability guide, provider capabilities, API reference, and README.
@seanbrar seanbrar merged commit f72dc37 into main Mar 21, 2026
10 checks passed
@seanbrar seanbrar deleted the feat/gemini-video-metadata branch March 21, 2026 06:55
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 21, 2026

Codecov Report

❌ Patch coverage is 85.71429% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pollux/providers/gemini.py 64.70% 12 Missing ⚠️
src/pollux/plan.py 63.63% 4 Missing ⚠️
src/pollux/cache.py 92.30% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant