mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
(fix) get_response_headers for Azure OpenAI (#6344)
* fix get_response_headers * unit testing for get headers * unit testing for anthropic / azure openai headers * increase test coverage for test_completion_response_ratelimit_headers * fix test rate limit headers
This commit is contained in:
parent
fb523b79e9
commit
274bf3e48d
6 changed files with 316 additions and 30 deletions
|
@ -70,6 +70,9 @@ from litellm.litellm_core_utils.get_llm_provider_logic import (
|
|||
get_llm_provider,
|
||||
)
|
||||
from litellm.litellm_core_utils.llm_request_utils import _ensure_extra_body_is_safe
|
||||
from litellm.litellm_core_utils.llm_response_utils.get_headers import (
|
||||
get_response_headers,
|
||||
)
|
||||
from litellm.litellm_core_utils.redact_messages import (
|
||||
LiteLLMLoggingObject,
|
||||
redact_message_input_output_from_logging,
|
||||
|
@ -5704,36 +5707,12 @@ def convert_to_model_response_object( # noqa: PLR0915
|
|||
):
|
||||
received_args = locals()
|
||||
|
||||
if _response_headers is not None:
|
||||
openai_headers = {}
|
||||
if "x-ratelimit-limit-requests" in _response_headers:
|
||||
openai_headers["x-ratelimit-limit-requests"] = _response_headers[
|
||||
"x-ratelimit-limit-requests"
|
||||
]
|
||||
if "x-ratelimit-remaining-requests" in _response_headers:
|
||||
openai_headers["x-ratelimit-remaining-requests"] = _response_headers[
|
||||
"x-ratelimit-remaining-requests"
|
||||
]
|
||||
if "x-ratelimit-limit-tokens" in _response_headers:
|
||||
openai_headers["x-ratelimit-limit-tokens"] = _response_headers[
|
||||
"x-ratelimit-limit-tokens"
|
||||
]
|
||||
if "x-ratelimit-remaining-tokens" in _response_headers:
|
||||
openai_headers["x-ratelimit-remaining-tokens"] = _response_headers[
|
||||
"x-ratelimit-remaining-tokens"
|
||||
]
|
||||
llm_response_headers = {
|
||||
"{}-{}".format("llm_provider", k): v for k, v in _response_headers.items()
|
||||
}
|
||||
if hidden_params is not None:
|
||||
hidden_params["additional_headers"] = {
|
||||
**llm_response_headers,
|
||||
**openai_headers,
|
||||
}
|
||||
else:
|
||||
hidden_params = {
|
||||
"additional_headers": {**llm_response_headers, **openai_headers}
|
||||
}
|
||||
additional_headers = get_response_headers(_response_headers)
|
||||
|
||||
if hidden_params is None:
|
||||
hidden_params = {}
|
||||
hidden_params["additional_headers"] = additional_headers
|
||||
|
||||
### CHECK IF ERROR IN RESPONSE ### - openrouter returns these in the dictionary
|
||||
if (
|
||||
response_object is not None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue