mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-06 08:16:43 +00:00
address greptile issues
This commit is contained in:
parent
160f26ca08
commit
70ac6ccf89
3 changed files with 30 additions and 4 deletions
|
|
@ -9,8 +9,6 @@ import os
|
|||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from fastapi import HTTPException
|
||||
|
||||
from litellm._logging import verbose_logger
|
||||
from litellm.integrations.custom_logger import CustomLogger
|
||||
from litellm.llms.custom_httpx.http_handler import (
|
||||
|
|
@ -224,7 +222,11 @@ class AktoLogger(CustomLogger):
|
|||
def get_failure_status_code(kwargs: dict) -> int:
|
||||
"""Return the appropriate status code for a failed request."""
|
||||
exc = kwargs.get("exception")
|
||||
if isinstance(exc, HTTPException):
|
||||
if (
|
||||
exc is not None
|
||||
and hasattr(exc, "status_code")
|
||||
and isinstance(exc.status_code, int)
|
||||
):
|
||||
return exc.status_code
|
||||
return 500
|
||||
|
||||
|
|
|
|||
|
|
@ -3058,6 +3058,16 @@ class Logging(LiteLLMLoggingBaseClass):
|
|||
print_verbose=print_verbose,
|
||||
callback_func=callback,
|
||||
)
|
||||
if callback == "akto" and is_sync_request:
|
||||
global aktoLogger
|
||||
if aktoLogger is None:
|
||||
aktoLogger = AktoLogger()
|
||||
aktoLogger.log_failure_event(
|
||||
kwargs=self.model_call_details,
|
||||
response_obj=result,
|
||||
start_time=start_time,
|
||||
end_time=end_time,
|
||||
)
|
||||
if (
|
||||
isinstance(callback, CustomLogger)
|
||||
and is_sync_request
|
||||
|
|
@ -3183,6 +3193,16 @@ class Logging(LiteLLMLoggingBaseClass):
|
|||
)
|
||||
if not should_run:
|
||||
continue
|
||||
if callback == "akto":
|
||||
global aktoLogger
|
||||
if aktoLogger is None:
|
||||
aktoLogger = AktoLogger()
|
||||
await aktoLogger.async_log_failure_event(
|
||||
kwargs=self.model_call_details,
|
||||
response_obj=result,
|
||||
start_time=start_time,
|
||||
end_time=end_time,
|
||||
)
|
||||
if isinstance(callback, CustomLogger): # custom logger class
|
||||
await callback.async_log_failure_event(
|
||||
kwargs=self.model_call_details,
|
||||
|
|
|
|||
|
|
@ -99,7 +99,11 @@ class LoggingCallbackManager:
|
|||
Add a failure callback to `litellm.failure_callback`.
|
||||
Auto-routes async callbacks to litellm._async_failure_callback.
|
||||
"""
|
||||
if not isinstance(callback, str) and self._is_async_callable(callback):
|
||||
if isinstance(callback, str) and callback in ("akto",):
|
||||
self._safe_add_callback_to_list(
|
||||
callback=callback, parent_list=litellm._async_failure_callback
|
||||
)
|
||||
elif not isinstance(callback, str) and self._is_async_callable(callback):
|
||||
self._safe_add_callback_to_list(
|
||||
callback=callback, parent_list=litellm._async_failure_callback
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue