mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
Litellm dev 01 22 2025 p4 (#7932)
* feat(main.py): add new 'provider_specific_header' param allows passing extra header for specific provider * fix(litellm_pre_call_utils.py): add unit test for pre call utils * test(test_bedrock_completion.py): skip test now that bedrock supports this
This commit is contained in:
parent
65ca5f74b0
commit
bf1639cb92
5 changed files with 119 additions and 5 deletions
|
@ -179,6 +179,7 @@ from .types.utils import (
|
|||
HiddenParams,
|
||||
LlmProviders,
|
||||
PromptTokensDetails,
|
||||
ProviderSpecificHeader,
|
||||
all_litellm_params,
|
||||
)
|
||||
|
||||
|
@ -832,6 +833,9 @@ def completion( # type: ignore # noqa: PLR0915
|
|||
model_info = kwargs.get("model_info", None)
|
||||
proxy_server_request = kwargs.get("proxy_server_request", None)
|
||||
fallbacks = kwargs.get("fallbacks", None)
|
||||
provider_specific_header = cast(
|
||||
Optional[ProviderSpecificHeader], kwargs.get("provider_specific_header", None)
|
||||
)
|
||||
headers = kwargs.get("headers", None) or extra_headers
|
||||
ensure_alternating_roles: Optional[bool] = kwargs.get(
|
||||
"ensure_alternating_roles", None
|
||||
|
@ -937,6 +941,13 @@ def completion( # type: ignore # noqa: PLR0915
|
|||
api_base=api_base,
|
||||
api_key=api_key,
|
||||
)
|
||||
|
||||
if (
|
||||
provider_specific_header is not None
|
||||
and provider_specific_header["custom_llm_provider"] == custom_llm_provider
|
||||
):
|
||||
headers.update(provider_specific_header["extra_headers"])
|
||||
|
||||
if model_response is not None and hasattr(model_response, "_hidden_params"):
|
||||
model_response._hidden_params["custom_llm_provider"] = custom_llm_provider
|
||||
model_response._hidden_params["region_name"] = kwargs.get(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue