Merge pull request #2164 from BerriAI/litellm_support_extra_headers

[FEAT] Support extra headers - OpenAI / Azure
This commit is contained in:
Ishaan Jaff 2024-02-23 09:42:09 -08:00 committed by GitHub
commit 9594ceae55
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 43 additions and 13 deletions

View file

@ -3920,6 +3920,7 @@ def get_optional_params(
max_retries=None,
logprobs=None,
top_logprobs=None,
extra_headers=None,
**kwargs,
):
# retrieve all parameters passed to the function
@ -3959,6 +3960,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 = {
@ -4766,6 +4768,7 @@ def get_optional_params(
"max_retries",
"logprobs",
"top_logprobs",
"extra_headers",
]
_check_valid_arg(supported_params=supported_params)
if functions is not None:
@ -4806,6 +4809,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", {})