fix(models): forward generation config parameters in AnthropicLlm#5513
Open
sebastienc wants to merge 2 commits intogoogle:mainfrom
Open
fix(models): forward generation config parameters in AnthropicLlm#5513sebastienc wants to merge 2 commits intogoogle:mainfrom
sebastienc wants to merge 2 commits intogoogle:mainfrom
Conversation
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 #5393
Disclaimer: I'm using Claude Code to generate the following text. I find the summary is better than what I would've wrote.
AnthropicLlmwas silently ignoringtemperature,top_p,top_k, andstop_sequencesfromGenerateContentConfig. This change wires them through to both the streaming and non-streamingmessages.createcalls, and addsoutput_config.effortsupport via a newAnthropicGenerateContentConfigescape hatch and aThinkingLevel→ effort mapping.temperature/top_p/top_k/stop_sequences— forwarded tomessages.createin both streaming and non-streaming paths; each is guarded byis not Noneso unset params remainNOT_GIVENrather thanNonetemperature,top_p, andtop_kare suppressed (sent asNOT_GIVEN) whenoutput_config.effortis active, since Anthropic does not allow sampling parameters alongside effort-based generation_build_effort_param— mapsThinkingConfig.thinking_levelto Anthropic'soutput_config.effortstring (MINIMAL→"low",LOW→"medium",MEDIUM→"high",HIGH→"xhigh"); also readsAnthropicGenerateContentConfig.effortdirectly for cases needing"max"AnthropicGenerateContentConfig— subclass ofGenerateContentConfigthat adds a singleeffortfield accepting"low" | "medium" | "high" | "xhigh" | "max"; callers who need the"max"effort level (not expressible viaThinkingLevel) can pass this config insteadTesting plan
12 new tests added to
tests/unittests/models/test_anthropic_llm.py. Full suite: 71 passed.