-
-
Notifications
You must be signed in to change notification settings - Fork 11.6k
feat(bedrock): normalize custom tool JSON schema for Invoke and Converse #25396
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
8f4676a
83140e7
ec91021
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
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. what does this change do? @Sameerlite |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -796,15 +796,21 @@ def translate_anthropic_tools_to_openai( | |
| tool_name_mapping: Dict[str, str] = {} | ||
| mapped_tool_params = ["name", "input_schema", "description", "cache_control"] | ||
|
|
||
| for tool in tools: | ||
| for idx, tool in enumerate(tools): | ||
| # Check if this is an Anthropic-native tool that should be kept as-is | ||
| tool_type = tool.get("type", "") | ||
| if any(tool_type.startswith(t.value) for t in ANTHROPIC_HOSTED_TOOLS): | ||
| # Keep Anthropic-native tools in their original format | ||
| new_tools.append(tool) # type: ignore[arg-type] | ||
| continue | ||
|
|
||
| original_name = tool["name"] | ||
| raw_name = tool.get("name") | ||
| if raw_name is None or ( | ||
| isinstance(raw_name, str) and not str(raw_name).strip() | ||
| ): | ||
| original_name = f"litellm_unnamed_tool_{idx}" | ||
|
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. can you explain this?
Contributor
Author
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. @krrish-berri-2 The code in adapters/transformation.py is used for /v1/messages → litellm.completion adapter flows. For Bedrock, that mainly means bedrock/converse/... |
||
| else: | ||
| original_name = str(raw_name) | ||
| truncated_name = truncate_tool_name(original_name) | ||
|
|
||
| # Store mapping if name was truncated | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.