add docs on status code from exceptions

This commit is contained in:
Ishaan Jaff 2024-07-30 12:38:33 -07:00
parent daa0b10f51
commit d26ffbdf8c
2 changed files with 7 additions and 0 deletions

View file

@ -1667,6 +1667,10 @@ class ProxyException(Exception):
self.message = message self.message = message
self.type = type self.type = type
self.param = param self.param = param
# If we look on official python OpenAI lib, the code should be a string:
# https://github.com/openai/openai-python/blob/195c05a64d39c87b2dfdf1eca2d339597f1fce03/src/openai/types/shared/error_object.py#L11
# Related LiteLLM issue: https://github.com/BerriAI/litellm/discussions/4834
self.code = str(code) self.code = str(code)
if headers is not None: if headers is not None:
for k, v in headers.items(): for k, v in headers.items():

View file

@ -81,6 +81,9 @@ def test_chat_completion_exception(client):
code_in_error = json_response["error"]["code"] code_in_error = json_response["error"]["code"]
# OpenAI SDK required code to be STR, https://github.com/BerriAI/litellm/issues/4970 # OpenAI SDK required code to be STR, https://github.com/BerriAI/litellm/issues/4970
# If we look on official python OpenAI lib, the code should be a string:
# https://github.com/openai/openai-python/blob/195c05a64d39c87b2dfdf1eca2d339597f1fce03/src/openai/types/shared/error_object.py#L11
# Related LiteLLM issue: https://github.com/BerriAI/litellm/discussions/4834
assert type(code_in_error) == str assert type(code_in_error) == str
# make an openai client to call _make_status_error_from_response # make an openai client to call _make_status_error_from_response