The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
correctly add modified tool names to cache
Ishaan Jaffd445f3967d1d
diff --git a/litellm/llms/prompt_templates/factory.py b/litellm/llms/prompt_templates/factory.pyindex db655c01d0d..6c055300606 100644--- a/litellm/llms/prompt_templates/factory.py+++ b/litellm/llms/prompt_templates/factory.py@@ -1,3 +1,4 @@+import copyimport jsonimport reimport traceback@@ -2310,13 +2311,20 @@ def make_valid_bedrock_tool_name(input_tool_name: str) -> str:# If the string is empty, return a default valid identifierif input_tool_name is None or len(input_tool_name) == 0:return input_tool_name-+ bedrock_tool_name = copy.copy(input_tool_name)# If it doesn't start with a letter, prepend 'a'- if not input_tool_name[0].isalpha():- input_tool_name = "a" + input_tool_name+ if not bedrock_tool_name[0].isalpha():+ bedrock_tool_name = "a" + bedrock_tool_name# Replace any invalid characters with underscores- valid_string = "".join(replace_invalid(char) for char in input_tool_name)+ valid_string = "".join(replace_invalid(char) for char in bedrock_tool_name)++ if input_tool_name != valid_string:+ # passed tool name was formatted to become valid+ # store it internally so we can use for the response+ litellm.bedrock_tool_name_mappings.set_cache(+ key=valid_string, value=input_tool_name+ )return valid_string