Repository navigation
Conversation
…oat penalties - Make token detail breakdown fields in LLMGatewayCacheCreation, LLMGatewayPromptTokensDetails, and LLMGatewayCompletionTokensDetails Optional[int] = None so partial breakdowns (e.g. reasoning_tokens without audio_tokens) parse without validation errors - Add thinking: Optional[str] = None to LLMGatewayChunkDelta for streaming reasoning model parity - Support float frequency_penalty and optional presence_penalty in LLMGatewayDefaultParameters - Add unit tests for partial token details, thinking delta, and float penalties - Bump version to 1.6.1 for version bump check
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
When LLM Gateway proxies models that return partial token details (such as OpenAI reasoning models returning
completion_tokens_details: {"reasoning_tokens": 128}without audio/prediction fields, or Claude models returningprompt_tokens_details: {"cached_tokens": 512}without audio fields), Pydantic raised aValidationErrorbecause all breakdown fields were declared as required integers.This PR makes token detail breakdown fields optional with a default of
None, addsthinkingdelta support for streamed reasoning models, and ensures model penalty parameters support float values.Changes
assemblyai/llm_gateway/v1/models.py:LLMGatewayCacheCreation,LLMGatewayPromptTokensDetails, andLLMGatewayCompletionTokensDetails, declare breakdown fields asOptional[int] = Noneso partial breakdowns from upstream providers parse cleanly.LLMGatewayChunkDelta, addthinking: Optional[str] = Nonefor parity withLLMGatewayResponseMessage.thinkingduring streamed completions with reasoning/thinking models.LLMGatewayDefaultParameters, updatefrequency_penaltytoOptional[float] = Noneand addpresence_penalty: Optional[float] = None.tests/unit/test_llm_gateway.py:test_chat_completions_tolerates_partial_token_detailscovering partial prompt caching and reasoning token breakdowns.test_stream_chunk_exposes_thinking_deltaverifying streamed reasoning delta parsing.test_list_models_tolerates_float_penalties_and_presence_penaltyverifying float model parameter parsing.assemblyai/__version__.py:1.6.1to satisfy CI version bump check.Backwards Compatibility
All new/modified fields are
OptionalwithNonedefaults or widen integer types to floats, preserving full compatibility with existing code and responses.