Repository navigation
feat(bedrock): pass chat through to each model's native openai endpoint on runtime and mantle #43581
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
Closed
devin-ai-integration
wants to merge
6
commits into
litellm_bedrock_grok_chat_completions
from
litellm_bedrock_native_endpoint_passthrough
Closed
feat(bedrock): pass chat through to each model's native openai endpoint on runtime and mantle #43581
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ac42eb1
feat(bedrock): pass chat through to each model's native openai endpoi…
mateo-berri f80c583
fix(bedrock): regenerate model pricing schema
mateo-berri bcf0cd9
fix(bedrock): preserve legacy functions and bridge web search
mateo-berri 6fc79b0
refactor(bedrock): centralize Mantle Responses bridge eligibility
mateo-berri 50f5487
Merge remote-tracking branch 'origin/litellm_bedrock_grok_chat_comple…
mateo-berri c22b3ab
fix(bedrock): honor regional Mantle rows and dict none effort in Resp…
mateo-berri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from collections.abc import Mapping, Sequence | ||
| from types import MappingProxyType | ||
| from typing import Final, Protocol, cast, runtime_checkable | ||
|
|
||
|
|
||
| @runtime_checkable | ||
| class _FunctionToolLike(Protocol): | ||
| type: str | ||
|
|
||
|
|
||
| def has_function_tool(tools: object) -> bool: | ||
| if not isinstance(tools, Sequence): | ||
| return False | ||
| typed_tools: Final = cast(Sequence[object], tools) # cast-ok: a runtime Sequence contains Python objects | ||
| return any(_is_function_tool(tool) for tool in typed_tools) | ||
|
|
||
|
|
||
| def _is_function_tool(tool: object) -> bool: | ||
| if not isinstance(tool, Mapping): | ||
| return isinstance(tool, _FunctionToolLike) and tool.type == "function" | ||
| tool_mapping: Final = cast(Mapping[str, object], tool) # cast-ok: OpenAI tool mappings have string keys | ||
| function: Final = tool_mapping.get("function") | ||
| return tool_mapping.get("type") == "function" and (isinstance(function, Mapping) or "name" in tool_mapping) | ||
|
|
||
|
|
||
| def reasoning_effort_is_active( | ||
| reasoning_effort: object, | ||
| supports_none_reasoning_effort: bool | None = None, | ||
| ) -> bool: | ||
| if isinstance(reasoning_effort, Mapping): | ||
| effort_mapping: Final = cast( # cast-ok: reasoning payload keys are strings | ||
| Mapping[str, object], reasoning_effort | ||
| ) | ||
| return ( | ||
| effort_mapping.get("effort") != "none" | ||
| or effort_mapping.get("summary") is not None | ||
| or supports_none_reasoning_effort is False | ||
| ) | ||
| return reasoning_effort != "none" or supports_none_reasoning_effort is False | ||
|
|
||
|
|
||
| def peek_reasoning_summary_aliases(optional_params: Mapping[str, object]) -> object | None: | ||
| if "reasoningSummary" in optional_params: | ||
| return optional_params["reasoningSummary"] | ||
| if "reasoning_summary" in optional_params: | ||
| return optional_params["reasoning_summary"] | ||
| extra_body: Final = optional_params.get("extra_body") | ||
| if isinstance(extra_body, Mapping): | ||
| extra_body_mapping: Final = cast( # cast-ok: extra_body uses JSON object keys | ||
| Mapping[str, object], extra_body | ||
| ) | ||
| if "reasoningSummary" in extra_body_mapping: | ||
| return extra_body_mapping["reasoningSummary"] | ||
| if "reasoning_summary" in extra_body_mapping: | ||
| return extra_body_mapping["reasoning_summary"] | ||
| return None | ||
|
|
||
|
|
||
| def filter_additional_drop_params( | ||
| request_params: Mapping[str, object], | ||
| additional_drop_params: Sequence[str] | None, | ||
| ) -> Mapping[str, object]: | ||
| dropped: Final = frozenset(additional_drop_params or ()) | ||
| return MappingProxyType({key: value for key, value in request_params.items() if key not in dropped}) | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.