(feat) support extra_headers

This commit is contained in:
ishaan-jaff 2024-02-23 08:48:21 -08:00
parent e049858266
commit 3c8b58bd80
3 changed files with 23 additions and 0 deletions

View file

@ -3907,6 +3907,7 @@ def get_optional_params(
max_retries=None,
logprobs=None,
top_logprobs=None,
extra_headers=None,
**kwargs,
):
# retrieve all parameters passed to the function
@ -3946,6 +3947,7 @@ def get_optional_params(
"max_retries": None,
"logprobs": None,
"top_logprobs": None,
"extra_headers": None,
}
# filter out those parameters that were passed with non-default values
non_default_params = {
@ -4753,6 +4755,7 @@ def get_optional_params(
"max_retries",
"logprobs",
"top_logprobs",
"extra_headers",
]
_check_valid_arg(supported_params=supported_params)
if functions is not None:
@ -4793,6 +4796,8 @@ def get_optional_params(
optional_params["logprobs"] = logprobs
if top_logprobs is not None:
optional_params["top_logprobs"] = top_logprobs
if extra_headers is not None:
optional_params["extra_headers"] = extra_headers
if custom_llm_provider in ["openai", "azure"] + litellm.openai_compatible_providers:
# for openai, azure we should pass the extra/passed params within `extra_body` https://github.com/openai/openai-python/blob/ac33853ba10d13ac149b1fa3ca6dba7d613065c9/src/openai/resources/models.py#L46
extra_body = passed_params.pop("extra_body", {})