diff --git a/litellm/llms/bedrock/chat/converse_transformation.py b/litellm/llms/bedrock/chat/converse_transformation.py index 4e76fb24dc..59b83151f5 100644 --- a/litellm/llms/bedrock/chat/converse_transformation.py +++ b/litellm/llms/bedrock/chat/converse_transformation.py @@ -105,6 +105,8 @@ class AmazonConverseConfig(BaseConfig): } def get_supported_openai_params(self, model: str) -> List[str]: + from litellm.utils import supports_function_calling + supported_params = [ "max_tokens", "max_completion_tokens", @@ -137,6 +139,9 @@ class AmazonConverseConfig(BaseConfig): or base_model.startswith("meta.llama3-2") or base_model.startswith("meta.llama3-3") or base_model.startswith("amazon.nova") + or supports_function_calling( + model=model, custom_llm_provider=self.custom_llm_provider + ) ): supported_params.append("tools") diff --git a/tests/llm_translation/test_bedrock_completion.py b/tests/llm_translation/test_bedrock_completion.py index 2b10514d33..54cb1fd4ec 100644 --- a/tests/llm_translation/test_bedrock_completion.py +++ b/tests/llm_translation/test_bedrock_completion.py @@ -3141,3 +3141,49 @@ async def test_bedrock_max_completion_tokens(model: str): } + +def test_bedrock_meta_llama_function_calling(): + """ + Tests that: + - meta llama models support function calling + """ + tools = [ + { + "type": "function", + "function": { + "name": "get_current_weather", + "description": "Get the current weather in a given location", + "parameters": { + "type": "object", + "properties": { + "location": { + "type": "string", + "description": "The city and state, e.g. San Francisco, CA", + }, + "unit": { + "type": "string", + "enum": ["celsius", "fahrenheit"], + }, + }, + "required": ["location"], + }, + }, + } + ] + messages = [ + { + "role": "user", + "content": "What's the weather like in Boston today in fahrenheit?", + } + ] + request_args = { + "messages": messages, + "tools": tools, + "model": "bedrock/us.meta.llama4-scout-17b-instruct-v1:0", + } + + response = completion(**request_args) + + print(response) + + \ No newline at end of file