pipecat-rabel 0.3.0__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_rabel-0.3.0/.github/workflows/nightly.yml +58 -0
- pipecat_rabel-0.3.0/.github/workflows/release.yml +96 -0
- pipecat_rabel-0.3.0/.gitignore +8 -0
- pipecat_rabel-0.3.0/CHANGELOG.md +51 -0
- pipecat_rabel-0.3.0/LICENSE +24 -0
- pipecat_rabel-0.3.0/PKG-INFO +205 -0
- pipecat_rabel-0.3.0/README.md +173 -0
- pipecat_rabel-0.3.0/examples/bank_call.py +150 -0
- pipecat_rabel-0.3.0/pyproject.toml +53 -0
- pipecat_rabel-0.3.0/src/pipecat_rabel/__init__.py +24 -0
- pipecat_rabel-0.3.0/src/pipecat_rabel/strategy.py +1029 -0
- pipecat_rabel-0.3.0/tests/__init__.py +0 -0
- pipecat_rabel-0.3.0/tests/common.py +111 -0
- pipecat_rabel-0.3.0/tests/standin.py +211 -0
- pipecat_rabel-0.3.0/tests/test_audit_eager.py +224 -0
- pipecat_rabel-0.3.0/tests/test_failures.py +95 -0
- pipecat_rabel-0.3.0/tests/test_pipecat_check.py +103 -0
- pipecat_rabel-0.3.0/tests/test_report.py +306 -0
- pipecat_rabel-0.3.0/tests/test_strategy.py +535 -0
- pipecat_rabel-0.3.0/tests/test_vendor_patterns.py +135 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
name: tests
|
|
2
|
+
|
|
3
|
+
# Every push and pull request, and every night against Pipecat's main branch, so a change in Pipecat that breaks the
|
|
4
|
+
# strategy shows here before it reaches a release. The tests use a local stand-in for Bell's API and need no key.
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
pull_request:
|
|
9
|
+
schedule:
|
|
10
|
+
- cron: "17 4 * * *"
|
|
11
|
+
workflow_dispatch:
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
test:
|
|
18
|
+
name: Pipecat ${{ matrix.pipecat }}, Python ${{ matrix.python }}
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
strategy:
|
|
21
|
+
fail-fast: false
|
|
22
|
+
matrix:
|
|
23
|
+
python: ["3.11", "3.12", "3.13"]
|
|
24
|
+
pipecat: ["1.16.0", "main"]
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
- uses: actions/setup-python@v5
|
|
28
|
+
with:
|
|
29
|
+
python-version: ${{ matrix.python }}
|
|
30
|
+
- name: Install
|
|
31
|
+
run: |
|
|
32
|
+
python -m pip install --upgrade pip
|
|
33
|
+
if [ "${{ matrix.pipecat }}" = "main" ]; then
|
|
34
|
+
pip install "pipecat-ai @ git+https://github.com/pipecat-ai/pipecat.git@main"
|
|
35
|
+
else
|
|
36
|
+
pip install "pipecat-ai==${{ matrix.pipecat }}"
|
|
37
|
+
fi
|
|
38
|
+
pip install ".[test]"
|
|
39
|
+
pip show pipecat-ai | head -2
|
|
40
|
+
- name: Check the job tests the Pipecat it names
|
|
41
|
+
# Installing the package must not swap Pipecat's main branch for a release, or the other way round.
|
|
42
|
+
run: |
|
|
43
|
+
python - <<'EOF'
|
|
44
|
+
import importlib.metadata as md
|
|
45
|
+
import sys
|
|
46
|
+
|
|
47
|
+
want = "${{ matrix.pipecat }}"
|
|
48
|
+
dist = md.distribution("pipecat-ai")
|
|
49
|
+
source = dist.read_text("direct_url.json") or ""
|
|
50
|
+
print("pipecat-ai", dist.version, source or "(a release)")
|
|
51
|
+
if want == "main":
|
|
52
|
+
ok = "github.com/pipecat-ai/pipecat" in source
|
|
53
|
+
else:
|
|
54
|
+
ok = dist.version == want and "github.com" not in source
|
|
55
|
+
sys.exit(0 if ok else f"expected Pipecat {want}, found {dist.version} {source}")
|
|
56
|
+
EOF
|
|
57
|
+
- name: Test
|
|
58
|
+
run: python -m pytest -v
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
|
|
3
|
+
# Builds pipecat-rabel's wheel and source distribution from the checked-out commit, checks them, and uploads them to PyPI
|
|
4
|
+
# through PyPI's trusted publishing. Run by hand only, from the Actions tab or `gh workflow run release.yml`: never on a
|
|
5
|
+
# push or a tag. With `dry_run` (the default) it does everything but the upload.
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
inputs:
|
|
10
|
+
dry_run:
|
|
11
|
+
description: "Build and check only; do not upload to PyPI"
|
|
12
|
+
type: boolean
|
|
13
|
+
default: true
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
build:
|
|
20
|
+
name: Build and check
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
- uses: actions/setup-python@v5
|
|
25
|
+
with:
|
|
26
|
+
python-version: "3.12"
|
|
27
|
+
- name: Build
|
|
28
|
+
run: |
|
|
29
|
+
python -m pip install --upgrade pip build twine
|
|
30
|
+
python -m build
|
|
31
|
+
ls -l dist
|
|
32
|
+
- name: twine check
|
|
33
|
+
run: python -m twine check --strict dist/*
|
|
34
|
+
- name: Check the file lists
|
|
35
|
+
# The wheel holds only the package and its licence; the source distribution leaves lab/ out.
|
|
36
|
+
run: |
|
|
37
|
+
python - <<'EOF'
|
|
38
|
+
import glob
|
|
39
|
+
import re
|
|
40
|
+
import sys
|
|
41
|
+
import tarfile
|
|
42
|
+
import zipfile
|
|
43
|
+
|
|
44
|
+
version = re.search(r'__version__ = "([^"]+)"', open("src/pipecat_rabel/__init__.py").read()).group(1)
|
|
45
|
+
wheels = glob.glob("dist/*.whl")
|
|
46
|
+
sdists = glob.glob("dist/*.tar.gz")
|
|
47
|
+
bad = []
|
|
48
|
+
if len(wheels) != 1 or len(sdists) != 1:
|
|
49
|
+
sys.exit(f"expected one wheel and one source distribution, found {wheels} {sdists}")
|
|
50
|
+
for path in wheels + sdists:
|
|
51
|
+
if f"-{version}" not in path:
|
|
52
|
+
bad.append(f"{path} is not version {version}")
|
|
53
|
+
|
|
54
|
+
names = zipfile.ZipFile(wheels[0]).namelist()
|
|
55
|
+
print(f"wheel {wheels[0]}:")
|
|
56
|
+
for n in names:
|
|
57
|
+
print(" ", n)
|
|
58
|
+
top = n.split("/")[0]
|
|
59
|
+
if top != "pipecat_rabel" and not top.endswith(".dist-info"):
|
|
60
|
+
bad.append(f"wheel holds {n}")
|
|
61
|
+
licences = [n for n in names if "/licenses/" in n]
|
|
62
|
+
if not licences:
|
|
63
|
+
bad.append("wheel holds no licence")
|
|
64
|
+
|
|
65
|
+
names = tarfile.open(sdists[0]).getnames()
|
|
66
|
+
print(f"source distribution {sdists[0]}:")
|
|
67
|
+
for n in names:
|
|
68
|
+
print(" ", n)
|
|
69
|
+
parts = n.split("/")
|
|
70
|
+
if len(parts) > 1 and parts[1] == "lab":
|
|
71
|
+
bad.append(f"source distribution holds {n}")
|
|
72
|
+
|
|
73
|
+
if bad:
|
|
74
|
+
sys.exit("\n".join(bad))
|
|
75
|
+
print(f"file lists as expected for {version}")
|
|
76
|
+
EOF
|
|
77
|
+
- uses: actions/upload-artifact@v4
|
|
78
|
+
with:
|
|
79
|
+
name: dist
|
|
80
|
+
path: dist/
|
|
81
|
+
if-no-files-found: error
|
|
82
|
+
|
|
83
|
+
publish:
|
|
84
|
+
name: Upload to PyPI
|
|
85
|
+
needs: build
|
|
86
|
+
if: ${{ !inputs.dry_run }}
|
|
87
|
+
runs-on: ubuntu-latest
|
|
88
|
+
environment: pypi
|
|
89
|
+
permissions:
|
|
90
|
+
id-token: write
|
|
91
|
+
steps:
|
|
92
|
+
- uses: actions/download-artifact@v4
|
|
93
|
+
with:
|
|
94
|
+
name: dist
|
|
95
|
+
path: dist/
|
|
96
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.0 - 2026-11-23
|
|
4
|
+
|
|
5
|
+
- Bell is now a user turn stop strategy, on the door Pipecat's docs give a custom stop strategy for answering early:
|
|
6
|
+
`RabelBellUserTurnStopStrategy`, installed with the bundle `RabelBellUserTurnStrategies` as Pipecat's
|
|
7
|
+
`EagerUserTurnStopStrategy` is with `EagerUserTurnStrategies`. Pass the bundle as the user aggregator's
|
|
8
|
+
`user_turn_strategies`; nothing goes in the pipeline.
|
|
9
|
+
- The early reply on Bell's guess is started with `start_user_turn_speculation()`, kept at the turn's end only when the
|
|
10
|
+
final transcript matches it by the match policy, and withdrawn with `cancel_user_turn_speculation()` otherwise. The
|
|
11
|
+
strategy pushes no frame and holds none back.
|
|
12
|
+
- `RabelBellProcessor` is removed (never uploaded). Its settings, events, stats, report and summary line are the
|
|
13
|
+
strategy's, with the same names; the events' first argument is the strategy. New settings passed to Pipecat's eager
|
|
14
|
+
strategy: `match_policy` and `speculation_timeout`.
|
|
15
|
+
- Flux's own eager end of turn keeps working beside Bell. Its early end of turn on the words of Bell's reply under way
|
|
16
|
+
is not started (`stats.eager_held_back`).
|
|
17
|
+
- Flux's early end of turn on other words withdraws Bell's reply under way before its own starts. Bell's reply no longer
|
|
18
|
+
holds the LLM ahead of it or reaches the caller when the turn ends.
|
|
19
|
+
- When a local VAD hears the caller go on after a pause, Pipecat voids the early reply under way, and Bell's no longer
|
|
20
|
+
counts as running: Flux's early end of turn on the same words starts, and words that reach Bell's guess start it again.
|
|
21
|
+
- Each turn's end tells the API whether Bell's guess was kept or dropped (`report`, on by default), with no words. One
|
|
22
|
+
DEBUG line for each guess kept and one INFO line with the call's totals. `user` is sent when set.
|
|
23
|
+
- A guess never started in its turn (it came before Pipecat's turn opened, or beside an early reply on the same words,
|
|
24
|
+
and the words never reached it) counts in `stats.guesses_dropped`, and the turn's report says dropped.
|
|
25
|
+
- The conversation opens when the strategy is set up and is closed at the pipeline's teardown, also when no end frame
|
|
26
|
+
arrived. The API's address can be set with `RABEL_API_URL`. `websockets>=15`.
|
|
27
|
+
- Tests rewritten for the strategy in Pipecat's user aggregator, with eight kinds of API failure, each failing open.
|
|
28
|
+
Three more run Bell beside Flux's eager end of turn through a local stand-in LLM service and Pipecat's speculation
|
|
29
|
+
gate, and check what passes the gate against Pipecat's eager strategies alone.
|
|
30
|
+
|
|
31
|
+
## 0.2.0 - 2026-11-19
|
|
32
|
+
|
|
33
|
+
- An installable package, `pipecat-rabel`, for Pipecat 1.16.0: `from pipecat_rabel import RabelBellProcessor`.
|
|
34
|
+
- Version 2 of Rabel's API: the hello carries `agent`, `min_chance` and `learn`, the key goes in the `Authorization`
|
|
35
|
+
header, and each guess carries its `chance`. Bell now learns each agent on its own.
|
|
36
|
+
- Fails open: with the API down, slow to connect, slow to answer, refusing, closing mid-call or sending what the
|
|
37
|
+
processor cannot read, the frames out are exactly the speech-to-text's, with one logged line for each kind of failure.
|
|
38
|
+
A connect timeout, an answer timeout, and reopening by the API's rules.
|
|
39
|
+
- The words go out from a queue, so the pipeline never waits on the network.
|
|
40
|
+
- Tracks the speech-to-text's own early start (Flux's eager end of turn), so Bell's guess and Flux's prediction share
|
|
41
|
+
Pipecat's one early reply.
|
|
42
|
+
- Event handlers `on_ready`, `on_guess` and `on_turn_end`, and `processor.stats`.
|
|
43
|
+
- `examples/bank_call.py`, a bank's phone agent on `demo-bank`, replaces `compare.py`.
|
|
44
|
+
- Tests against a local stand-in for the API, and a nightly run against Pipecat's main branch.
|
|
45
|
+
- While Bell's early start is live, the speech-to-text's own early start on the same words is held back
|
|
46
|
+
(`stats.eager_held_back`): Pipecat would otherwise start a second reply and drop the one under way on Bell's guess.
|
|
47
|
+
- `min_chance` is 0.67 to 0.99, the API's range; a value outside it is clamped.
|
|
48
|
+
|
|
49
|
+
## 0.1.0 - 2026-11-14
|
|
50
|
+
|
|
51
|
+
- `RabelBellProcessor` and `compare.py`, tested with Pipecat 1.15.0.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
BSD 2-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, Rabel Labs Inc.
|
|
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,205 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pipecat-rabel
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Pipecat user turn strategy for Rabel Bell: an early start for your agent's reply, beside Deepgram Flux's eager end of turn
|
|
5
|
+
Project-URL: Homepage, https://rabellabs.com
|
|
6
|
+
Project-URL: Source, https://github.com/rabellabs/pipecat-rabel
|
|
7
|
+
Project-URL: Issues, https://github.com/rabellabs/pipecat-rabel/issues
|
|
8
|
+
Project-URL: Documentation, https://rabellabs.com/docs
|
|
9
|
+
Author: Rabel Labs
|
|
10
|
+
License-Expression: BSD-2-Clause
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Framework :: AsyncIO
|
|
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
|
+
Requires-Python: >=3.11
|
|
24
|
+
Requires-Dist: pipecat-ai<2,>=1.16.0
|
|
25
|
+
Requires-Dist: websockets>=15
|
|
26
|
+
Provides-Extra: example
|
|
27
|
+
Requires-Dist: pipecat-ai[anthropic,deepgram,runner,webrtc]<2,>=1.16.0; extra == 'example'
|
|
28
|
+
Provides-Extra: test
|
|
29
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'test'
|
|
30
|
+
Requires-Dist: pytest>=8; extra == 'test'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# Bell for Pipecat
|
|
34
|
+
|
|
35
|
+
Starts your [Pipecat](https://github.com/pipecat-ai/pipecat) voice agent's reply on Bell's guess at the caller's words,
|
|
36
|
+
before the caller finishes.
|
|
37
|
+
|
|
38
|
+
Bell is a hosted model from Rabel Labs that learns each of your agents' callers from that agent's own calls. It is in
|
|
39
|
+
beta. It works best on agents whose callers come for the same few things, like a bank's phone line or a booking desk.
|
|
40
|
+
Where callers talk freely, Bell has little to guess and mostly stays quiet, and the call runs as it would without it.
|
|
41
|
+
|
|
42
|
+
As your speech-to-text hears a turn, Bell may guess the whole turn.
|
|
43
|
+
`RabelBellUserTurnStopStrategy`, a user turn stop strategy, starts Pipecat's early reply on that guess. At the end of the
|
|
44
|
+
turn Pipecat keeps the reply only if the final words match the guess; otherwise it discards the reply unheard and answers
|
|
45
|
+
the final words. The package adds nothing to your pipeline, sends no frame and replaces no service.
|
|
46
|
+
|
|
47
|
+
Bell runs on Rabel's servers: there is nothing to host and no GPU. The API's docs:
|
|
48
|
+
[rabellabs.com/docs](https://rabellabs.com/docs). Tested with Pipecat 1.16.0. The numbers here come from recorded,
|
|
49
|
+
scripted calls to one bank, in English, on Deepgram Flux's words; the rest is under [Limits](#limits).
|
|
50
|
+
|
|
51
|
+
**What Rabel keeps.** Bell never receives audio. It takes nothing but the words from your
|
|
52
|
+
speech-to-text and holds a call's words only while that call is open. When the call closes, Bell learns from them for
|
|
53
|
+
your agent and drops them. What it learns stays with your agent and is never filed under a call or under a caller's name
|
|
54
|
+
or number. Part of it is kept as codes that Rabel holds the key to, and the rest is short phrases kept in words. A phrase
|
|
55
|
+
can be a name or a number your callers say. You can list your agent's phrases at any time and delete any of them.
|
|
56
|
+
Deleting an agent erases what Bell learned for it. Rabel's notice says it in full:
|
|
57
|
+
[rabellabs.com/api-privacy](https://rabellabs.com/api-privacy).
|
|
58
|
+
|
|
59
|
+
This is a community integration, built and maintained by Rabel Labs, which runs Bell. Rabel Labs is not affiliated with,
|
|
60
|
+
endorsed by or sponsored by LiveKit, Pipecat (Daily) or Deepgram; they are named only to say what the package works with.
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
uv add pipecat-rabel
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
It needs Pipecat 1.16.0 or later (below 2) and Python 3.11 or later, and a Rabel API key in `RABEL_API_KEY`
|
|
69
|
+
([sign up](https://rabellabs.com/signup); the first 10,000 minutes are free).
|
|
70
|
+
|
|
71
|
+
## Usage with a Pipecat pipeline
|
|
72
|
+
|
|
73
|
+
Give Bell's turn strategies to your user aggregator. Nothing goes in the pipeline.
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
import os
|
|
77
|
+
|
|
78
|
+
from pipecat.pipeline.pipeline import Pipeline
|
|
79
|
+
from pipecat.processors.aggregators.llm_context import LLMContext
|
|
80
|
+
from pipecat.processors.aggregators.llm_response_universal import (
|
|
81
|
+
LLMContextAggregatorPair,
|
|
82
|
+
LLMUserAggregatorParams,
|
|
83
|
+
)
|
|
84
|
+
from pipecat.services.deepgram.flux.stt import DeepgramFluxSTTService
|
|
85
|
+
|
|
86
|
+
from pipecat_rabel import RabelBellUserTurnStrategies
|
|
87
|
+
|
|
88
|
+
stt = DeepgramFluxSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"), enable_eager_end_of_turn=True)
|
|
89
|
+
|
|
90
|
+
context = LLMContext()
|
|
91
|
+
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
|
|
92
|
+
context,
|
|
93
|
+
user_params=LLMUserAggregatorParams(
|
|
94
|
+
user_turn_strategies=RabelBellUserTurnStrategies(agent="demo-bank"),
|
|
95
|
+
),
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
# transport, llm and tts are your own; the pipeline is Pipecat's usual one
|
|
99
|
+
pipeline = Pipeline(
|
|
100
|
+
[transport.input(), stt, user_aggregator, llm, tts, transport.output(), assistant_aggregator]
|
|
101
|
+
)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
`RabelBellUserTurnStrategies` is built on Pipecat's `ExternalUserTurnStrategies`, as `EagerUserTurnStrategies` is,
|
|
105
|
+
with Bell's stop strategy, a subclass of `EagerUserTurnStopStrategy`. It uses Pipecat's documented door for answering
|
|
106
|
+
early: a custom stop strategy that calls `start_user_turn_speculation()`, `cancel_user_turn_speculation()` and
|
|
107
|
+
`report_user_turn_stopped()`. With Flux's eager end of turn on, as above, Pipecat answers early on Flux's ends of turn
|
|
108
|
+
and on Bell's guesses; with it off, on Bell's guesses alone.
|
|
109
|
+
|
|
110
|
+
The bundle replaces the turn strategies Flux recommends. If you set Flux's `should_interrupt=False`, pass
|
|
111
|
+
`RabelBellUserTurnStrategies(enable_interruptions=False)`.
|
|
112
|
+
|
|
113
|
+
`demo-bank` is a demonstration agent already trained on a bank's callers, so it guesses from the first call. Use your
|
|
114
|
+
own agent's name once it takes calls. A new name sends no guess until Bell has learned enough of its calls. The
|
|
115
|
+
conversation always holds the speech-to-text's final words, never the guess.
|
|
116
|
+
|
|
117
|
+
## Running the example
|
|
118
|
+
|
|
119
|
+
[`examples/bank_call.py`](https://github.com/rabellabs/pipecat-rabel/blob/main/examples/bank_call.py) is a bank's phone agent: Deepgram Flux, Bell, Claude Haiku 5.5 and
|
|
120
|
+
Deepgram Aura-2, talking to you in the browser.
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
uv add "pipecat-rabel[example]"
|
|
124
|
+
export RABEL_API_KEY=... DEEPGRAM_API_KEY=... ANTHROPIC_API_KEY=...
|
|
125
|
+
python examples/bank_call.py # then open http://localhost:7860 and talk
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Say "I need to reset my password". Each turn logs Bell's guess, whether it was right, and how long before the final
|
|
129
|
+
words the reply on it started. Its calls are from the Gridspace-Stanford Harper Valley dataset of simulated
|
|
130
|
+
bank calls (CC BY 4.0).
|
|
131
|
+
|
|
132
|
+
## Settings
|
|
133
|
+
|
|
134
|
+
The bundle and the strategy take the same settings. The strategy is `strategies.bell`.
|
|
135
|
+
|
|
136
|
+
| Setting | Default | What it does |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| `api_key` | `RABEL_API_KEY` | Without a key Bell stays off, the strategy is Pipecat's eager one, and one line is logged. |
|
|
139
|
+
| `agent` | `"default"` | The agent Bell learns for: 1 to 64 lower-case letters, digits, `-` and `_`. Calls that share an agent name share what Bell learns. Give each voice agent you run its own name, such as `front-desk` or `billing`, and keep all of that agent's calls under it. |
|
|
140
|
+
| `min_chance` | `0.7` | How sure Bell must be before it guesses, 0.67 to 0.99. Higher means fewer guesses and fewer wrong ones. |
|
|
141
|
+
| `learn` | `True` | `False` means this call teaches Bell nothing. |
|
|
142
|
+
| `report` | `True` | Tells the API at each turn's end whether the guess was kept or dropped, with no words, so the agent's status can show it. |
|
|
143
|
+
| `user` | `None` | An id you choose for the person on the call. Bell does not use it yet. Never a name, a number or an address. |
|
|
144
|
+
| `vendor` | `None` | Your speech-to-text, for example `"deepgram/flux-general-en"`, for usage reports. |
|
|
145
|
+
| `connect_timeout` | `2.0` | Seconds allowed to open a conversation with the API. |
|
|
146
|
+
| `answer_timeout` | `0.5` | Seconds after the words it answers within which a guess is still used. |
|
|
147
|
+
| `match_policy` | `NormalizedMatch()` | Pipecat's check of an early reply's words against the final words. |
|
|
148
|
+
| `speculation_timeout` | `5.0` | Seconds an early reply may go unresolved before it is withdrawn. |
|
|
149
|
+
| `url` | `RABEL_API_URL`, then Rabel's API | The API's address. |
|
|
150
|
+
|
|
151
|
+
Events on the strategy: `on_ready(strategy, ready)`, `on_guess(strategy, text, chance)` and
|
|
152
|
+
`on_turn_end(strategy, final, guess, right)`. `strategy.stats` counts turns, guesses received, started, dropped and right,
|
|
153
|
+
and failures by kind.
|
|
154
|
+
|
|
155
|
+
## What was measured
|
|
156
|
+
|
|
157
|
+
On recorded, scripted calls to one bank (Harper Valley), in English, on Deepgram Flux's words. Bell learned from 1,070
|
|
158
|
+
calls by 27 callers and was measured on 376 calls by 28 callers it had never heard (95% intervals, by whole calls).
|
|
159
|
+
|
|
160
|
+
- On Pipecat 1.16.0 with Flux deciding the end of the turn, Bell started the reply 170 ms a turn sooner [159, 182] than
|
|
161
|
+
with no early start, at 0.07 more LLM calls a turn. That is when the LLM starts. Pipecat holds an early reply until the
|
|
162
|
+
turn ends, so the caller hears less of it: in one reading with Claude Haiku 5.5 and Deepgram Aura-2, the first audio came
|
|
163
|
+
133 ms a turn sooner [125, 142]. The package ran as `RabelBellUserTurnStrategies` on the user aggregator, with Flux's
|
|
164
|
+
eager end of turn off and no local VAD.
|
|
165
|
+
- Under LiveKit's default (its own turn detector with preemptive generation, on LiveKit Agents 1.8.13 on our own
|
|
166
|
+
machines), Bell started the reply 118 ms a turn sooner [108, 128], at 0.11 more LLM calls a turn. In one reading the
|
|
167
|
+
first audio came 115 ms a turn sooner [105, 125].
|
|
168
|
+
|
|
169
|
+
The method, the other rows, the script and its data are in [Rabel's benchmark](https://github.com/rabellabs/bell-benchmark).
|
|
170
|
+
|
|
171
|
+
## Limits
|
|
172
|
+
|
|
173
|
+
- **The numbers come from one kind of call:** scripted calls to one bank, in English, on Flux's words. On freer speech we
|
|
174
|
+
have only looked informally, and Bell mostly stayed quiet. No live deployment's callers and no other language have been
|
|
175
|
+
measured.
|
|
176
|
+
- **A wrong guess costs one LLM call** and nothing the caller hears, when these turn strategies end the turn. If your app,
|
|
177
|
+
or a turn processor ahead of the aggregator such as `UserTurnProcessor`, pushes `UserStoppedSpeakingFrame` itself,
|
|
178
|
+
Pipecat releases the early reply before the words are checked and the caller can hear both replies.
|
|
179
|
+
- **It takes the place of Smart Turn.** Like Pipecat's eager strategies, it leaves the end of the turn to the
|
|
180
|
+
speech-to-text, so the speech-to-text must end turns and send interim transcriptions, as Flux does.
|
|
181
|
+
- **A local VAD can withdraw an early start** when the caller pauses and speaks again. That start costs one LLM call and
|
|
182
|
+
gains nothing; the reply starts early again when the words reach Bell's guess or Flux's eager end of turn comes.
|
|
183
|
+
- **A reply started on a guess never runs a tool call.** Pipecat withdraws it and the reply to the final words runs it.
|
|
184
|
+
- **It fails open.** While the API is unreachable, slow, refusing or sending what the strategy cannot read, Bell starts no
|
|
185
|
+
early reply, the turn goes exactly as with Pipecat's eager strategy, and one line is logged for each kind of failure.
|
|
186
|
+
The pipeline never waits for the API. After a busy, slow or unreachable API it tries again on its own; after a refused
|
|
187
|
+
key, no minutes left or an unknown agent, Bell stays off for the rest of the call.
|
|
188
|
+
- **The stats and the turn's report count a refused guess differently.** A guess the strategy refuses as unreadable,
|
|
189
|
+
under `min_chance`, late or for other words counts as dropped in `strategy.stats` and shows as "none" in the turn's
|
|
190
|
+
report.
|
|
191
|
+
|
|
192
|
+
## Tests
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
uv run --extra test pytest
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
112 tests, with no key and no network, against a local stand-in for the API, with the strategy in Pipecat's own user
|
|
199
|
+
aggregator. A [workflow](https://github.com/rabellabs/pipecat-rabel/blob/main/.github/workflows/nightly.yml) also runs them every night against Pipecat's main branch.
|
|
200
|
+
|
|
201
|
+
Tested with Pipecat 1.16.0 on Python 3.11, 3.12 and 3.13.
|
|
202
|
+
|
|
203
|
+
## License
|
|
204
|
+
|
|
205
|
+
BSD 2-Clause. See [LICENSE](https://github.com/rabellabs/pipecat-rabel/blob/main/LICENSE).
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Bell for Pipecat
|
|
2
|
+
|
|
3
|
+
Starts your [Pipecat](https://github.com/pipecat-ai/pipecat) voice agent's reply on Bell's guess at the caller's words,
|
|
4
|
+
before the caller finishes.
|
|
5
|
+
|
|
6
|
+
Bell is a hosted model from Rabel Labs that learns each of your agents' callers from that agent's own calls. It is in
|
|
7
|
+
beta. It works best on agents whose callers come for the same few things, like a bank's phone line or a booking desk.
|
|
8
|
+
Where callers talk freely, Bell has little to guess and mostly stays quiet, and the call runs as it would without it.
|
|
9
|
+
|
|
10
|
+
As your speech-to-text hears a turn, Bell may guess the whole turn.
|
|
11
|
+
`RabelBellUserTurnStopStrategy`, a user turn stop strategy, starts Pipecat's early reply on that guess. At the end of the
|
|
12
|
+
turn Pipecat keeps the reply only if the final words match the guess; otherwise it discards the reply unheard and answers
|
|
13
|
+
the final words. The package adds nothing to your pipeline, sends no frame and replaces no service.
|
|
14
|
+
|
|
15
|
+
Bell runs on Rabel's servers: there is nothing to host and no GPU. The API's docs:
|
|
16
|
+
[rabellabs.com/docs](https://rabellabs.com/docs). Tested with Pipecat 1.16.0. The numbers here come from recorded,
|
|
17
|
+
scripted calls to one bank, in English, on Deepgram Flux's words; the rest is under [Limits](#limits).
|
|
18
|
+
|
|
19
|
+
**What Rabel keeps.** Bell never receives audio. It takes nothing but the words from your
|
|
20
|
+
speech-to-text and holds a call's words only while that call is open. When the call closes, Bell learns from them for
|
|
21
|
+
your agent and drops them. What it learns stays with your agent and is never filed under a call or under a caller's name
|
|
22
|
+
or number. Part of it is kept as codes that Rabel holds the key to, and the rest is short phrases kept in words. A phrase
|
|
23
|
+
can be a name or a number your callers say. You can list your agent's phrases at any time and delete any of them.
|
|
24
|
+
Deleting an agent erases what Bell learned for it. Rabel's notice says it in full:
|
|
25
|
+
[rabellabs.com/api-privacy](https://rabellabs.com/api-privacy).
|
|
26
|
+
|
|
27
|
+
This is a community integration, built and maintained by Rabel Labs, which runs Bell. Rabel Labs is not affiliated with,
|
|
28
|
+
endorsed by or sponsored by LiveKit, Pipecat (Daily) or Deepgram; they are named only to say what the package works with.
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
uv add pipecat-rabel
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
It needs Pipecat 1.16.0 or later (below 2) and Python 3.11 or later, and a Rabel API key in `RABEL_API_KEY`
|
|
37
|
+
([sign up](https://rabellabs.com/signup); the first 10,000 minutes are free).
|
|
38
|
+
|
|
39
|
+
## Usage with a Pipecat pipeline
|
|
40
|
+
|
|
41
|
+
Give Bell's turn strategies to your user aggregator. Nothing goes in the pipeline.
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
import os
|
|
45
|
+
|
|
46
|
+
from pipecat.pipeline.pipeline import Pipeline
|
|
47
|
+
from pipecat.processors.aggregators.llm_context import LLMContext
|
|
48
|
+
from pipecat.processors.aggregators.llm_response_universal import (
|
|
49
|
+
LLMContextAggregatorPair,
|
|
50
|
+
LLMUserAggregatorParams,
|
|
51
|
+
)
|
|
52
|
+
from pipecat.services.deepgram.flux.stt import DeepgramFluxSTTService
|
|
53
|
+
|
|
54
|
+
from pipecat_rabel import RabelBellUserTurnStrategies
|
|
55
|
+
|
|
56
|
+
stt = DeepgramFluxSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"), enable_eager_end_of_turn=True)
|
|
57
|
+
|
|
58
|
+
context = LLMContext()
|
|
59
|
+
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
|
|
60
|
+
context,
|
|
61
|
+
user_params=LLMUserAggregatorParams(
|
|
62
|
+
user_turn_strategies=RabelBellUserTurnStrategies(agent="demo-bank"),
|
|
63
|
+
),
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
# transport, llm and tts are your own; the pipeline is Pipecat's usual one
|
|
67
|
+
pipeline = Pipeline(
|
|
68
|
+
[transport.input(), stt, user_aggregator, llm, tts, transport.output(), assistant_aggregator]
|
|
69
|
+
)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`RabelBellUserTurnStrategies` is built on Pipecat's `ExternalUserTurnStrategies`, as `EagerUserTurnStrategies` is,
|
|
73
|
+
with Bell's stop strategy, a subclass of `EagerUserTurnStopStrategy`. It uses Pipecat's documented door for answering
|
|
74
|
+
early: a custom stop strategy that calls `start_user_turn_speculation()`, `cancel_user_turn_speculation()` and
|
|
75
|
+
`report_user_turn_stopped()`. With Flux's eager end of turn on, as above, Pipecat answers early on Flux's ends of turn
|
|
76
|
+
and on Bell's guesses; with it off, on Bell's guesses alone.
|
|
77
|
+
|
|
78
|
+
The bundle replaces the turn strategies Flux recommends. If you set Flux's `should_interrupt=False`, pass
|
|
79
|
+
`RabelBellUserTurnStrategies(enable_interruptions=False)`.
|
|
80
|
+
|
|
81
|
+
`demo-bank` is a demonstration agent already trained on a bank's callers, so it guesses from the first call. Use your
|
|
82
|
+
own agent's name once it takes calls. A new name sends no guess until Bell has learned enough of its calls. The
|
|
83
|
+
conversation always holds the speech-to-text's final words, never the guess.
|
|
84
|
+
|
|
85
|
+
## Running the example
|
|
86
|
+
|
|
87
|
+
[`examples/bank_call.py`](https://github.com/rabellabs/pipecat-rabel/blob/main/examples/bank_call.py) is a bank's phone agent: Deepgram Flux, Bell, Claude Haiku 5.5 and
|
|
88
|
+
Deepgram Aura-2, talking to you in the browser.
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
uv add "pipecat-rabel[example]"
|
|
92
|
+
export RABEL_API_KEY=... DEEPGRAM_API_KEY=... ANTHROPIC_API_KEY=...
|
|
93
|
+
python examples/bank_call.py # then open http://localhost:7860 and talk
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Say "I need to reset my password". Each turn logs Bell's guess, whether it was right, and how long before the final
|
|
97
|
+
words the reply on it started. Its calls are from the Gridspace-Stanford Harper Valley dataset of simulated
|
|
98
|
+
bank calls (CC BY 4.0).
|
|
99
|
+
|
|
100
|
+
## Settings
|
|
101
|
+
|
|
102
|
+
The bundle and the strategy take the same settings. The strategy is `strategies.bell`.
|
|
103
|
+
|
|
104
|
+
| Setting | Default | What it does |
|
|
105
|
+
|---|---|---|
|
|
106
|
+
| `api_key` | `RABEL_API_KEY` | Without a key Bell stays off, the strategy is Pipecat's eager one, and one line is logged. |
|
|
107
|
+
| `agent` | `"default"` | The agent Bell learns for: 1 to 64 lower-case letters, digits, `-` and `_`. Calls that share an agent name share what Bell learns. Give each voice agent you run its own name, such as `front-desk` or `billing`, and keep all of that agent's calls under it. |
|
|
108
|
+
| `min_chance` | `0.7` | How sure Bell must be before it guesses, 0.67 to 0.99. Higher means fewer guesses and fewer wrong ones. |
|
|
109
|
+
| `learn` | `True` | `False` means this call teaches Bell nothing. |
|
|
110
|
+
| `report` | `True` | Tells the API at each turn's end whether the guess was kept or dropped, with no words, so the agent's status can show it. |
|
|
111
|
+
| `user` | `None` | An id you choose for the person on the call. Bell does not use it yet. Never a name, a number or an address. |
|
|
112
|
+
| `vendor` | `None` | Your speech-to-text, for example `"deepgram/flux-general-en"`, for usage reports. |
|
|
113
|
+
| `connect_timeout` | `2.0` | Seconds allowed to open a conversation with the API. |
|
|
114
|
+
| `answer_timeout` | `0.5` | Seconds after the words it answers within which a guess is still used. |
|
|
115
|
+
| `match_policy` | `NormalizedMatch()` | Pipecat's check of an early reply's words against the final words. |
|
|
116
|
+
| `speculation_timeout` | `5.0` | Seconds an early reply may go unresolved before it is withdrawn. |
|
|
117
|
+
| `url` | `RABEL_API_URL`, then Rabel's API | The API's address. |
|
|
118
|
+
|
|
119
|
+
Events on the strategy: `on_ready(strategy, ready)`, `on_guess(strategy, text, chance)` and
|
|
120
|
+
`on_turn_end(strategy, final, guess, right)`. `strategy.stats` counts turns, guesses received, started, dropped and right,
|
|
121
|
+
and failures by kind.
|
|
122
|
+
|
|
123
|
+
## What was measured
|
|
124
|
+
|
|
125
|
+
On recorded, scripted calls to one bank (Harper Valley), in English, on Deepgram Flux's words. Bell learned from 1,070
|
|
126
|
+
calls by 27 callers and was measured on 376 calls by 28 callers it had never heard (95% intervals, by whole calls).
|
|
127
|
+
|
|
128
|
+
- On Pipecat 1.16.0 with Flux deciding the end of the turn, Bell started the reply 170 ms a turn sooner [159, 182] than
|
|
129
|
+
with no early start, at 0.07 more LLM calls a turn. That is when the LLM starts. Pipecat holds an early reply until the
|
|
130
|
+
turn ends, so the caller hears less of it: in one reading with Claude Haiku 5.5 and Deepgram Aura-2, the first audio came
|
|
131
|
+
133 ms a turn sooner [125, 142]. The package ran as `RabelBellUserTurnStrategies` on the user aggregator, with Flux's
|
|
132
|
+
eager end of turn off and no local VAD.
|
|
133
|
+
- Under LiveKit's default (its own turn detector with preemptive generation, on LiveKit Agents 1.8.13 on our own
|
|
134
|
+
machines), Bell started the reply 118 ms a turn sooner [108, 128], at 0.11 more LLM calls a turn. In one reading the
|
|
135
|
+
first audio came 115 ms a turn sooner [105, 125].
|
|
136
|
+
|
|
137
|
+
The method, the other rows, the script and its data are in [Rabel's benchmark](https://github.com/rabellabs/bell-benchmark).
|
|
138
|
+
|
|
139
|
+
## Limits
|
|
140
|
+
|
|
141
|
+
- **The numbers come from one kind of call:** scripted calls to one bank, in English, on Flux's words. On freer speech we
|
|
142
|
+
have only looked informally, and Bell mostly stayed quiet. No live deployment's callers and no other language have been
|
|
143
|
+
measured.
|
|
144
|
+
- **A wrong guess costs one LLM call** and nothing the caller hears, when these turn strategies end the turn. If your app,
|
|
145
|
+
or a turn processor ahead of the aggregator such as `UserTurnProcessor`, pushes `UserStoppedSpeakingFrame` itself,
|
|
146
|
+
Pipecat releases the early reply before the words are checked and the caller can hear both replies.
|
|
147
|
+
- **It takes the place of Smart Turn.** Like Pipecat's eager strategies, it leaves the end of the turn to the
|
|
148
|
+
speech-to-text, so the speech-to-text must end turns and send interim transcriptions, as Flux does.
|
|
149
|
+
- **A local VAD can withdraw an early start** when the caller pauses and speaks again. That start costs one LLM call and
|
|
150
|
+
gains nothing; the reply starts early again when the words reach Bell's guess or Flux's eager end of turn comes.
|
|
151
|
+
- **A reply started on a guess never runs a tool call.** Pipecat withdraws it and the reply to the final words runs it.
|
|
152
|
+
- **It fails open.** While the API is unreachable, slow, refusing or sending what the strategy cannot read, Bell starts no
|
|
153
|
+
early reply, the turn goes exactly as with Pipecat's eager strategy, and one line is logged for each kind of failure.
|
|
154
|
+
The pipeline never waits for the API. After a busy, slow or unreachable API it tries again on its own; after a refused
|
|
155
|
+
key, no minutes left or an unknown agent, Bell stays off for the rest of the call.
|
|
156
|
+
- **The stats and the turn's report count a refused guess differently.** A guess the strategy refuses as unreadable,
|
|
157
|
+
under `min_chance`, late or for other words counts as dropped in `strategy.stats` and shows as "none" in the turn's
|
|
158
|
+
report.
|
|
159
|
+
|
|
160
|
+
## Tests
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
uv run --extra test pytest
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
112 tests, with no key and no network, against a local stand-in for the API, with the strategy in Pipecat's own user
|
|
167
|
+
aggregator. A [workflow](https://github.com/rabellabs/pipecat-rabel/blob/main/.github/workflows/nightly.yml) also runs them every night against Pipecat's main branch.
|
|
168
|
+
|
|
169
|
+
Tested with Pipecat 1.16.0 on Python 3.11, 3.12 and 3.13.
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
BSD 2-Clause. See [LICENSE](https://github.com/rabellabs/pipecat-rabel/blob/main/LICENSE).
|