diff --git a/litellm/tests/test_get_optional_params_functions_not_supported.py b/litellm/tests/test_get_optional_params_functions_not_supported.py new file mode 100644 index 000000000..2abfbc41f --- /dev/null +++ b/litellm/tests/test_get_optional_params_functions_not_supported.py @@ -0,0 +1,9 @@ +import litellm +from litellm import get_optional_params + +litellm.add_function_to_prompt = True +optional_params = get_optional_params( + tools= [{'type': 'function', 'function': {'description': 'Get the current weather in a given location', 'name': 'get_current_weather', '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']}}}], + tool_choice= 'auto', +) +assert optional_params is not None \ No newline at end of file diff --git a/litellm/utils.py b/litellm/utils.py index 0b4aa0e87..88e395233 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -4836,7 +4836,7 @@ def get_optional_params( **kwargs, ): # retrieve all parameters passed to the function - passed_params = locals() + passed_params = locals().copy() special_params = passed_params.pop("kwargs") for k, v in special_params.items(): if k.startswith("aws_") and ( @@ -4933,6 +4933,7 @@ def get_optional_params( and custom_llm_provider != "mistral" and custom_llm_provider != "anthropic" and custom_llm_provider != "cohere_chat" + and custom_llm_provider != "cohere" and custom_llm_provider != "bedrock" and custom_llm_provider != "ollama_chat" ): @@ -4957,7 +4958,7 @@ def get_optional_params( litellm.add_function_to_prompt ): # if user opts to add it to prompt instead optional_params["functions_unsupported_model"] = non_default_params.pop( - "tools", non_default_params.pop("functions") + "tools", non_default_params.pop("functions", None) ) else: raise UnsupportedParamsError(