Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix req changes

Harshit28j1073ba6d1350
diff --git a/litellm/proxy/guardrails/guardrail_hooks/presidio.py b/litellm/proxy/guardrails/guardrail_hooks/presidio.py
index 849b1ec9cab..adfe69315c6 100644
--- a/litellm/proxy/guardrails/guardrail_hooks/presidio.py
+++ b/litellm/proxy/guardrails/guardrail_hooks/presidio.py
@@ -508,7 +508,13 @@ class _OPTIONAL_PresidioPIIMasking(CustomGuardrail):
masked_entity_count[entity_type] = (
masked_entity_count.get(entity_type, 0) + 1
)
- return redacted_text["text"]
+ # When output_parse_pii is True, new_text contains UUID-suffixed
+ # tokens that match the keys in pii_tokens. Returning
+ # redacted_text["text"] (Presidio's original output) would send
+ # un-suffixed tokens to the LLM, making unmasking impossible.
+ # When output_parse_pii is False, new_text == redacted_text["text"]
+ # because no UUID suffix is appended.
+ return new_text
else:
raise Exception("Invalid anonymizer response: received None")
except Exception as e: