mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-11 08:38:24 +00:00
test(logging): give the failure-capture kwargs and the Langfuse export route full types
This commit is contained in:
parent
c2dfc17e04
commit
213ed9b438
2 changed files with 14 additions and 6 deletions
|
|
@ -189,7 +189,7 @@ async def test_langfuse_logging_completion(langfuse_export: tuple[respx.Route, s
|
|||
async def test_langfuse_failure_with_redaction_on_logs_the_error_without_the_prompt(
|
||||
langfuse_export: tuple[respx.Route, str], monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
route, _ = langfuse_export
|
||||
route: Final = langfuse_export[0]
|
||||
prompt: Final = "my ssn is 123-45-6789"
|
||||
monkeypatch.setattr(litellm, "turn_off_message_logging", True)
|
||||
monkeypatch.setattr(litellm, "failure_callback", ["langfuse"])
|
||||
|
|
|
|||
|
|
@ -12056,16 +12056,24 @@ SCRUB_PROMPT: Final = "my ssn is 123-45-6789"
|
|||
class _FailureCapture(CustomLogger):
|
||||
def __init__(self, **kwargs: bool) -> None:
|
||||
super().__init__(**kwargs)
|
||||
self.sync_kwargs: dict | None = None
|
||||
self.async_kwargs: dict | None = None
|
||||
self.sync_kwargs: dict[str, object] | None = None
|
||||
self.async_kwargs: dict[str, object] | None = None
|
||||
|
||||
def log_failure_event(
|
||||
self, kwargs: dict, response_obj: object, start_time: datetime.datetime, end_time: datetime.datetime
|
||||
self,
|
||||
kwargs: dict[str, object],
|
||||
response_obj: object,
|
||||
start_time: datetime.datetime,
|
||||
end_time: datetime.datetime,
|
||||
) -> None:
|
||||
self.sync_kwargs = kwargs
|
||||
|
||||
async def async_log_failure_event(
|
||||
self, kwargs: dict, response_obj: object, start_time: datetime.datetime, end_time: datetime.datetime
|
||||
self,
|
||||
kwargs: dict[str, object],
|
||||
response_obj: object,
|
||||
start_time: datetime.datetime,
|
||||
end_time: datetime.datetime,
|
||||
) -> None:
|
||||
self.async_kwargs = kwargs
|
||||
|
||||
|
|
@ -12096,7 +12104,7 @@ def _prompt_echo_error() -> litellm.BadRequestError:
|
|||
|
||||
async def _async_failure_payload(
|
||||
monkeypatch: pytest.MonkeyPatch, *, redact: bool, error: Exception, capture: _FailureCapture | None = None
|
||||
) -> dict:
|
||||
) -> dict[str, object]:
|
||||
logger: Final = capture or _FailureCapture()
|
||||
monkeypatch.setattr(litellm, "turn_off_message_logging", redact)
|
||||
monkeypatch.setattr(litellm, "_async_failure_callback", [logger])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue