feat(guardrails): Flag for PII Masking on Logging

Fixes https://github.com/BerriAI/litellm/issues/4580
This commit is contained in:
Krrish Dholakia 2024-07-11 16:09:34 -07:00
parent ca76d2fd72
commit 9deb9b4e3f
7 changed files with 107 additions and 6 deletions

View file

@ -2,7 +2,7 @@
# On success, logs events to Promptlayer
import os
import traceback
from typing import Literal, Optional, Union
from typing import Any, Literal, Optional, Tuple, Union
import dotenv
@ -90,6 +90,16 @@ class CustomLogger: # https://docs.litellm.ai/docs/observability/custom_callbac
):
pass
async def async_logging_hook(self):
"""For masking logged request/response"""
pass
def logging_hook(
self, kwargs: dict, result: Any, call_type: str
) -> Tuple[dict, Any]:
"""For masking logged request/response. Return a modified version of the request/result."""
return kwargs, result
async def async_moderation_hook(
self,
data: dict,