livekit-plugins-rabel 1.8.13__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.
@@ -0,0 +1,5 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ dist/
5
+ .pytest_cache/
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,185 @@
1
+ Metadata-Version: 2.5
2
+ Name: livekit-plugins-rabel
3
+ Version: 1.8.13
4
+ Summary: Agent Framework plugin for Rabel Bell: an early start for your agent's reply, on a guess at how the turn will end
5
+ Project-URL: Documentation, https://docs.livekit.io
6
+ Project-URL: Website, https://rabellabs.com/
7
+ Author: Rabel Labs
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: ai,audio,bell,livekit,preemptive generation,rabel,realtime,stt,voice
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Framework :: AsyncIO
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: Apache Software License
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.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.10.0
25
+ Requires-Dist: livekit-agents<2,>=1.8.13
26
+ Description-Content-Type: text/markdown
27
+
28
+ # Rabel plugin for LiveKit Agents
29
+
30
+ Starts your [LiveKit](https://github.com/livekit/agents) voice agent's reply on [Rabel](https://rabellabs.com) Bell's
31
+ guess at the caller's final words, before the caller finishes.
32
+
33
+ Bell is a model behind Rabel's API that learns each agent's own callers from that agent's finished calls. It is in beta.
34
+ It works best on agents whose callers come for the same few things, like a bank's phone line or a booking desk.
35
+ Where callers talk freely, Bell has little to guess and mostly stays quiet, and the call runs as it would without it.
36
+
37
+ While the
38
+ caller speaks, it reads your speech-to-text's words and, once it has learned enough of that agent's calls, guesses how
39
+ the turn will end. The plugin wraps your speech-to-text and sends that guess to LiveKit as a preflight transcript, the
40
+ same signal Deepgram Flux's eager end of turn sends. LiveKit starts the LLM on it (preemptive generation), and its own
41
+ check keeps that reply only if the turn's final words match the guess. Your speech-to-text still decides where the turn
42
+ ends.
43
+
44
+ Bell runs on Rabel's servers: there is nothing to host and no GPU. It answers in about 3 ms to an agent in the same cloud
45
+ region (Google Cloud's us-east1) and about 72 ms from the US west coast, read from one Google Cloud machine in each (the
46
+ western one in Oregon) and not yet from LiveKit Cloud or any other network. One key holds up to 50 calls at once. Tested with LiveKit Agents 1.8.13. The numbers here come from
47
+ scripted calls to one bank, in English, with Deepgram Flux as the speech-to-text; the rest is under [Limits](#limits).
48
+
49
+ **What Rabel keeps.** Bell never receives audio. It takes nothing but the words from your speech-to-text and holds a
50
+ call's words only while that call is open. When the call closes, Bell learns from them for your agent and drops them.
51
+ What it learns stays with your agent and is never filed under a call or under a caller's name or number. Part of it is
52
+ kept as codes that Rabel holds the key to, and the rest is short phrases kept in words. A phrase can be a name or a
53
+ number your callers say. You can list your agent's phrases at any time and delete any of them. Deleting an agent erases
54
+ what Bell learned for it. Rabel's notice says it in full: [rabellabs.com/api-privacy](https://rabellabs.com/api-privacy).
55
+
56
+ Rabel Labs is not affiliated with, endorsed by or sponsored by LiveKit, Pipecat (Daily) or Deepgram; they are named only
57
+ to say what the package works with.
58
+
59
+ ## Installation
60
+
61
+ ```bash
62
+ pip install livekit-plugins-rabel
63
+ ```
64
+
65
+ It needs `livekit-agents` 1.8.13 or later, before 2.0. Install your speech-to-text's plugin as you do today (for example
66
+ `livekit-plugins-deepgram`); this package does not bring one.
67
+
68
+ You need a Rabel API key, `demo-bank` included: see "Get an API key" in the [Rabel API docs](https://rabellabs.com/docs).
69
+ The price is on [Rabel's pricing page](https://rabellabs.com/pricing). Set the key in `RABEL_API_KEY`. Each speech
70
+ stream the plugin wraps (one for a call) keeps one conversation with the API open for the whole call, and the API meters
71
+ the seconds it is open, silence included.
72
+
73
+ ## Usage
74
+
75
+ Wrap the speech-to-text you already use. This is the one changed line:
76
+
77
+ ```python
78
+ from livekit.agents import AgentSession, TurnHandlingOptions
79
+ from livekit.plugins import deepgram, rabel
80
+
81
+ session = AgentSession(
82
+ stt=rabel.STT(deepgram.STTv2(model="flux-general-en", eager_eot_threshold=0.5), agent="front-desk"),
83
+ turn_handling=TurnHandlingOptions(turn_detection="stt"),
84
+ ...
85
+ )
86
+ ```
87
+
88
+ A new agent starts with nothing learned, and Bell sends no guess until it has heard enough of that agent's calls. To see
89
+ it work at once, use `agent="demo-bank"`: a ready-made agent that every account can use, already trained on a bank's
90
+ callers (the Gridspace-Stanford Harper Valley dataset of simulated bank calls, CC BY 4.0). A conversation that sounds
91
+ like a call to a bank gets guesses; talk on another topic rarely does. `demo-bank` never learns.
92
+
93
+ Any streaming speech-to-text with interim results can be wrapped. Bell goes with the speech-to-text's own early starts,
94
+ not instead of them: on turns where Bell has no guess, the events are the speech-to-text's, unchanged. Preemptive
95
+ generation is on by default in LiveKit, and Bell needs it on.
96
+
97
+ `turn_detection="stt"` is not required. Bell also works under LiveKit's own turn detection (its VAD and turn detector,
98
+ the default). There LiveKit keeps an early reply only when the final transcript is the same string as the guess, so
99
+ the plugin writes the guess the way your speech-to-text writes its finals.
100
+
101
+ Rabel's numbers were measured in a different setup from this snippet: LiveKit's own turn detector ends the turn,
102
+ preemptive generation is on and Flux's eager end of turn is off. That is
103
+ `rabel.STT(deepgram.STTv2(model="flux-general-en"), agent="front-desk")` with `turn_handling` left as it is.
104
+
105
+ ## How a guess is handled
106
+
107
+ - Bell sends at most one guess a turn, never one equal to the words it was made from, and only within `answer_timeout`
108
+ of those words, at or above `min_chance`, on the turn it answers. A turn is sent to Bell only if its first words are:
109
+ when the connection opens or reopens mid-turn, Bell starts with the next turn.
110
+ - The plugin keeps within LiveKit's default limits for preemptive generation (`max_retries` 3, `max_speech_duration`
111
+ 10 s): a guess is never the third early start of a turn and is never sent after 10 seconds of speech.
112
+ - **With Flux's eager end of turn on**, Bell sends no guess once your speech-to-text has made its own early start in the
113
+ turn, because the guess would cancel that start's reply or take a start the speech-to-text needs next. On a turn where
114
+ Bell's guess took one of LiveKit's early starts, the speech-to-text's own early start is held back when none is left
115
+ and a reply is running, because LiveKit would cancel that reply and start none.
116
+ - While Bell's guess is the running early start, the plugin holds back the interim transcripts and the speech-to-text's
117
+ own preflight that agree with it, because LiveKit would otherwise cancel the reply. Anything that disagrees is passed
118
+ and cancels the wrong reply. The final words still decide whether the reply is kept.
119
+ - While LiveKit's own early reply made on a final transcript waits for LiveKit's end of turn, the plugin holds Bell's
120
+ guess, which would replace that reply, and never sends it later. The plugin sees LiveKit's end of turn through the
121
+ session's `stt_context_options` `forward_chat_context`, on by default. With it off, the plugin holds every guess that
122
+ comes after LiveKit's own early start on a final.
123
+
124
+ These rules make it rare for a guess to start a reply later than it would have started without Bell. Rare is not never.
125
+
126
+ ## Options
127
+
128
+ | Option | Default | |
129
+ |---|---|---|
130
+ | `agent` | `"default"` | Your agent's name: 1 to 64 lower-case letters, digits, `-` or `_`. Each agent learns from its own calls, and calls that share a name share what Bell learns: give each voice agent you run its own name and keep all of its calls under it. What Bell learns for it belongs to your account, so a new key keeps it. `"demo-bank"` is read-only. |
131
+ | `min_chance` | `0.7` | How sure Bell must be before it guesses, from `0.67` to `0.99`. Higher sends fewer guesses, and fewer wrong ones. A value outside is clamped and one line is logged. |
132
+ | `answer_timeout` | `0.5` | Seconds after its words within which a guess is still used. |
133
+ | `learn` | `True` | `False` means the calls through this wrapper teach Bell nothing. |
134
+ | `user` | `None` | An id you choose for the person on the call: 1 to 128 letters, digits, `.`, `_`, `:` or `-`. Bell does not use it yet. Never a name, a number or an address. |
135
+ | `report` | `True` | Tells the API at each turn's end whether the guess was kept or dropped, with the head start of a kept one and no words, so your agent's status can show them. |
136
+ | `enabled` | `True` | `False` makes the wrapper a plain pass-through. |
137
+ | `api_key` | `RABEL_API_KEY` | Your Rabel API key. |
138
+ | `base_url` | `RABEL_API_URL`, else `https://api.rabellabs.com` | The API's address. |
139
+ | `http_session` | the job's own, else a new one | An `aiohttp.ClientSession` for the API's WebSocket. |
140
+
141
+ All but the last three can be changed with `update_options()`. `answer_timeout` and `report` take effect at once and
142
+ the others from the next speech stream. `user=None` stops sending the id. An `agent`, `user`, `learn` or `report` not
143
+ of the form above, a `min_chance` that is not a number or an `answer_timeout` not over 0 raises `ValueError`. Bell is
144
+ sent the caller's words only, never the agent's lines.
145
+
146
+ ## Seeing Bell work
147
+
148
+ Set the `livekit.plugins.rabel` logger to `DEBUG`. Each guess sent logs "Bell: a guess sent as an early start" with its
149
+ chance, and each guess LiveKit kept logs "Bell's guess kept" with its head start in milliseconds. At `INFO`, one line
150
+ when the stream closes gives the call's turns, guesses, kept, dropped and head start in all. No line carries a word of
151
+ the call. LiveKit's own "using preemptive generation" line does not show Bell's guess was kept: LiveKit prints it for
152
+ every early reply it keeps.
153
+
154
+ The API's `GET /v1/agents/{agent}` shows the calls Bell has heard for your agent and, with `report` on,
155
+ `guesses_kept`, `guesses_dropped`, the head start and the agent's state (`learning`, `guessing` or `quiet`). The plugin
156
+ reports your speech-to-text's model and provider as its own, so LiveKit's metrics and logs name your speech-to-text.
157
+
158
+ ## Limits
159
+
160
+ - **The numbers come from one kind of call:** scripted calls to one bank, in English, with Flux's words. On freer speech we
161
+ have only looked informally, and Bell mostly stayed quiet. No live deployment's callers and no other language have been
162
+ measured, and the numbers were not read with Flux's eager end of turn on.
163
+ - **A later reply is rare, not impossible.** On some turns a guess can still start the reply later than it would have
164
+ started without Bell.
165
+ - **Keep LiveKit's default preemptive-generation limits.** The plugin assumes them. With lower limits set in
166
+ `preemptive_generation`, a guess can take the place of an early reply that LiveKit then has no try left to replace.
167
+ - **Keep LiveKit's minimum interruption words at its default 0.** Set above 0 (`min_words` in `turn_handling`'s
168
+ interruption options, `min_interruption_words` before), LiveKit counts a guess's words as the caller's. A "yeah" while
169
+ your agent speaks can bring a guess long enough to interrupt or pause it.
170
+ - **Keep `forward_chat_context` on.** Off, Bell sends fewer guesses (above).
171
+ - **While a guess is live, your live caption shows the guess.** The user transcript LiveKit shows and sends to your
172
+ front end carries Bell's guess, not the caller's words so far, until the words move past it or the final arrives. A
173
+ front end cannot tell the two apart. Only `enabled=False` turns this off.
174
+ - **An app that commits turns itself should set `enabled=False`.** LiveKit starts no early reply on turns committed by
175
+ hand (`session.commit_user_turn()`, push-to-talk, `turn_detection="manual"`), so Bell gives it nothing. And a commit,
176
+ or the session closing, within half a second of a guess commits the guess as the caller's words.
177
+ - **It fails open.** If the API is slow, down, refuses or errors, the events are exactly your speech-to-text's, nothing
178
+ is raised into the agent, and at most one line is logged for each kind of failure. With nothing listening, or no
179
+ ready within 2 s of opening, it retries after 1, 2, 4, 8 and 16 s, then every 30 s. A 429 `key_at_once` or 529
180
+ `out_of_capacity` retries the same way, or after the API's `retry_after_s` when that is longer (at most 300 s). A 400
181
+ `bad_message`, 401 `bad_key`, 402 `no_seconds` or 404 `unknown_agent` ends Bell for that stream. Broken data from the
182
+ API is ignored. A guess that comes late, under `min_chance` or after its turn has ended is dropped. With no API key, or
183
+ `enabled=False`, no connection is opened. A conversation that closes cleanly after a minute or more (the API closes
184
+ one after an hour) is reopened at once; any other is reopened as when the API is down. The tests run each of these
185
+ cases against a local stand-in for version 1 and version 2 of Rabel's API.
@@ -0,0 +1,158 @@
1
+ # Rabel plugin for LiveKit Agents
2
+
3
+ Starts your [LiveKit](https://github.com/livekit/agents) voice agent's reply on [Rabel](https://rabellabs.com) Bell's
4
+ guess at the caller's final words, before the caller finishes.
5
+
6
+ Bell is a model behind Rabel's API that learns each agent's own callers from that agent's finished calls. It is in beta.
7
+ 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
+ While the
11
+ caller speaks, it reads your speech-to-text's words and, once it has learned enough of that agent's calls, guesses how
12
+ the turn will end. The plugin wraps your speech-to-text and sends that guess to LiveKit as a preflight transcript, the
13
+ same signal Deepgram Flux's eager end of turn sends. LiveKit starts the LLM on it (preemptive generation), and its own
14
+ check keeps that reply only if the turn's final words match the guess. Your speech-to-text still decides where the turn
15
+ ends.
16
+
17
+ Bell runs on Rabel's servers: there is nothing to host and no GPU. It answers in about 3 ms to an agent in the same cloud
18
+ region (Google Cloud's us-east1) and about 72 ms from the US west coast, read from one Google Cloud machine in each (the
19
+ western one in Oregon) and not yet from LiveKit Cloud or any other network. One key holds up to 50 calls at once. Tested with LiveKit Agents 1.8.13. The numbers here come from
20
+ scripted calls to one bank, in English, with Deepgram Flux as the speech-to-text; the rest is under [Limits](#limits).
21
+
22
+ **What Rabel keeps.** Bell never receives audio. It takes nothing but the words from your speech-to-text and holds a
23
+ call's words only while that call is open. When the call closes, Bell learns from them for your agent and drops them.
24
+ What it learns stays with your agent and is never filed under a call or under a caller's name or number. Part of it is
25
+ kept as codes that Rabel holds the key to, and the rest is short phrases kept in words. A phrase can be a name or a
26
+ number your callers say. You can list your agent's phrases at any time and delete any of them. Deleting an agent erases
27
+ what Bell learned for it. Rabel's notice says it in full: [rabellabs.com/api-privacy](https://rabellabs.com/api-privacy).
28
+
29
+ Rabel Labs is not affiliated with, endorsed by or sponsored by LiveKit, Pipecat (Daily) or Deepgram; they are named only
30
+ to say what the package works with.
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install livekit-plugins-rabel
36
+ ```
37
+
38
+ It needs `livekit-agents` 1.8.13 or later, before 2.0. Install your speech-to-text's plugin as you do today (for example
39
+ `livekit-plugins-deepgram`); this package does not bring one.
40
+
41
+ You need a Rabel API key, `demo-bank` included: see "Get an API key" in the [Rabel API docs](https://rabellabs.com/docs).
42
+ The price is on [Rabel's pricing page](https://rabellabs.com/pricing). Set the key in `RABEL_API_KEY`. Each speech
43
+ stream the plugin wraps (one for a call) keeps one conversation with the API open for the whole call, and the API meters
44
+ the seconds it is open, silence included.
45
+
46
+ ## Usage
47
+
48
+ Wrap the speech-to-text you already use. This is the one changed line:
49
+
50
+ ```python
51
+ from livekit.agents import AgentSession, TurnHandlingOptions
52
+ from livekit.plugins import deepgram, rabel
53
+
54
+ session = AgentSession(
55
+ stt=rabel.STT(deepgram.STTv2(model="flux-general-en", eager_eot_threshold=0.5), agent="front-desk"),
56
+ turn_handling=TurnHandlingOptions(turn_detection="stt"),
57
+ ...
58
+ )
59
+ ```
60
+
61
+ A new agent starts with nothing learned, and Bell sends no guess until it has heard enough of that agent's calls. To see
62
+ it work at once, use `agent="demo-bank"`: a ready-made agent that every account can use, already trained on a bank's
63
+ callers (the Gridspace-Stanford Harper Valley dataset of simulated bank calls, CC BY 4.0). A conversation that sounds
64
+ like a call to a bank gets guesses; talk on another topic rarely does. `demo-bank` never learns.
65
+
66
+ Any streaming speech-to-text with interim results can be wrapped. Bell goes with the speech-to-text's own early starts,
67
+ not instead of them: on turns where Bell has no guess, the events are the speech-to-text's, unchanged. Preemptive
68
+ generation is on by default in LiveKit, and Bell needs it on.
69
+
70
+ `turn_detection="stt"` is not required. Bell also works under LiveKit's own turn detection (its VAD and turn detector,
71
+ the default). There LiveKit keeps an early reply only when the final transcript is the same string as the guess, so
72
+ the plugin writes the guess the way your speech-to-text writes its finals.
73
+
74
+ Rabel's numbers were measured in a different setup from this snippet: LiveKit's own turn detector ends the turn,
75
+ preemptive generation is on and Flux's eager end of turn is off. That is
76
+ `rabel.STT(deepgram.STTv2(model="flux-general-en"), agent="front-desk")` with `turn_handling` left as it is.
77
+
78
+ ## How a guess is handled
79
+
80
+ - Bell sends at most one guess a turn, never one equal to the words it was made from, and only within `answer_timeout`
81
+ of those words, at or above `min_chance`, on the turn it answers. A turn is sent to Bell only if its first words are:
82
+ when the connection opens or reopens mid-turn, Bell starts with the next turn.
83
+ - The plugin keeps within LiveKit's default limits for preemptive generation (`max_retries` 3, `max_speech_duration`
84
+ 10 s): a guess is never the third early start of a turn and is never sent after 10 seconds of speech.
85
+ - **With Flux's eager end of turn on**, Bell sends no guess once your speech-to-text has made its own early start in the
86
+ turn, because the guess would cancel that start's reply or take a start the speech-to-text needs next. On a turn where
87
+ Bell's guess took one of LiveKit's early starts, the speech-to-text's own early start is held back when none is left
88
+ and a reply is running, because LiveKit would cancel that reply and start none.
89
+ - While Bell's guess is the running early start, the plugin holds back the interim transcripts and the speech-to-text's
90
+ own preflight that agree with it, because LiveKit would otherwise cancel the reply. Anything that disagrees is passed
91
+ and cancels the wrong reply. The final words still decide whether the reply is kept.
92
+ - While LiveKit's own early reply made on a final transcript waits for LiveKit's end of turn, the plugin holds Bell's
93
+ guess, which would replace that reply, and never sends it later. The plugin sees LiveKit's end of turn through the
94
+ session's `stt_context_options` `forward_chat_context`, on by default. With it off, the plugin holds every guess that
95
+ comes after LiveKit's own early start on a final.
96
+
97
+ These rules make it rare for a guess to start a reply later than it would have started without Bell. Rare is not never.
98
+
99
+ ## Options
100
+
101
+ | Option | Default | |
102
+ |---|---|---|
103
+ | `agent` | `"default"` | Your agent's name: 1 to 64 lower-case letters, digits, `-` or `_`. Each agent learns from its own calls, and calls that share a name share what Bell learns: give each voice agent you run its own name and keep all of its calls under it. What Bell learns for it belongs to your account, so a new key keeps it. `"demo-bank"` is read-only. |
104
+ | `min_chance` | `0.7` | How sure Bell must be before it guesses, from `0.67` to `0.99`. Higher sends fewer guesses, and fewer wrong ones. A value outside is clamped and one line is logged. |
105
+ | `answer_timeout` | `0.5` | Seconds after its words within which a guess is still used. |
106
+ | `learn` | `True` | `False` means the calls through this wrapper teach Bell nothing. |
107
+ | `user` | `None` | An id you choose for the person on the call: 1 to 128 letters, digits, `.`, `_`, `:` or `-`. Bell does not use it yet. Never a name, a number or an address. |
108
+ | `report` | `True` | Tells the API at each turn's end whether the guess was kept or dropped, with the head start of a kept one and no words, so your agent's status can show them. |
109
+ | `enabled` | `True` | `False` makes the wrapper a plain pass-through. |
110
+ | `api_key` | `RABEL_API_KEY` | Your Rabel API key. |
111
+ | `base_url` | `RABEL_API_URL`, else `https://api.rabellabs.com` | The API's address. |
112
+ | `http_session` | the job's own, else a new one | An `aiohttp.ClientSession` for the API's WebSocket. |
113
+
114
+ All but the last three can be changed with `update_options()`. `answer_timeout` and `report` take effect at once and
115
+ the others from the next speech stream. `user=None` stops sending the id. An `agent`, `user`, `learn` or `report` not
116
+ of the form above, a `min_chance` that is not a number or an `answer_timeout` not over 0 raises `ValueError`. Bell is
117
+ sent the caller's words only, never the agent's lines.
118
+
119
+ ## Seeing Bell work
120
+
121
+ Set the `livekit.plugins.rabel` logger to `DEBUG`. Each guess sent logs "Bell: a guess sent as an early start" with its
122
+ chance, and each guess LiveKit kept logs "Bell's guess kept" with its head start in milliseconds. At `INFO`, one line
123
+ when the stream closes gives the call's turns, guesses, kept, dropped and head start in all. No line carries a word of
124
+ the call. LiveKit's own "using preemptive generation" line does not show Bell's guess was kept: LiveKit prints it for
125
+ every early reply it keeps.
126
+
127
+ The API's `GET /v1/agents/{agent}` shows the calls Bell has heard for your agent and, with `report` on,
128
+ `guesses_kept`, `guesses_dropped`, the head start and the agent's state (`learning`, `guessing` or `quiet`). The plugin
129
+ reports your speech-to-text's model and provider as its own, so LiveKit's metrics and logs name your speech-to-text.
130
+
131
+ ## Limits
132
+
133
+ - **The numbers come from one kind of call:** scripted calls to one bank, in English, with Flux's words. On freer speech we
134
+ have only looked informally, and Bell mostly stayed quiet. No live deployment's callers and no other language have been
135
+ measured, and the numbers were not read with Flux's eager end of turn on.
136
+ - **A later reply is rare, not impossible.** On some turns a guess can still start the reply later than it would have
137
+ started without Bell.
138
+ - **Keep LiveKit's default preemptive-generation limits.** The plugin assumes them. With lower limits set in
139
+ `preemptive_generation`, a guess can take the place of an early reply that LiveKit then has no try left to replace.
140
+ - **Keep LiveKit's minimum interruption words at its default 0.** Set above 0 (`min_words` in `turn_handling`'s
141
+ interruption options, `min_interruption_words` before), LiveKit counts a guess's words as the caller's. A "yeah" while
142
+ your agent speaks can bring a guess long enough to interrupt or pause it.
143
+ - **Keep `forward_chat_context` on.** Off, Bell sends fewer guesses (above).
144
+ - **While a guess is live, your live caption shows the guess.** The user transcript LiveKit shows and sends to your
145
+ front end carries Bell's guess, not the caller's words so far, until the words move past it or the final arrives. A
146
+ front end cannot tell the two apart. Only `enabled=False` turns this off.
147
+ - **An app that commits turns itself should set `enabled=False`.** LiveKit starts no early reply on turns committed by
148
+ hand (`session.commit_user_turn()`, push-to-talk, `turn_detection="manual"`), so Bell gives it nothing. And a commit,
149
+ or the session closing, within half a second of a guess commits the guess as the caller's words.
150
+ - **It fails open.** If the API is slow, down, refuses or errors, the events are exactly your speech-to-text's, nothing
151
+ is raised into the agent, and at most one line is logged for each kind of failure. With nothing listening, or no
152
+ ready within 2 s of opening, it retries after 1, 2, 4, 8 and 16 s, then every 30 s. A 429 `key_at_once` or 529
153
+ `out_of_capacity` retries the same way, or after the API's `retry_after_s` when that is longer (at most 300 s). A 400
154
+ `bad_message`, 401 `bad_key`, 402 `no_seconds` or 404 `unknown_agent` ends Bell for that stream. Broken data from the
155
+ API is ignored. A guess that comes late, under `min_chance` or after its turn has ended is dropped. With no API key, or
156
+ `enabled=False`, no connection is opened. A conversation that closes cleanly after a minute or more (the API closes
157
+ one after an hour) is reopened at once; any other is reopened as when the API is down. The tests run each of these
158
+ cases against a local stand-in for version 1 and version 2 of Rabel's API.
@@ -0,0 +1,47 @@
1
+ # Copyright 2026 Rabel Labs
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Rabel plugin for LiveKit Agents
16
+
17
+ Bell guesses the caller's final words before the speech-to-text has them. This plugin wraps
18
+ any streaming speech-to-text and sends one guess a turn as a preflight transcript, on which
19
+ LiveKit starts the LLM early. LiveKit's own end-of-turn check keeps or drops that reply.
20
+ """
21
+
22
+ from .stt import STT, SpeechStream
23
+ from .version import __version__
24
+
25
+ __all__ = ["STT", "SpeechStream", "__version__"]
26
+
27
+
28
+ from livekit.agents import Plugin
29
+
30
+ from .log import logger
31
+
32
+
33
+ class RabelPlugin(Plugin):
34
+ def __init__(self) -> None:
35
+ super().__init__(__name__, __version__, __package__, logger)
36
+
37
+
38
+ Plugin.register_plugin(RabelPlugin())
39
+
40
+ # Cleanup docs of unexported modules
41
+ _module = dir()
42
+ NOT_IN_ALL = [m for m in _module if m not in __all__]
43
+
44
+ __pdoc__ = {}
45
+
46
+ for n in NOT_IN_ALL:
47
+ __pdoc__[n] = False