feat(llm): GOOGLE_AI_PERSONAL — route Gemini to consumer AI Studio key#26
Merged
Merged
Conversation
Stacks on PR #23. Adds a config switch that points GeminiProvider at the consumer Gemini API (generativelanguage.googleapis.com) with a personal AI Studio key, instead of Vertex on GOOGLE_CLOUD_PROJECT. When GOOGLE_AI_PERSONAL is set on AppConfig, GeminiProvider.get_client() returns genai.Client(api_key=...) instead of genai.Client(vertexai=True, location=...). Region selection is skipped on this path — the consumer API is globally routed. Empty string = disabled. Default behavior unchanged. Use: mint a key at https://aistudio.google.com/app/apikey, drop into /opt/sentry-extra/secrets/seer.env as GOOGLE_AI_PERSONAL=AIza..., recreate seer container. Rollback = unset + restart. 4 unit tests pin both branches of the routing decision.
Bugbot finding on PR #24: the `# noqa: B006` was hiding a real bug (shared-state across calls via the mutable default `list[str] = []`). The proper fix is small enough to do here: - Default `thinking_content_chunks: list[str] = []` (mutable) → `thinking_content_chunks: list[str] | None = None` + a guard `if thinking_content_chunks is None: thinking_content_chunks = []` at the top of the function. The Anthropic inner provider method expects a non-optional `list[str]`, so the normalization happens in the LlmClient wrapper — provider contract stays unchanged. Confirmed callsite safety: the only production caller in autofix_agent.py:232 passes `thinking_content_chunks` explicitly, so no caller relies on the mutable-default's empty-list identity. 8 tests pass (4 personal-key + the existing construct_message_from_stream coverage).
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.
Reopens #24 (auto-closed by GitHub when its base feat/summarize-flash-lite was deleted on PR #25 merge). Same diff, rebased onto current feature/explorer-endpoints.
Adds a config switch that points GeminiProvider at the consumer Gemini API (
generativelanguage.googleapis.com) with a personal AI Studio key, instead of Vertex on GOOGLE_CLOUD_PROJECT. Used to peel high-volume traffic off the billed org project — consumer API has a free tier and bills the personal account.When
GOOGLE_AI_PERSONALis set on AppConfig,get_client()returnsgenai.Client(api_key=...). Region/DE-lockout checks skipped (consumer API is globally routed). Empty string = disabled, default unchanged.Use:
GOOGLE_AI_PERSONAL=AIza...to /opt/sentry-extra/secrets/seer.envRollback: unset env + restart.
4 unit tests pin both branches of the routing decision (key-set, key-empty, region-skip, DE-bypass).
Bugbot review applied: properly fixed the B006 mutable-default-arg in
construct_message_from_streaminstead of papering over with# noqa—list[str] = []→list[str] | None = None+ normalize-at-top guard. Confirmed callsite safety (only one production caller, passes explicitly).