dialt-sdk 0.15.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.
- dialt_sdk-0.15.0/.gitignore +47 -0
- dialt_sdk-0.15.0/LICENSE +202 -0
- dialt_sdk-0.15.0/NOTICE +7 -0
- dialt_sdk-0.15.0/PKG-INFO +199 -0
- dialt_sdk-0.15.0/README.md +174 -0
- dialt_sdk-0.15.0/dialt/__init__.py +45 -0
- dialt_sdk-0.15.0/dialt/audio.py +51 -0
- dialt_sdk-0.15.0/dialt/evals.py +283 -0
- dialt_sdk-0.15.0/dialt/py.typed +1 -0
- dialt_sdk-0.15.0/dialt/recorder.py +89 -0
- dialt_sdk-0.15.0/dialt/relay.py +181 -0
- dialt_sdk-0.15.0/dialt/session.py +685 -0
- dialt_sdk-0.15.0/dialt/webrtc.py +296 -0
- dialt_sdk-0.15.0/pyproject.toml +39 -0
- dialt_sdk-0.15.0/tests/test_evals.py +160 -0
- dialt_sdk-0.15.0/tests/test_relay.py +205 -0
- dialt_sdk-0.15.0/tests/test_session.py +625 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
tmp/
|
|
2
|
+
.venv/
|
|
3
|
+
node_modules/
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.pyc
|
|
6
|
+
.DS_Store
|
|
7
|
+
|
|
8
|
+
eval/out/
|
|
9
|
+
eval/results/
|
|
10
|
+
|
|
11
|
+
# Third-party / regenerable eval audio (fetch via eval/runners/*.py); manifests are tracked.
|
|
12
|
+
# noise_beds/local/ is kept: locally-recorded beds (e.g. keyboard) cannot be regenerated.
|
|
13
|
+
eval/datasets/noise_beds/demand_clean/
|
|
14
|
+
eval/datasets/aec_challenge/real/
|
|
15
|
+
eval/datasets/audio_frontend/fixtures/
|
|
16
|
+
eval/fixtures/spelling_transcription/
|
|
17
|
+
# regenerable barge clips; manifests tracked.
|
|
18
|
+
eval/benchmarks/turntaking/barge_examples/*.wav
|
|
19
|
+
|
|
20
|
+
.env
|
|
21
|
+
*.env
|
|
22
|
+
!.env.example
|
|
23
|
+
.runpod_endpoint
|
|
24
|
+
eval/runners/aec_apm/target/
|
|
25
|
+
# Research tooling may write repo-root checkpoints/ when run from the root.
|
|
26
|
+
/checkpoints/
|
|
27
|
+
|
|
28
|
+
# pulled session captures (pull-sessions.sh default dest when run from repo root)
|
|
29
|
+
live_sessions/
|
|
30
|
+
# ...except the committed ingestion test fixture (eval/results is untracked, so CI needs its own copy).
|
|
31
|
+
!webapp/tests/fixtures/live_sessions/
|
|
32
|
+
!webapp/tests/fixtures/live_sessions/**
|
|
33
|
+
|
|
34
|
+
# generated listen-QA page (rebuild: uv run eval/runners/review/span_review_page.py)
|
|
35
|
+
eval/datasets/frontend_pairs/span_review.html
|
|
36
|
+
eval/datasets/frontend_pairs/backchannel_onsets.html
|
|
37
|
+
.claude/settings.local.json
|
|
38
|
+
.claude/scheduled_tasks.lock
|
|
39
|
+
eval/manifests/**/*.publication.lock
|
|
40
|
+
.claude/worktrees/
|
|
41
|
+
.codex/worktrees/
|
|
42
|
+
|
|
43
|
+
# Django admin static collection (webapp/), regenerated by collectstatic.
|
|
44
|
+
webapp/staticfiles/
|
|
45
|
+
|
|
46
|
+
# Local research scratch (LiveKit community scrape) — report ships in docs/research/.
|
|
47
|
+
research/livekit-community/
|
dialt_sdk-0.15.0/LICENSE
ADDED
|
@@ -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.
|
dialt_sdk-0.15.0/NOTICE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Dialt Python SDK
|
|
2
|
+
Copyright 2026 Dialt
|
|
3
|
+
|
|
4
|
+
Dialt-authored portions of this SDK are licensed under the Apache License, Version 2.0.
|
|
5
|
+
|
|
6
|
+
This license does not grant rights to the hosted Dialt service, its models, Dialt
|
|
7
|
+
trademarks, or server-side software. Runtime dependencies remain under their own licenses.
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: dialt-sdk
|
|
3
|
+
Version: 0.15.0
|
|
4
|
+
Summary: Python SDK for the Dialt realtime voice and text API.
|
|
5
|
+
Project-URL: Documentation, https://dialt.com/docs/api/
|
|
6
|
+
Project-URL: Homepage, https://dialt.com/
|
|
7
|
+
Author: Dialt
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
License-File: NOTICE
|
|
11
|
+
Keywords: dialt,realtime,speech,voice,voice-ai
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Requires-Dist: numpy>=1.26
|
|
21
|
+
Requires-Dist: websockets>=12.0
|
|
22
|
+
Provides-Extra: webrtc
|
|
23
|
+
Requires-Dist: aiortc>=1.15.0; extra == 'webrtc'
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# dialt-sdk
|
|
27
|
+
|
|
28
|
+
The headless Python SDK for the
|
|
29
|
+
[Dialt realtime voice API](https://dialt.com/docs/api/). Dialt manages
|
|
30
|
+
speech recognition, turn-taking, interruption handling, speech generation, reasoning and tool
|
|
31
|
+
orchestration through a single API; this SDK connects telephony bridges, services, evaluations
|
|
32
|
+
and custom devices to it.
|
|
33
|
+
|
|
34
|
+
`dialt-sdk` replaces the deprecated `converse-sdk` distribution. New code imports from `dialt`.
|
|
35
|
+
Existing applications can install the final `converse-sdk` compatibility release while migrating imports from `converse_sdk` to `dialt`.
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
uv add dialt-sdk
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The session-loop fragment below assumes your media layer supplies `mic_frame` and `play_audio`,
|
|
42
|
+
and your application supplies `run_tool`:
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
import os
|
|
46
|
+
|
|
47
|
+
from dialt import ConverseMode, ConverseSession, ToolDefinition
|
|
48
|
+
|
|
49
|
+
lookup_tool: ToolDefinition = {
|
|
50
|
+
"name": "lookup_order",
|
|
51
|
+
"description": "Look up an order by ID.",
|
|
52
|
+
"parameters": {"type": "object", "properties": {"order_id": {"type": "string"}}},
|
|
53
|
+
"read_only": True,
|
|
54
|
+
"expected_duration": "instant",
|
|
55
|
+
"status_label": "order lookup",
|
|
56
|
+
"deferred": True,
|
|
57
|
+
"deferred_timeout": 7200,
|
|
58
|
+
"notify_on_complete": True,
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
session = await ConverseSession.connect(
|
|
62
|
+
"wss://dialt.com/ws",
|
|
63
|
+
api_key=os.environ["CONVERSE_API_KEY"],
|
|
64
|
+
mode=ConverseMode(
|
|
65
|
+
instructions="Help callers with their orders.",
|
|
66
|
+
greeting="Hello, how can I help?",
|
|
67
|
+
tools=[lookup_tool],
|
|
68
|
+
),
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
async with session:
|
|
72
|
+
await session.send_audio(mic_frame) # PCM16 little-endian mono at 16 kHz
|
|
73
|
+
await session.inject_context(
|
|
74
|
+
"Claude Code finished. Tell the user briefly.", role="context", reply=True)
|
|
75
|
+
|
|
76
|
+
async for event in session.events():
|
|
77
|
+
if event.type == "audio":
|
|
78
|
+
play_audio(event.audio) # Float32 mono at 16 kHz
|
|
79
|
+
elif event.type == "tool_call":
|
|
80
|
+
result = await run_tool(event.data["name"], event.data["args"])
|
|
81
|
+
await session.send_tool_result(
|
|
82
|
+
event.data["id"], result, outcome="succeeded", verified=True)
|
|
83
|
+
elif event.type == "tool_deferred_resume":
|
|
84
|
+
resume_host_job(event.data["handle"])
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`deferred: True` makes the tool a background job: the call can outlive the voice turn, the
|
|
88
|
+
conversation carries on while the host works, and with `notify_on_complete` the agent speaks the
|
|
89
|
+
result when it lands — even if the caller has moved on to another topic. For work that should
|
|
90
|
+
release the voice turn immediately, call `send_tool_deferred(id, handle, status_label=...)` before
|
|
91
|
+
continuing it in the background. The handle identifies that call, not your worker: mint a fresh one
|
|
92
|
+
per call (e.g. `f"job-{call_id}"`) and check the returned acknowledgement — re-using a live handle
|
|
93
|
+
is rejected as `handle_in_use`, and a rejected defer leaves the call on the ordinary tool timeout,
|
|
94
|
+
so it expires while you think it is backgrounded. Keep a handle-to-worker map if several calls
|
|
95
|
+
should feed one long-running worker.
|
|
96
|
+
For proactive host announcements, call
|
|
97
|
+
`await session.inject_context(text, role="context", reply=True, message_id="job-42")`. It returns
|
|
98
|
+
the broker's authoritative acknowledgement (`accepted` plus optional `retryable`/`detail`). For a
|
|
99
|
+
typed user turn, the same `message_id` and `input_source="text"` appear on the final ASR event;
|
|
100
|
+
spoken input uses `input_source="voice"`. The role defaults to `"context"`, `reply` defaults to
|
|
101
|
+
`False`, and omitted message IDs are generated by the SDK. Text is limited to 1–2000 characters.
|
|
102
|
+
An accepted `message_id` is an idempotency key for the logical session. After an acknowledgement
|
|
103
|
+
loss, retry the identical payload and ID (including after resume) to replay delivery proof without
|
|
104
|
+
injecting a duplicate turn. Reusing an accepted ID with different content is rejected; the broker
|
|
105
|
+
retains up to 512 accepted receipts per logical session.
|
|
106
|
+
|
|
107
|
+
Save `session.resume_token` from the connected session; after a transport loss, pass it as
|
|
108
|
+
`resume_token=...` to the replacement `ConverseSession.connect(...)` call so pending jobs are
|
|
109
|
+
re-announced as `tool_deferred_resume` events within the broker's bounded resume window.
|
|
110
|
+
|
|
111
|
+
The SDK deliberately does not own capture, playback, pacing or echo cancellation. Live playback
|
|
112
|
+
integrations must implement the
|
|
113
|
+
[playback contract](https://dialt.com/docs/api/websocket/#playback-contract).
|
|
114
|
+
|
|
115
|
+
For a text session, keep the same conversation configuration and replace the media loop with
|
|
116
|
+
committed turns:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
async with await ConverseSession.connect(
|
|
120
|
+
"wss://dialt.com/ws",
|
|
121
|
+
api_key=os.environ["CONVERSE_API_KEY"],
|
|
122
|
+
mode=ConverseMode(modality="text", instructions="Help customers with their orders."),
|
|
123
|
+
) as session:
|
|
124
|
+
await session.send_text("Where is order A123?")
|
|
125
|
+
async for event in session.events():
|
|
126
|
+
if event.type == "utterance":
|
|
127
|
+
print(event.data["text"])
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Text mode is WebSocket-only and emits no audio. Model behavior, tools, greeting, history and
|
|
131
|
+
conversation lifecycle events remain the same.
|
|
132
|
+
|
|
133
|
+
`ConverseMode(end_call=True)` lets the agent end the session itself through the managed
|
|
134
|
+
`end_call(farewell)` tool: the farewell is spoken, `session_end_requested` arrives with the
|
|
135
|
+
`farewell`, and the server closes after a short grace unless the user speaks. Off by default; the
|
|
136
|
+
host then ends the session with `wrap_up` or by closing.
|
|
137
|
+
|
|
138
|
+
See the [complete Python reference](https://dialt.com/docs/api/python/#python-sdk)
|
|
139
|
+
and the [Twilio bridge quickstart](https://dialt.com/docs/api/twilio/).
|
|
140
|
+
|
|
141
|
+
### Hosted evals
|
|
142
|
+
|
|
143
|
+
`dialt.evals` creates cases and starts runs on the Dialt evals dashboard with your
|
|
144
|
+
account API key (`ck_...`). Cases are JSON files in your repository; `upsert_case` keeps the
|
|
145
|
+
hosted copy in step by name, so a re-push updates rather than duplicates.
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
from dialt import EvalsClient, load_cases
|
|
149
|
+
|
|
150
|
+
evals = EvalsClient(api_key=os.environ["CONVERSE_API_KEY"])
|
|
151
|
+
cases = evals.upsert_cases(load_cases("evals/")) # one case per *.json file
|
|
152
|
+
run = evals.start_run([c["id"] for c in cases], modality="text")
|
|
153
|
+
print(evals.dashboard_url(run["id"]))
|
|
154
|
+
result = evals.wait(run["id"]) # polls until terminal
|
|
155
|
+
print(result["status"], [a["status"] for a in result["attempts"]])
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
A case has `name`, `starter`, `target` (`instructions`, optional `tools`), `simulator`
|
|
159
|
+
(`instructions`), `fixtures`, `checks` and `limits`; the field reference is in the evals guide.
|
|
160
|
+
`converse-recipes` ships a `converse-evals push evals/` command built on this client.
|
|
161
|
+
|
|
162
|
+
### Relaying two sessions (simulations)
|
|
163
|
+
|
|
164
|
+
`dialt.relay` cross-pipes two sessions so one can play the user for the other: the
|
|
165
|
+
building blocks behind `converse-recipes`' `converse-sim` and the hosted evals in the Dialt
|
|
166
|
+
webapp.
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
from dialt.relay import TextTurnRelay, VoiceTurnRelay
|
|
170
|
+
|
|
171
|
+
# text: forward each committed target utterance to the simulator once tool work has settled
|
|
172
|
+
relay = TextTurnRelay(simulator.send_text)
|
|
173
|
+
relay.utterance(event.data["text"]) # on the target's `utterance`
|
|
174
|
+
relay.working(active) # on `working`
|
|
175
|
+
relay.done() # on `done`: forwards after TURN_RELAY_SETTLE_S
|
|
176
|
+
|
|
177
|
+
# voice: stream the target's audio straight into the simulator's mic, then close the turn
|
|
178
|
+
relay = VoiceTurnRelay(simulator)
|
|
179
|
+
await relay.audio(event.audio) # on each `audio` event
|
|
180
|
+
relay.input_committed() # on the simulator's `asr`: stops the silence tail early
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`VoiceTurnRelay.done()` feeds up to `voice_tail_s()` of silence so the receiving side's
|
|
184
|
+
endpointer commits the turn (bounded by `CARTESIA_TURN_END_TIMEOUT_MS` when set, else Ink's
|
|
185
|
+
5.6 s default). Both relays take `on_error` to surface background failures.
|
|
186
|
+
|
|
187
|
+
### WebRTC transport (experimental)
|
|
188
|
+
|
|
189
|
+
Experimental: the API is stable, but this transport is newly shipped and still being hardened on
|
|
190
|
+
real networks; `ws` remains the default and recommended fallback.
|
|
191
|
+
|
|
192
|
+
Pass `transport="webrtc"` to `ConverseSession.connect(...)` to carry the session over WebRTC (UDP)
|
|
193
|
+
instead of the default WebSocket. Requires `pip install "dialt-sdk[webrtc]"` (or `uv add`).
|
|
194
|
+
`ws` remains the default; most headless callers are fine on it. See the
|
|
195
|
+
[Python guide's WebRTC section](https://dialt.com/docs/api/python/#python-webrtc).
|
|
196
|
+
|
|
197
|
+
Licensed under the [Apache License 2.0](LICENSE). This license applies to the SDK, not to the
|
|
198
|
+
hosted Dialt service, its models, or its server-side implementation. Runtime dependencies
|
|
199
|
+
remain under their own licenses.
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# dialt-sdk
|
|
2
|
+
|
|
3
|
+
The headless Python SDK for the
|
|
4
|
+
[Dialt realtime voice API](https://dialt.com/docs/api/). Dialt manages
|
|
5
|
+
speech recognition, turn-taking, interruption handling, speech generation, reasoning and tool
|
|
6
|
+
orchestration through a single API; this SDK connects telephony bridges, services, evaluations
|
|
7
|
+
and custom devices to it.
|
|
8
|
+
|
|
9
|
+
`dialt-sdk` replaces the deprecated `converse-sdk` distribution. New code imports from `dialt`.
|
|
10
|
+
Existing applications can install the final `converse-sdk` compatibility release while migrating imports from `converse_sdk` to `dialt`.
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
uv add dialt-sdk
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The session-loop fragment below assumes your media layer supplies `mic_frame` and `play_audio`,
|
|
17
|
+
and your application supplies `run_tool`:
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
import os
|
|
21
|
+
|
|
22
|
+
from dialt import ConverseMode, ConverseSession, ToolDefinition
|
|
23
|
+
|
|
24
|
+
lookup_tool: ToolDefinition = {
|
|
25
|
+
"name": "lookup_order",
|
|
26
|
+
"description": "Look up an order by ID.",
|
|
27
|
+
"parameters": {"type": "object", "properties": {"order_id": {"type": "string"}}},
|
|
28
|
+
"read_only": True,
|
|
29
|
+
"expected_duration": "instant",
|
|
30
|
+
"status_label": "order lookup",
|
|
31
|
+
"deferred": True,
|
|
32
|
+
"deferred_timeout": 7200,
|
|
33
|
+
"notify_on_complete": True,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
session = await ConverseSession.connect(
|
|
37
|
+
"wss://dialt.com/ws",
|
|
38
|
+
api_key=os.environ["CONVERSE_API_KEY"],
|
|
39
|
+
mode=ConverseMode(
|
|
40
|
+
instructions="Help callers with their orders.",
|
|
41
|
+
greeting="Hello, how can I help?",
|
|
42
|
+
tools=[lookup_tool],
|
|
43
|
+
),
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
async with session:
|
|
47
|
+
await session.send_audio(mic_frame) # PCM16 little-endian mono at 16 kHz
|
|
48
|
+
await session.inject_context(
|
|
49
|
+
"Claude Code finished. Tell the user briefly.", role="context", reply=True)
|
|
50
|
+
|
|
51
|
+
async for event in session.events():
|
|
52
|
+
if event.type == "audio":
|
|
53
|
+
play_audio(event.audio) # Float32 mono at 16 kHz
|
|
54
|
+
elif event.type == "tool_call":
|
|
55
|
+
result = await run_tool(event.data["name"], event.data["args"])
|
|
56
|
+
await session.send_tool_result(
|
|
57
|
+
event.data["id"], result, outcome="succeeded", verified=True)
|
|
58
|
+
elif event.type == "tool_deferred_resume":
|
|
59
|
+
resume_host_job(event.data["handle"])
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`deferred: True` makes the tool a background job: the call can outlive the voice turn, the
|
|
63
|
+
conversation carries on while the host works, and with `notify_on_complete` the agent speaks the
|
|
64
|
+
result when it lands — even if the caller has moved on to another topic. For work that should
|
|
65
|
+
release the voice turn immediately, call `send_tool_deferred(id, handle, status_label=...)` before
|
|
66
|
+
continuing it in the background. The handle identifies that call, not your worker: mint a fresh one
|
|
67
|
+
per call (e.g. `f"job-{call_id}"`) and check the returned acknowledgement — re-using a live handle
|
|
68
|
+
is rejected as `handle_in_use`, and a rejected defer leaves the call on the ordinary tool timeout,
|
|
69
|
+
so it expires while you think it is backgrounded. Keep a handle-to-worker map if several calls
|
|
70
|
+
should feed one long-running worker.
|
|
71
|
+
For proactive host announcements, call
|
|
72
|
+
`await session.inject_context(text, role="context", reply=True, message_id="job-42")`. It returns
|
|
73
|
+
the broker's authoritative acknowledgement (`accepted` plus optional `retryable`/`detail`). For a
|
|
74
|
+
typed user turn, the same `message_id` and `input_source="text"` appear on the final ASR event;
|
|
75
|
+
spoken input uses `input_source="voice"`. The role defaults to `"context"`, `reply` defaults to
|
|
76
|
+
`False`, and omitted message IDs are generated by the SDK. Text is limited to 1–2000 characters.
|
|
77
|
+
An accepted `message_id` is an idempotency key for the logical session. After an acknowledgement
|
|
78
|
+
loss, retry the identical payload and ID (including after resume) to replay delivery proof without
|
|
79
|
+
injecting a duplicate turn. Reusing an accepted ID with different content is rejected; the broker
|
|
80
|
+
retains up to 512 accepted receipts per logical session.
|
|
81
|
+
|
|
82
|
+
Save `session.resume_token` from the connected session; after a transport loss, pass it as
|
|
83
|
+
`resume_token=...` to the replacement `ConverseSession.connect(...)` call so pending jobs are
|
|
84
|
+
re-announced as `tool_deferred_resume` events within the broker's bounded resume window.
|
|
85
|
+
|
|
86
|
+
The SDK deliberately does not own capture, playback, pacing or echo cancellation. Live playback
|
|
87
|
+
integrations must implement the
|
|
88
|
+
[playback contract](https://dialt.com/docs/api/websocket/#playback-contract).
|
|
89
|
+
|
|
90
|
+
For a text session, keep the same conversation configuration and replace the media loop with
|
|
91
|
+
committed turns:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
async with await ConverseSession.connect(
|
|
95
|
+
"wss://dialt.com/ws",
|
|
96
|
+
api_key=os.environ["CONVERSE_API_KEY"],
|
|
97
|
+
mode=ConverseMode(modality="text", instructions="Help customers with their orders."),
|
|
98
|
+
) as session:
|
|
99
|
+
await session.send_text("Where is order A123?")
|
|
100
|
+
async for event in session.events():
|
|
101
|
+
if event.type == "utterance":
|
|
102
|
+
print(event.data["text"])
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Text mode is WebSocket-only and emits no audio. Model behavior, tools, greeting, history and
|
|
106
|
+
conversation lifecycle events remain the same.
|
|
107
|
+
|
|
108
|
+
`ConverseMode(end_call=True)` lets the agent end the session itself through the managed
|
|
109
|
+
`end_call(farewell)` tool: the farewell is spoken, `session_end_requested` arrives with the
|
|
110
|
+
`farewell`, and the server closes after a short grace unless the user speaks. Off by default; the
|
|
111
|
+
host then ends the session with `wrap_up` or by closing.
|
|
112
|
+
|
|
113
|
+
See the [complete Python reference](https://dialt.com/docs/api/python/#python-sdk)
|
|
114
|
+
and the [Twilio bridge quickstart](https://dialt.com/docs/api/twilio/).
|
|
115
|
+
|
|
116
|
+
### Hosted evals
|
|
117
|
+
|
|
118
|
+
`dialt.evals` creates cases and starts runs on the Dialt evals dashboard with your
|
|
119
|
+
account API key (`ck_...`). Cases are JSON files in your repository; `upsert_case` keeps the
|
|
120
|
+
hosted copy in step by name, so a re-push updates rather than duplicates.
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from dialt import EvalsClient, load_cases
|
|
124
|
+
|
|
125
|
+
evals = EvalsClient(api_key=os.environ["CONVERSE_API_KEY"])
|
|
126
|
+
cases = evals.upsert_cases(load_cases("evals/")) # one case per *.json file
|
|
127
|
+
run = evals.start_run([c["id"] for c in cases], modality="text")
|
|
128
|
+
print(evals.dashboard_url(run["id"]))
|
|
129
|
+
result = evals.wait(run["id"]) # polls until terminal
|
|
130
|
+
print(result["status"], [a["status"] for a in result["attempts"]])
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
A case has `name`, `starter`, `target` (`instructions`, optional `tools`), `simulator`
|
|
134
|
+
(`instructions`), `fixtures`, `checks` and `limits`; the field reference is in the evals guide.
|
|
135
|
+
`converse-recipes` ships a `converse-evals push evals/` command built on this client.
|
|
136
|
+
|
|
137
|
+
### Relaying two sessions (simulations)
|
|
138
|
+
|
|
139
|
+
`dialt.relay` cross-pipes two sessions so one can play the user for the other: the
|
|
140
|
+
building blocks behind `converse-recipes`' `converse-sim` and the hosted evals in the Dialt
|
|
141
|
+
webapp.
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
from dialt.relay import TextTurnRelay, VoiceTurnRelay
|
|
145
|
+
|
|
146
|
+
# text: forward each committed target utterance to the simulator once tool work has settled
|
|
147
|
+
relay = TextTurnRelay(simulator.send_text)
|
|
148
|
+
relay.utterance(event.data["text"]) # on the target's `utterance`
|
|
149
|
+
relay.working(active) # on `working`
|
|
150
|
+
relay.done() # on `done`: forwards after TURN_RELAY_SETTLE_S
|
|
151
|
+
|
|
152
|
+
# voice: stream the target's audio straight into the simulator's mic, then close the turn
|
|
153
|
+
relay = VoiceTurnRelay(simulator)
|
|
154
|
+
await relay.audio(event.audio) # on each `audio` event
|
|
155
|
+
relay.input_committed() # on the simulator's `asr`: stops the silence tail early
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
`VoiceTurnRelay.done()` feeds up to `voice_tail_s()` of silence so the receiving side's
|
|
159
|
+
endpointer commits the turn (bounded by `CARTESIA_TURN_END_TIMEOUT_MS` when set, else Ink's
|
|
160
|
+
5.6 s default). Both relays take `on_error` to surface background failures.
|
|
161
|
+
|
|
162
|
+
### WebRTC transport (experimental)
|
|
163
|
+
|
|
164
|
+
Experimental: the API is stable, but this transport is newly shipped and still being hardened on
|
|
165
|
+
real networks; `ws` remains the default and recommended fallback.
|
|
166
|
+
|
|
167
|
+
Pass `transport="webrtc"` to `ConverseSession.connect(...)` to carry the session over WebRTC (UDP)
|
|
168
|
+
instead of the default WebSocket. Requires `pip install "dialt-sdk[webrtc]"` (or `uv add`).
|
|
169
|
+
`ws` remains the default; most headless callers are fine on it. See the
|
|
170
|
+
[Python guide's WebRTC section](https://dialt.com/docs/api/python/#python-webrtc).
|
|
171
|
+
|
|
172
|
+
Licensed under the [Apache License 2.0](LICENSE). This license applies to the SDK, not to the
|
|
173
|
+
hosted Dialt service, its models, or its server-side implementation. Runtime dependencies
|
|
174
|
+
remain under their own licenses.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from .audio import (
|
|
2
|
+
chunk_audio,
|
|
3
|
+
f32le_to_float32,
|
|
4
|
+
float32_to_pcm16,
|
|
5
|
+
pcm16_to_float32,
|
|
6
|
+
to_ws_url,
|
|
7
|
+
)
|
|
8
|
+
from .evals import EvalsClient, EvalsError, load_cases, validate_case
|
|
9
|
+
from .recorder import TurnRecorder
|
|
10
|
+
from .relay import TextTurnRelay, VoiceTurnRelay
|
|
11
|
+
from .session import (
|
|
12
|
+
DEFAULT_CHUNK_MS,
|
|
13
|
+
DEFAULT_SR,
|
|
14
|
+
OUTPUT_SR,
|
|
15
|
+
ConverseError,
|
|
16
|
+
ConverseMode,
|
|
17
|
+
SessionMode,
|
|
18
|
+
ConverseSession,
|
|
19
|
+
SessionEvent,
|
|
20
|
+
ToolDefinition,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"ConverseError",
|
|
25
|
+
"ConverseMode",
|
|
26
|
+
"SessionMode",
|
|
27
|
+
"ConverseSession",
|
|
28
|
+
"EvalsClient",
|
|
29
|
+
"EvalsError",
|
|
30
|
+
"load_cases",
|
|
31
|
+
"validate_case",
|
|
32
|
+
"SessionEvent",
|
|
33
|
+
"ToolDefinition",
|
|
34
|
+
"TurnRecorder",
|
|
35
|
+
"TextTurnRelay",
|
|
36
|
+
"VoiceTurnRelay",
|
|
37
|
+
"DEFAULT_CHUNK_MS",
|
|
38
|
+
"DEFAULT_SR",
|
|
39
|
+
"OUTPUT_SR",
|
|
40
|
+
"chunk_audio",
|
|
41
|
+
"f32le_to_float32",
|
|
42
|
+
"float32_to_pcm16",
|
|
43
|
+
"pcm16_to_float32",
|
|
44
|
+
"to_ws_url",
|
|
45
|
+
]
|