Skip to content

feat(models): add native Gemini reference adapter - #39

Open
itzgeebee wants to merge 1 commit into
lunarstack-co:mainfrom
itzgeebee:feat/gemini-native-adapter
Open

itzgeebee wants to merge 1 commit into
lunarstack-co:mainfrom
itzgeebee:feat/gemini-native-adapter

Conversation

@itzgeebee

Copy link
Copy Markdown

Closes #30

What changed

Add a copyable GeminiModel adapter for native streamGenerateContent over httpx. It maps text, thoughts, function calls/results, finish reasons and cumulative usage, preserves signed model parts through provider_data, and classifies HTTP, transport and malformed-stream errors without retrying.

Register the adapter with record.py, list it in the README and changelog, and add a fixture plus offline contract/failure tests. Extend fixture recording to redact Google's x-goog-api-key header.

Validation

  • Ruff lint and formatting: passed.
  • Mypy across src/tests/examples and strict mypy on src: passed.
  • Full pytest suite: 589 passed, 7 skipped.
  • Gemini unit tests: 51 passed; the fixture passes all eight check_model rules.
  • uv build: passed.

Live validation pending

The fixture is explicitly documented as hand-written responses captured through record.py over httpx.MockTransport, following the repository's existing fixture convention. It is not a live Gemini recording.

Live model discovery succeeded with the native API. Text and tool generation still need successful live validation before this draft is ready. The fixture README includes the command to replace the two successful mock exchanges with a real recording.

Add native streaming, function calls, thought-signature replay, token usage and error mapping. Integrate the recorder, redact Google API key headers, and cover the adapter with offline conformance and failure tests.
@itzgeebee
itzgeebee marked this pull request as ready for review November 5, 2026 13:10

@folathecoder folathecoder left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@itzgeebee Thanks — solid native Gemini reference adapter; it fits the 0.2.0 “copyable examples/providers” direction well (signatures via provider_data, no retries, transport/extra_body, check_model + recorder wiring, x-goog-api-key redaction). Offline unit suite looks strong.

Requesting a few updates before merge:

  1. Live fixture (issue #30) — I re-recorded successfully with a free-tier key. Text + tool turns pass all 8 check_model rules. Please replace the hand-written fixture with a live recording (or document maintainer acceptance of a hand-written v1). Keep a third fixture line with HTTP 429 so test_reference_adapter_fixture_passes_check_model still asserts error_status == 429 (synthetic rate-limit line is fine if you aren’t rate-limited during record).

  2. Default / docs model — gemini-2.5-flash returns 404 for new users (“no longer available… use models/gemini-3.8-flash”). Please update README / record examples / defaults to a model new free-tier keys can call (e.g. gemini-3.8-flash), and note the 2.5→3.x availability gotcha.

  3. CHANGELOG — #38 also adds ## [Unreleased]; rebase/merge so Unreleased combines both entries without a duplicate heading.

  4. PR status — description still reads like a draft pending live validation; either mark draft until the fixture is updated, or update the body once the live fixture lands.

Happy to re-review as soon as that’s up.

@folathecoder folathecoder added the enhancement New feature or request label Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reference adapter for the Gemini native API

2 participants