feat(utils.py): support passing openai response headers to client, if enabled

Allows openai/openai-compatible provider response headers to be sent to client, if 'return_response_headers' is enabled
This commit is contained in:
Krrish Dholakia 2024-07-23 11:30:52 -07:00
parent b137207ae6
commit dcb974dd1e
3 changed files with 12 additions and 0 deletions

View file

@ -5678,6 +5678,14 @@ def convert_to_model_response_object(
_response_headers: Optional[dict] = None,
):
received_args = locals()
if _response_headers is not None:
if hidden_params is not None:
hidden_params["additional_headers"] = {
"{}-{}".format("llm_provider", k): v
for k, v in _response_headers.items()
}
else:
hidden_params = {"additional_headers": _response_headers}
### CHECK IF ERROR IN RESPONSE ### - openrouter returns these in the dictionary
if (
response_object is not None