diff --git a/litellm/main.py b/litellm/main.py index 1fc18313d..5bb08cc99 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -255,6 +255,11 @@ def completion( frequency_penalty: Optional[float]=None, logit_bias: dict = {}, user: str = "", + # openai v1.0+ new params + response_format: Optional[dict] = None, + seed: Optional[int] = None, + tools: Optional[List] = None, + tool_choice: Optional[str] = None, deployment_id = None, # set api_base, api_version, api_key @@ -329,7 +334,7 @@ def completion( eos_token = kwargs.get("eos_token", None) acompletion = kwargs.get("acompletion", False) ######## end of unpacking kwargs ########### - openai_params = ["functions", "function_call", "temperature", "temperature", "top_p", "n", "stream", "stop", "max_tokens", "presence_penalty", "frequency_penalty", "logit_bias", "user", "request_timeout", "api_base", "api_version", "api_key", "deployment_id", "organization", "base_url", "default_headers", "timeout"] + openai_params = ["functions", "function_call", "temperature", "temperature", "top_p", "n", "stream", "stop", "max_tokens", "presence_penalty", "frequency_penalty", "logit_bias", "user", "request_timeout", "api_base", "api_version", "api_key", "deployment_id", "organization", "base_url", "default_headers", "timeout", "response_format", "seed", "tools", "tool_choice"] litellm_params = ["metadata", "acompletion", "caching", "return_async", "mock_response", "api_key", "api_version", "api_base", "force_timeout", "logger_fn", "verbose", "custom_llm_provider", "litellm_logging_obj", "litellm_call_id", "use_client", "id", "fallbacks", "azure", "headers", "model_list", "num_retries", "context_window_fallback_dict", "roles", "final_prompt_value", "bos_token", "eos_token", "request_timeout", "complete_response", "self", "max_retries"] default_params = openai_params + litellm_params non_default_params = {k: v for k,v in kwargs.items() if k not in default_params} # model-specific params - pass them straight to the model/provider @@ -400,6 +405,10 @@ def completion( # params to identify the model model=model, custom_llm_provider=custom_llm_provider, + response_format=response_format, + seed=seed, + tools=tools, + tool_choice=tool_choice, **non_default_params ) diff --git a/litellm/utils.py b/litellm/utils.py index 96ad325fc..808dc3323 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -1751,6 +1751,10 @@ def get_optional_params( # use the openai defaults user="", model=None, custom_llm_provider="", + response_format=None, + seed=None, + tools=None, + tool_choice=None, **kwargs ): # retrieve all parameters passed to the function @@ -1773,6 +1777,10 @@ def get_optional_params( # use the openai defaults "user":"", "model":None, "custom_llm_provider":"", + "response_format": None, + "seed": None, + "tools": None, + "tool_choice": None } # filter out those parameters that were passed with non-default values non_default_params = {k: v for k, v in passed_params.items() if (k != "model" and k != "custom_llm_provider" and k in default_params and v != default_params[k])} @@ -2166,7 +2174,7 @@ def get_optional_params( # use the openai defaults temperature = 0.0001 # close to 0 optional_params["temperature"] = temperature else: # assume passing in params for openai/azure openai - supported_params = ["functions", "function_call", "temperature", "top_p", "n", "stream", "stop", "max_tokens", "presence_penalty", "frequency_penalty", "logit_bias", "user"] + supported_params = ["functions", "function_call", "temperature", "top_p", "n", "stream", "stop", "max_tokens", "presence_penalty", "frequency_penalty", "logit_bias", "user", "response_format", "seed", "tools", "tool_choice"] _check_valid_arg(supported_params=supported_params) optional_params = non_default_params # if user passed in non-default kwargs for specific providers/models, pass them along