Repository navigation
chore(release): backport #41870 to stable/1.101.x #42332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
|
|
||
| import copy | ||
| import json | ||
| import re | ||
| import time | ||
| import types | ||
| from collections.abc import Mapping | ||
|
|
@@ -105,6 +106,7 @@ | |
| "bash_", | ||
| "text_editor_", | ||
| ] | ||
| BEDROCK_OPENAI_COMPAT_MIN_MAX_TOKENS: Final = 16 | ||
|
|
||
| # Beta header patterns that are not supported by Bedrock Converse API | ||
| # These will be filtered out to prevent errors | ||
|
|
@@ -293,6 +295,10 @@ def _validate_request_metadata(self, metadata: dict) -> None: | |
| llm_provider="bedrock", | ||
| ) | ||
|
|
||
| @staticmethod | ||
| def _requires_min_max_tokens(model: str) -> bool: | ||
| return re.search(r"openai\.gpt-\d|xai\.grok-", model) is not None | ||
|
|
||
| def _is_nova_2_model(self, model: str) -> bool: | ||
| """ | ||
| Check if the model is a Nova 2 model that supports reasoningConfig. | ||
|
|
@@ -883,7 +889,11 @@ def map_openai_params( | |
| is_thinking_enabled=is_thinking_enabled, | ||
| ) | ||
| if param == "max_tokens" or param == "max_completion_tokens": | ||
| optional_params["maxTokens"] = value | ||
| optional_params["maxTokens"] = ( | ||
| max(value, BEDROCK_OPENAI_COMPAT_MIN_MAX_TOKENS) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Low: Token rate-limit under-reservation The rate-limit pre-call hook reserves the caller's original |
||
| if isinstance(value, int) and self._requires_min_max_tokens(model) | ||
| else value | ||
| ) | ||
| if param == "stream": | ||
| optional_params["stream"] = value | ||
| if param == "stop": | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This identifies model families with hardcoded name patterns. Repository rules require model-specific flags to live in model_prices_and_context_window.json and be read through get_model_info, so this must be addressed before merging
Rule Used: What: Do not hardcode model-specific flags in the codebase. Instead, put them in model_prices_and_context_window.json and then read them in via get_model_info Why: Prevents need for users to upgrade litellm each time a new model supports this featu... (source)
Knowledge Base Used: Provider adapters and capabilities