Community-maintained integration. This service is built and maintained by Apoorv012. Pipecat does not test or officially support it. Please report issues and request changes on the source repository. Learn more about community integrations.
Overview
OutputGuardProcessor sits between the LLM and the TTS and checks what the bot
is about to say. Each sentence is checked before the TTS gets it, so nothing
unchecked is spoken. A sentence can be allowed, redacted (for example a phone
number becomes [phone number]), or blocked: on a block, the rest of the reply
is dropped and a fallback line is spoken instead.
Blocked text never reaches the TTS, so it never enters the conversation history
either. User interruptions, function calls, and lines your own code speaks
(TTSSpeakFrame) pass through in order.
A Guard decides what is allowed, in up to three layers, stopping at the first
one that is sure:
- Rules: banned terms, regular expressions, and personal data (email, phone, card numbers, plus an India pack for Aadhaar, PAN, and Hinglish word lists). Local and instant.
- Classifier (optional): any Pipecat classifier, such as Jev, answers yes/no policies about the reply in one call.
- Judge (optional): an LLM, through Pipecat’s LLM classifier, decides the policies the classifier was unsure about.
Source Repository
Source code, examples, and issues for Pipecat Guardrails
PyPI Package
The
pipecat-guardrails package on PyPIInstallation
This is a community-maintained package distributed separately frompipecat-ai:
Prerequisites
- Pipecat 1.12.0 or later:
pipecat-ai>=1.12,<2 - Python 3.11 or later
- No API key for rules. Rules run locally.
- For policies, the keys of the classifier or judge you choose, for example
TYPESAFE_API_KEYfor Jev, or your LLM provider’s key for a judge.
Configuration
OutputGuardProcessor
"sentence" checks each sentence before it is spoken. "full_reply" holds
the whole reply, checks it once, then speaks it: safer for rules that need the
full reply, at the cost of latency.With the
"sentence" strategy, how many sentences are checked at once.
Sentences are always released in order, so usually only the first sentence of
a reply waits for a classifier or judge round trip.on_violation(processor, verdict) when a rule or policy fires, and
on_check(processor, verdict) for every check.
Guard
Layer 1:
BannedTerms, Regex, PII, or any function decorated with
@rule. Each rule can block, redact, or flag.Yes/no questions about the reply, by id, where “yes” means it breaks the
policy. Needs a
classifier, a judge, or both.Layer 3: usually
LLMClassifier, for the policies the classifier was unsure
about.What to say instead of blocked text, or a function of the verdict.
None
says nothing."shadow" reports what the guard would do without changing anything, so new
rules can be tried on live traffic.What a failed or timed-out check does:
"block" (fail closed) or "allow"
(fail open).pipecat-guardrails eval
command for measuring a guard on your own data.
Usage
PutOutputGuardProcessor between the LLM and the TTS: