From cdcf8ce9f604e421a230a39e64ed2faa480c3dab Mon Sep 17 00:00:00 2001 From: XxAlonexX Date: Sat, 22 Feb 2025 11:47:00 +0530 Subject: [PATCH 1/2] Fix serialization issue in OpenAILikeError class --- litellm/llms/openai_like/common_utils.py | 10 ++++------ litellm/proxy/_experimental/out/onboarding.html | 1 - 2 files changed, 4 insertions(+), 7 deletions(-) delete mode 100644 litellm/proxy/_experimental/out/onboarding.html diff --git a/litellm/llms/openai_like/common_utils.py b/litellm/llms/openai_like/common_utils.py index 116277b6dd..c05e0c8e8d 100644 --- a/litellm/llms/openai_like/common_utils.py +++ b/litellm/llms/openai_like/common_utils.py @@ -4,14 +4,12 @@ import httpx class OpenAILikeError(Exception): - def __init__(self, status_code, message): + def __init__(self, status_code, message, request: Optional[httpx.Request] = None, response: Optional[httpx.Response] = None): self.status_code = status_code self.message = message - self.request = httpx.Request(method="POST", url="https://www.litellm.ai") - self.response = httpx.Response(status_code=status_code, request=self.request) - super().__init__( - self.message - ) # Call the base class constructor with the parameters it needs + self.request = request + self.response = response + super().__init__(self.message) # Call the base class constructor with the parameters it needs class OpenAILikeBase: diff --git a/litellm/proxy/_experimental/out/onboarding.html b/litellm/proxy/_experimental/out/onboarding.html deleted file mode 100644 index a0965463b6..0000000000 --- a/litellm/proxy/_experimental/out/onboarding.html +++ /dev/null @@ -1 +0,0 @@ -LiteLLM Dashboard \ No newline at end of file From 5e55ee2402eeef10fa685d88314fc57925c444cc Mon Sep 17 00:00:00 2001 From: XxAlonexX Date: Tue, 11 Mar 2025 23:31:47 +0530 Subject: [PATCH 2/2] Done with the requested changes --- litellm/_logging.py | 5 ++++- litellm/llms/openai_like/common_utils.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/litellm/_logging.py b/litellm/_logging.py index 151ae6003d..757bbf5e73 100644 --- a/litellm/_logging.py +++ b/litellm/_logging.py @@ -35,7 +35,10 @@ class JsonFormatter(Formatter): } if record.exc_info: - json_record["stacktrace"] = self.formatException(record.exc_info) + try: + json_record["stacktrace"] = self.formatException(record.exc_info) + except Exception as e: + json_record["stacktrace"] = f"Error serializing stacktrace: {str(e)}" return json.dumps(json_record) diff --git a/litellm/llms/openai_like/common_utils.py b/litellm/llms/openai_like/common_utils.py index c05e0c8e8d..7cce7b43b2 100644 --- a/litellm/llms/openai_like/common_utils.py +++ b/litellm/llms/openai_like/common_utils.py @@ -9,7 +9,7 @@ class OpenAILikeError(Exception): self.message = message self.request = request self.response = response - super().__init__(self.message) # Call the base class constructor with the parameters it needs + super().__init__(message) # Call the base class constructor with the parameters it needs class OpenAILikeBase: