From daa371ade900a93b5b6abe0cc16d6c1e37ba01e8 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Fri, 8 Mar 2024 22:41:32 -0800 Subject: [PATCH] fix(utils.py): add support for anthropic params in get_supported_openai_params --- litellm/__init__.py | 2 +- litellm/utils.py | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/litellm/__init__.py b/litellm/__init__.py index 506147166e2..04c2d23c79b 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -570,7 +570,7 @@ from .utils import ( _calculate_retry_after, _should_retry, get_secret, - get_mapped_model_params, + get_supported_openai_params, ) from .llms.huggingface_restapi import HuggingfaceConfig from .llms.anthropic import AnthropicConfig diff --git a/litellm/utils.py b/litellm/utils.py index 32f0f765bd2..83f2a7ec1c2 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -4581,7 +4581,7 @@ def get_optional_params( if stream: optional_params["stream"] = stream elif "anthropic" in model: - supported_params = get_mapped_model_params( + supported_params = get_supported_openai_params( model=model, custom_llm_provider=custom_llm_provider ) _check_valid_arg(supported_params=supported_params) @@ -5048,7 +5048,7 @@ def get_optional_params( return optional_params -def get_mapped_model_params(model: str, custom_llm_provider: str): +def get_supported_openai_params(model: str, custom_llm_provider: str): """ Returns the supported openai params for a given model + provider """ @@ -5057,6 +5057,18 @@ def get_mapped_model_params(model: str, custom_llm_provider: str): return litellm.AmazonAnthropicClaude3Config().get_supported_openai_params() else: return litellm.AmazonAnthropicConfig().get_supported_openai_params() + elif custom_llm_provider == "ollama_chat": + return litellm.OllamaChatConfig().get_supported_openai_params() + elif custom_llm_provider == "anthropic": + return [ + "stream", + "stop", + "temperature", + "top_p", + "max_tokens", + "tools", + "tool_choice", + ] def get_llm_provider(