Repository navigation
Conversation
Contributor
|
This branch has not been deployed
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
Fixes Gemini 3.x / 3.5 reasoning configuration, regional/resource-path model normalization, and streaming token usage handling in the Gemini provider (
dspy/_vendor/lm15/providers/gemini.py):gemini_level_class):models/...,publishers/google/models/...) and regional endpoint prefixes (au.gemini-...,eu.gemini-...,us.gemini-...) and matchesgemini-3+models (^gemini-([3-9]|\d{2,})(?:\.\d+|-|$)).thinkingLevelandthinkingBudgetconstraints (GeminiLM._payload):reasoning.is_off:-pro), substitutesthinkingLevel: "low"(since"minimal"is rejected by Gemini 3 Pro / 3.1 Pro / 3.5 Pro) while keeping"minimal"for Flash models.thinkingBudget: 128(minimum supported budget;0is rejected) while keepingthinkingBudget: 0for Flash / Flash-Lite.effort == "minimal"to"low"on Gemini 3+ Pro models andeffort == "medium"to"high"ongemini-3-pro/gemini-3-pro-preview(while preserving"medium"ongemini-3.1-proandgemini-3.5-pro).thinkingConfig.includeThoughts = Truewhen reasoning is enabled (not was_off and reasoning.summary != "none"), ensuringdspy.Reasoning(adapt_to_native_lm_feature) receives native thought parts from Gemini.finish_reasonand usage preservation:GeminiLM.parse_stream_events, trailing usage-only SSE chunks (not yielded_delta and "usageMetadata" in payload) now emitStreamEndEvent(finish_reason=None, ...)socoalesce_streampreserves an earlierfinish_reason(such as"tool_call"or"max_tokens") instead of overwriting it with"stop".GeminiLM._stream_via_live_completion, accumulatesreasoning_tokensandcache_read_tokensalongsideinput_tokens,output_tokens, andtotal_tokens.Test Plan
tests/adapters/test_reasoning.pyandtests/clients/test_lm15_adaptations_and_timeouts.py.uv run --extra dev pytest tests/adapters/test_reasoning.py tests/clients/test_lm15_adaptations_and_timeouts.py tests/test_vendored_lm15.py.