From 1949a32eca72066035ffe33087616ae6040ba735 Mon Sep 17 00:00:00 2001 From: Bipin Rimal <146849810+BipinRimal314@users.noreply.github.com> Date: Mon, 23 Mar 2026 11:28:18 +0545 Subject: [PATCH] fix: replace placeholder callback with real LiteLLM patterns Address Greptile P1: 'your_logging_backend' is not a valid callback. Show both built-in integration (langfuse/s3/datadog) and CustomLogger class pattern with actual Article 12 field references. --- docs/my-website/docs/eu-ai-act-compliance.md | 41 ++++++++++++++------ 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/docs/my-website/docs/eu-ai-act-compliance.md b/docs/my-website/docs/eu-ai-act-compliance.md index a03cbd2d382..79bf7e6caae 100644 --- a/docs/my-website/docs/eu-ai-act-compliance.md +++ b/docs/my-website/docs/eu-ai-act-compliance.md @@ -106,23 +106,42 @@ LiteLLM covers approximately 70-80% of Article 12 requirements out of the box wh ### Configuring Article 12-compliant logging -Enable comprehensive logging via LiteLLM callbacks: +**Option 1: Use a built-in integration** (recommended for most deployments): ```python import litellm -litellm.success_callback = ["your_logging_backend"] -litellm.failure_callback = ["your_logging_backend"] - -# Ensure these fields are captured in your callback: -# - model, messages, response, usage, response_cost -# - temperature, max_tokens (from kwargs) -# - user, metadata -# - timestamps, latency -# - error type and message (on failure) +# Use a built-in backend: "langfuse", "s3", "datadog", "helicone", etc. +litellm.success_callback = ["langfuse"] +litellm.failure_callback = ["langfuse"] ``` -Connect to a persistent backend (Langfuse, Helicone, or your own database) with a retention policy of at least 6 months. +**Option 2: Custom compliance logger** (when you need full control over what's captured): + +```python +import litellm +from litellm.integrations.custom_logger import CustomLogger + +class ComplianceLogger(CustomLogger): + async def async_log_success_event(self, kwargs, response_obj, start_time, end_time): + # Article 12 fields to capture: + # - kwargs["model"], kwargs["messages"] (input content) + # - response_obj (output content) + # - kwargs["optional_params"] (temperature, max_tokens) + # - response_obj.usage (token counts) + # - kwargs.get("response_cost") (cost per request) + # - kwargs.get("user") (user identification) + # - start_time, end_time (timestamps and latency) + ... + + async def async_log_failure_event(self, kwargs, response_obj, start_time, end_time): + # Capture: exception type, message, failing model, timestamp + ... + +litellm.callbacks = [ComplianceLogger()] +``` + +Whichever option you choose, connect to a persistent backend with a retention policy of at least 6 months (Article 26(6) for deployers; Article 18 requires 10 years for providers). ## Article 13: Transparency