(Feat) Log Guardrails run, guardrail response on logging integrations (#7445)

* add guardrail_information to SLP

* use standard_logging_guardrail_information

* track StandardLoggingGuardrailInformation

* use log_guardrail_information

* use log_guardrail_information

* docs guardrails

* docs guardrails

* update quick start

* fix presidio logging for sync functions

* update Guardrail type

* enforce add_standard_logging_guardrail_information_to_request_data

* update gd docs
This commit is contained in:
Ishaan Jaff 2024-12-27 15:01:56 -08:00 committed by GitHub
parent d1686eef72
commit 62753eea69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 223 additions and 29 deletions

View file

@ -20,7 +20,10 @@ from fastapi import HTTPException
import litellm
from litellm._logging import verbose_proxy_logger
from litellm.integrations.custom_guardrail import CustomGuardrail
from litellm.integrations.custom_guardrail import (
CustomGuardrail,
log_guardrail_information,
)
from litellm.llms.custom_httpx.http_handler import (
get_async_httpx_client,
httpxSpecialProvider,
@ -294,6 +297,7 @@ class lakeraAI_Moderation(CustomGuardrail):
"""
self._check_response_flagged(response=response.json())
@log_guardrail_information
async def async_pre_call_hook(
self,
user_api_key_dict: UserAPIKeyAuth,
@ -330,6 +334,7 @@ class lakeraAI_Moderation(CustomGuardrail):
data=data, user_api_key_dict=user_api_key_dict, call_type=call_type
)
@log_guardrail_information
async def async_moderation_hook( ### 👈 KEY CHANGE ###
self,
data: dict,