mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
refactor: cleanup dead codeblock (#7936)
* refactor: cleanup dead codeblock * fix(main.py): add extra headers to headers * fix: remove dead codeblock
This commit is contained in:
parent
4db1c7a9a9
commit
4857a1e9ba
2 changed files with 3 additions and 36 deletions
|
@ -2584,25 +2584,6 @@ def _remove_unsupported_params(
|
|||
return non_default_params
|
||||
|
||||
|
||||
def get_clean_extra_headers(extra_headers: dict, custom_llm_provider: str) -> dict:
|
||||
"""
|
||||
For `anthropic-beta` headers, ensure provider is anthropic.
|
||||
|
||||
Vertex AI raises an exception if `anthropic-beta` is passed in.
|
||||
"""
|
||||
if litellm.filter_invalid_headers is not True: # allow user to opt out of filtering
|
||||
return extra_headers
|
||||
clean_extra_headers = {}
|
||||
for k, v in extra_headers.items():
|
||||
if k in ANTHROPIC_API_ONLY_HEADERS and custom_llm_provider != "anthropic":
|
||||
verbose_logger.debug(
|
||||
f"Provider {custom_llm_provider} does not support {k} header. Dropping from request, to prevent errors."
|
||||
) # Switching between anthropic api and vertex ai anthropic fails when anthropic-beta is passed in. Welcome feedback on this.
|
||||
else:
|
||||
clean_extra_headers[k] = v
|
||||
return clean_extra_headers
|
||||
|
||||
|
||||
def get_optional_params( # noqa: PLR0915
|
||||
# use the openai defaults
|
||||
# https://platform.openai.com/docs/api-reference/chat/create
|
||||
|
@ -2741,12 +2722,6 @@ def get_optional_params( # noqa: PLR0915
|
|||
)
|
||||
}
|
||||
|
||||
## Supports anthropic headers
|
||||
if extra_headers is not None:
|
||||
extra_headers = get_clean_extra_headers(
|
||||
extra_headers=extra_headers, custom_llm_provider=custom_llm_provider
|
||||
)
|
||||
|
||||
## raise exception if function calling passed in for a provider that doesn't support it
|
||||
if (
|
||||
"functions" in non_default_params
|
||||
|
@ -3516,12 +3491,6 @@ def get_optional_params( # noqa: PLR0915
|
|||
for k in passed_params.keys():
|
||||
if k not in default_params.keys():
|
||||
optional_params[k] = passed_params[k]
|
||||
if extra_headers is not None:
|
||||
optional_params.setdefault("extra_headers", {})
|
||||
optional_params["extra_headers"] = {
|
||||
**optional_params["extra_headers"],
|
||||
**extra_headers,
|
||||
}
|
||||
print_verbose(f"Final returned optional params: {optional_params}")
|
||||
return optional_params
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue