pipecat-guardrails 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pipecat_guardrails-0.0.1/.gitignore +24 -0
- pipecat_guardrails-0.0.1/CHANGELOG.md +15 -0
- pipecat_guardrails-0.0.1/LICENSE +24 -0
- pipecat_guardrails-0.0.1/PKG-INFO +95 -0
- pipecat_guardrails-0.0.1/README.md +66 -0
- pipecat_guardrails-0.0.1/pyproject.toml +89 -0
- pipecat_guardrails-0.0.1/src/pipecat_guardrails/__init__.py +14 -0
- pipecat_guardrails-0.0.1/src/pipecat_guardrails/py.typed +0 -0
- pipecat_guardrails-0.0.1/tests/test_package.py +15 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
build/
|
|
6
|
+
dist/
|
|
7
|
+
|
|
8
|
+
# Environments
|
|
9
|
+
.venv/
|
|
10
|
+
.env
|
|
11
|
+
.env.*
|
|
12
|
+
|
|
13
|
+
# Tools
|
|
14
|
+
.pytest_cache/
|
|
15
|
+
.ruff_cache/
|
|
16
|
+
.coverage
|
|
17
|
+
coverage.xml
|
|
18
|
+
htmlcov/
|
|
19
|
+
|
|
20
|
+
# Editors / OS
|
|
21
|
+
.vscode/
|
|
22
|
+
.idea/
|
|
23
|
+
.DS_Store
|
|
24
|
+
Thumbs.db
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here.
|
|
4
|
+
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
|
|
5
|
+
[Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.0.1] - 2026-10-31
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- Package structure, CI and release workflow. No guardrail functionality yet.
|
|
13
|
+
|
|
14
|
+
[Unreleased]: https://github.com/Apoorv012/pipecat-guardrails/compare/v0.0.1...HEAD
|
|
15
|
+
[0.0.1]: https://github.com/Apoorv012/pipecat-guardrails/releases/tag/v0.0.1
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
BSD 2-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, Apoorv Mittal
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
17
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
19
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
20
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
21
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
23
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
24
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pipecat-guardrails
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Output guardrails for Pipecat voice agents: check what the bot is about to say, and stop it before it is spoken.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Apoorv012/pipecat-guardrails
|
|
6
|
+
Project-URL: Repository, https://github.com/Apoorv012/pipecat-guardrails
|
|
7
|
+
Project-URL: Issues, https://github.com/Apoorv012/pipecat-guardrails/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/Apoorv012/pipecat-guardrails/blob/main/CHANGELOG.md
|
|
9
|
+
Author: Apoorv Mittal
|
|
10
|
+
License-Expression: BSD-2-Clause
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: guardrails,llm,moderation,pipecat,safety,tts,voice
|
|
13
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Requires-Dist: pipecat-ai<2,>=1.12
|
|
26
|
+
Provides-Extra: jev
|
|
27
|
+
Requires-Dist: pipecat-ai[jev]<2,>=1.12; extra == 'jev'
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# pipecat-guardrails
|
|
31
|
+
|
|
32
|
+
Output guardrails for [Pipecat](https://github.com/pipecat-ai/pipecat) voice agents. It checks what
|
|
33
|
+
your bot is about to say, and stops it before it is spoken.
|
|
34
|
+
|
|
35
|
+
> **Status: early development.** Version 0.0.1 contains the package structure only, with no
|
|
36
|
+
> guardrails yet. Follow the repo for the first usable release (0.1.0).
|
|
37
|
+
|
|
38
|
+
## The problem
|
|
39
|
+
|
|
40
|
+
Pipecat has no built-in output guardrail, so every team writes its own processor between the LLM
|
|
41
|
+
and the TTS. These homemade processors tend to break on user interruptions, keep speaking after a
|
|
42
|
+
violation, let blocked text into the LLM history, and miss paraphrases and Hindi/Hinglish text.
|
|
43
|
+
|
|
44
|
+
This package will provide one processor you add to your pipeline:
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
pipeline = Pipeline([
|
|
48
|
+
transport.input(), stt, context_aggregator.user(), llm,
|
|
49
|
+
OutputGuardProcessor(guard), # checks each sentence before it is spoken
|
|
50
|
+
tts, transport.output(), context_aggregator.assistant(),
|
|
51
|
+
])
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
There will also be a plain `await guard.check(text)` for apps that run their own LLM loop.
|
|
55
|
+
|
|
56
|
+
See [BEFORE_AFTER.md](https://github.com/Apoorv012/pipecat-guardrails/blob/main/BEFORE_AFTER.md)
|
|
57
|
+
for a side-by-side comparison and
|
|
58
|
+
[PLAN.md](https://github.com/Apoorv012/pipecat-guardrails/blob/main/PLAN.md) for the design and
|
|
59
|
+
roadmap.
|
|
60
|
+
|
|
61
|
+
## Install
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pip install pipecat-guardrails # includes Pipecat
|
|
65
|
+
pip install "pipecat-guardrails[jev]" # also installs the TypeSafe Jev classifier client
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Requires Python 3.11+ and Pipecat 1.12 or later (installed automatically).
|
|
69
|
+
|
|
70
|
+
## How checking works
|
|
71
|
+
|
|
72
|
+
Each sentence goes through up to three layers, and stops at the first one that is sure:
|
|
73
|
+
|
|
74
|
+
1. **Banned words, PII, regex**: local and instant.
|
|
75
|
+
2. **Classifier model** (optional), such as TypeSafe Jev: a fast yes/no model with an API key.
|
|
76
|
+
A confident answer decides; an unsure one moves to layer 3.
|
|
77
|
+
3. **LLM judge** (optional): any OpenAI-compatible LLM gives the final answer.
|
|
78
|
+
|
|
79
|
+
Layers 2 and 3 use Pipecat's own classifiers (`pipecat.classifiers`), so any classifier Pipecat
|
|
80
|
+
supports works here.
|
|
81
|
+
|
|
82
|
+
## Development
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
uv sync # create .venv with dev tools
|
|
86
|
+
uv run pytest # tests
|
|
87
|
+
uv run ruff check . # lint
|
|
88
|
+
uv run ruff format . # format
|
|
89
|
+
uv run pyright # type check
|
|
90
|
+
uv run pre-commit install # run the checks on every commit
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
BSD-2-Clause, the same as Pipecat.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# pipecat-guardrails
|
|
2
|
+
|
|
3
|
+
Output guardrails for [Pipecat](https://github.com/pipecat-ai/pipecat) voice agents. It checks what
|
|
4
|
+
your bot is about to say, and stops it before it is spoken.
|
|
5
|
+
|
|
6
|
+
> **Status: early development.** Version 0.0.1 contains the package structure only, with no
|
|
7
|
+
> guardrails yet. Follow the repo for the first usable release (0.1.0).
|
|
8
|
+
|
|
9
|
+
## The problem
|
|
10
|
+
|
|
11
|
+
Pipecat has no built-in output guardrail, so every team writes its own processor between the LLM
|
|
12
|
+
and the TTS. These homemade processors tend to break on user interruptions, keep speaking after a
|
|
13
|
+
violation, let blocked text into the LLM history, and miss paraphrases and Hindi/Hinglish text.
|
|
14
|
+
|
|
15
|
+
This package will provide one processor you add to your pipeline:
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
pipeline = Pipeline([
|
|
19
|
+
transport.input(), stt, context_aggregator.user(), llm,
|
|
20
|
+
OutputGuardProcessor(guard), # checks each sentence before it is spoken
|
|
21
|
+
tts, transport.output(), context_aggregator.assistant(),
|
|
22
|
+
])
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
There will also be a plain `await guard.check(text)` for apps that run their own LLM loop.
|
|
26
|
+
|
|
27
|
+
See [BEFORE_AFTER.md](https://github.com/Apoorv012/pipecat-guardrails/blob/main/BEFORE_AFTER.md)
|
|
28
|
+
for a side-by-side comparison and
|
|
29
|
+
[PLAN.md](https://github.com/Apoorv012/pipecat-guardrails/blob/main/PLAN.md) for the design and
|
|
30
|
+
roadmap.
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install pipecat-guardrails # includes Pipecat
|
|
36
|
+
pip install "pipecat-guardrails[jev]" # also installs the TypeSafe Jev classifier client
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Requires Python 3.11+ and Pipecat 1.12 or later (installed automatically).
|
|
40
|
+
|
|
41
|
+
## How checking works
|
|
42
|
+
|
|
43
|
+
Each sentence goes through up to three layers, and stops at the first one that is sure:
|
|
44
|
+
|
|
45
|
+
1. **Banned words, PII, regex**: local and instant.
|
|
46
|
+
2. **Classifier model** (optional), such as TypeSafe Jev: a fast yes/no model with an API key.
|
|
47
|
+
A confident answer decides; an unsure one moves to layer 3.
|
|
48
|
+
3. **LLM judge** (optional): any OpenAI-compatible LLM gives the final answer.
|
|
49
|
+
|
|
50
|
+
Layers 2 and 3 use Pipecat's own classifiers (`pipecat.classifiers`), so any classifier Pipecat
|
|
51
|
+
supports works here.
|
|
52
|
+
|
|
53
|
+
## Development
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
uv sync # create .venv with dev tools
|
|
57
|
+
uv run pytest # tests
|
|
58
|
+
uv run ruff check . # lint
|
|
59
|
+
uv run ruff format . # format
|
|
60
|
+
uv run pyright # type check
|
|
61
|
+
uv run pre-commit install # run the checks on every commit
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
BSD-2-Clause, the same as Pipecat.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.27"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pipecat-guardrails"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
description = "Output guardrails for Pipecat voice agents: check what the bot is about to say, and stop it before it is spoken."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "BSD-2-Clause"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "Apoorv Mittal" }]
|
|
14
|
+
keywords = ["pipecat", "guardrails", "voice", "llm", "safety", "moderation", "tts"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Topic :: Multimedia :: Sound/Audio :: Speech",
|
|
25
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
26
|
+
"Typing :: Typed",
|
|
27
|
+
]
|
|
28
|
+
# Pipecat supplies the classifier and LLM-judge backends (pipecat.classifiers),
|
|
29
|
+
# the OpenAI SDK, and the frame-processor base class.
|
|
30
|
+
dependencies = ["pipecat-ai>=1.12,<2"]
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
jev = ["pipecat-ai[jev]>=1.12,<2"] # TypeSafe Jev classifier client
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://github.com/Apoorv012/pipecat-guardrails"
|
|
37
|
+
Repository = "https://github.com/Apoorv012/pipecat-guardrails"
|
|
38
|
+
Issues = "https://github.com/Apoorv012/pipecat-guardrails/issues"
|
|
39
|
+
Changelog = "https://github.com/Apoorv012/pipecat-guardrails/blob/main/CHANGELOG.md"
|
|
40
|
+
|
|
41
|
+
[dependency-groups]
|
|
42
|
+
dev = [
|
|
43
|
+
"pytest>=8",
|
|
44
|
+
"pytest-asyncio>=0.24",
|
|
45
|
+
"pytest-cov>=5",
|
|
46
|
+
"ruff>=0.8",
|
|
47
|
+
"pyright>=1.1.390",
|
|
48
|
+
"pre-commit>=4",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
[tool.hatch.build.targets.wheel]
|
|
52
|
+
packages = ["src/pipecat_guardrails"]
|
|
53
|
+
|
|
54
|
+
[tool.hatch.build.targets.sdist]
|
|
55
|
+
include = ["src/", "tests/", "README.md", "CHANGELOG.md", "LICENSE"]
|
|
56
|
+
|
|
57
|
+
[tool.ruff]
|
|
58
|
+
line-length = 100
|
|
59
|
+
target-version = "py311"
|
|
60
|
+
extend-exclude = ["*.md"] # code samples in docs are formatted by hand
|
|
61
|
+
|
|
62
|
+
[tool.ruff.lint]
|
|
63
|
+
select = ["E", "F", "W", "I", "UP", "B", "SIM", "RUF", "D"]
|
|
64
|
+
ignore = ["D105", "D107"] # magic methods and __init__ are documented on the class
|
|
65
|
+
|
|
66
|
+
[tool.ruff.lint.pydocstyle]
|
|
67
|
+
convention = "google"
|
|
68
|
+
|
|
69
|
+
[tool.ruff.lint.per-file-ignores]
|
|
70
|
+
"tests/**" = ["D"]
|
|
71
|
+
|
|
72
|
+
[tool.pyright]
|
|
73
|
+
include = ["src", "tests"]
|
|
74
|
+
pythonVersion = "3.11"
|
|
75
|
+
typeCheckingMode = "strict"
|
|
76
|
+
|
|
77
|
+
[tool.pytest.ini_options]
|
|
78
|
+
testpaths = ["tests"]
|
|
79
|
+
asyncio_mode = "auto"
|
|
80
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
81
|
+
addopts = ["--strict-markers", "--strict-config"]
|
|
82
|
+
|
|
83
|
+
[tool.coverage.run]
|
|
84
|
+
source = ["pipecat_guardrails"]
|
|
85
|
+
branch = true
|
|
86
|
+
|
|
87
|
+
[tool.coverage.report]
|
|
88
|
+
show_missing = true
|
|
89
|
+
skip_covered = true
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Output guardrails for Pipecat voice agents.
|
|
2
|
+
|
|
3
|
+
Checks what a voice agent is about to say and stops it before it is spoken.
|
|
4
|
+
This package is in early development; see the README for status.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
__version__ = version("pipecat-guardrails")
|
|
11
|
+
except PackageNotFoundError: # running from a source tree without an install
|
|
12
|
+
__version__ = "0.0.0"
|
|
13
|
+
|
|
14
|
+
__all__ = ["__version__"]
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from importlib.metadata import version
|
|
2
|
+
|
|
3
|
+
import pipecat_guardrails
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_version_matches_installed_metadata():
|
|
7
|
+
assert pipecat_guardrails.__version__ == version("pipecat-guardrails")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def test_pipecat_classifier_interface_is_available():
|
|
11
|
+
# Layers 2 and 3 (classifier and LLM judge) are built on this interface.
|
|
12
|
+
from pipecat.classifiers.base_classifier import BaseClassifier, YesNoQuestion
|
|
13
|
+
|
|
14
|
+
assert hasattr(BaseClassifier, "yes_no")
|
|
15
|
+
assert YesNoQuestion(instructions="Is this a test?").instructions == "Is this a test?"
|