tazo-sdk 0.1.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.
- tazo_sdk-0.1.0/.gitignore +37 -0
- tazo_sdk-0.1.0/CHANGELOG.md +10 -0
- tazo_sdk-0.1.0/LICENSE +177 -0
- tazo_sdk-0.1.0/PKG-INFO +239 -0
- tazo_sdk-0.1.0/README.md +221 -0
- tazo_sdk-0.1.0/RELEASING.md +121 -0
- tazo_sdk-0.1.0/docs/source/clients.rst +11 -0
- tazo_sdk-0.1.0/docs/source/conf.py +24 -0
- tazo_sdk-0.1.0/docs/source/errors.rst +6 -0
- tazo_sdk-0.1.0/docs/source/index.rst +15 -0
- tazo_sdk-0.1.0/docs/source/resources.rst +5 -0
- tazo_sdk-0.1.0/docs/source/streaming.rst +6 -0
- tazo_sdk-0.1.0/docs/source/types.rst +10 -0
- tazo_sdk-0.1.0/examples/smoke.py +97 -0
- tazo_sdk-0.1.0/examples/stream.py +50 -0
- tazo_sdk-0.1.0/examples/upload.py +38 -0
- tazo_sdk-0.1.0/pyproject.toml +53 -0
- tazo_sdk-0.1.0/src/tazo/__init__.py +45 -0
- tazo_sdk-0.1.0/src/tazo/_audio.py +87 -0
- tazo_sdk-0.1.0/src/tazo/_http.py +327 -0
- tazo_sdk-0.1.0/src/tazo/_version.py +1 -0
- tazo_sdk-0.1.0/src/tazo/client.py +99 -0
- tazo_sdk-0.1.0/src/tazo/errors.py +84 -0
- tazo_sdk-0.1.0/src/tazo/py.typed +0 -0
- tazo_sdk-0.1.0/src/tazo/resources.py +266 -0
- tazo_sdk-0.1.0/src/tazo/streaming.py +459 -0
- tazo_sdk-0.1.0/src/tazo/types.py +262 -0
- tazo_sdk-0.1.0/tests/conftest.py +144 -0
- tazo_sdk-0.1.0/tests/test_documentation.py +164 -0
- tazo_sdk-0.1.0/tests/test_http.py +341 -0
- tazo_sdk-0.1.0/tests/test_public_contract.py +89 -0
- tazo_sdk-0.1.0/tests/test_sdk_streaming.py +267 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Python bytecode and caches
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
.pytest_cache/
|
|
5
|
+
.mypy_cache/
|
|
6
|
+
.ruff_cache/
|
|
7
|
+
|
|
8
|
+
# Virtual environments
|
|
9
|
+
.venv/
|
|
10
|
+
venv/
|
|
11
|
+
|
|
12
|
+
# Test and coverage output
|
|
13
|
+
.coverage
|
|
14
|
+
.coverage.*
|
|
15
|
+
htmlcov/
|
|
16
|
+
|
|
17
|
+
# Local configuration and secrets
|
|
18
|
+
.env
|
|
19
|
+
.env.*
|
|
20
|
+
!.env.example
|
|
21
|
+
|
|
22
|
+
# Build artifacts
|
|
23
|
+
build/
|
|
24
|
+
dist/
|
|
25
|
+
*.egg-info/
|
|
26
|
+
|
|
27
|
+
# Editor and operating system files
|
|
28
|
+
.idea/
|
|
29
|
+
.vscode/
|
|
30
|
+
.DS_Store
|
|
31
|
+
|
|
32
|
+
# Local sample input
|
|
33
|
+
/request.wav
|
|
34
|
+
|
|
35
|
+
# Local load-test reports and credentials
|
|
36
|
+
/load_tests/reports/
|
|
37
|
+
/load_tests/tokens*.json
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 — unreleased
|
|
4
|
+
|
|
5
|
+
- Typed sync and async clients for decisions, streaming, models, and health.
|
|
6
|
+
- Replayable uploads with per-operation idempotency and bounded retries.
|
|
7
|
+
- Typed WebSocket events, explicit turn lifecycle, and PCM16 WAV chunks.
|
|
8
|
+
- Public-only Mintlify guides, tested endpoint samples, and Sphinx reference.
|
|
9
|
+
|
|
10
|
+
Supports Tazo API v1. No internal endpoints are part of the SDK.
|
tazo_sdk-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
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
|
tazo_sdk-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tazo-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The Python SDK for Tazo audio decisions.
|
|
5
|
+
Project-URL: Homepage, https://tazolabs.com
|
|
6
|
+
Project-URL: Documentation, https://docs.tazolabs.com/sdk/python/overview
|
|
7
|
+
Author: Tazo Labs
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Typing :: Typed
|
|
13
|
+
Requires-Python: >=3.11
|
|
14
|
+
Requires-Dist: httpx<1,>=0.27
|
|
15
|
+
Requires-Dist: pydantic<3,>=2.10
|
|
16
|
+
Requires-Dist: websockets<18,>=15
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# Tazo Python SDK
|
|
20
|
+
|
|
21
|
+
Typed, synchronous and asynchronous clients for Tazo audio decisions.
|
|
22
|
+
Supports exactly four public operations: uploaded decisions, streaming decisions,
|
|
23
|
+
model discovery, and health. API-key management and internal APIs are outside this package.
|
|
24
|
+
|
|
25
|
+
**Release status:** This repository's 0.1.0 release has not been published to PyPI. `tazo-sdk` is the proposed PyPI name; verify ownership
|
|
26
|
+
before publishing. Until then, install from source.
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
Python 3.11 or newer is required. From the repository root:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
python -m pip install ./packages/tazo-sdk
|
|
34
|
+
export TAZO_API_KEY='your-key'
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
After publication, use `python -m pip install tazo-sdk`.
|
|
38
|
+
Create a key in the [console](https://app.tazolabs.com); the SDK never manages keys.
|
|
39
|
+
|
|
40
|
+
## Uploaded decision
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from pathlib import Path
|
|
44
|
+
from tazo import Tazo
|
|
45
|
+
|
|
46
|
+
questions = {
|
|
47
|
+
"action": {
|
|
48
|
+
"type": "choice",
|
|
49
|
+
"instructions": "Which action should be taken?",
|
|
50
|
+
"criteria": {
|
|
51
|
+
"get_weather": "Get weather for a city.",
|
|
52
|
+
"NO_TOOL": "No tool is needed.",
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
with Tazo() as client:
|
|
58
|
+
result = client.decisions.create(
|
|
59
|
+
audio=Path("request.wav"),
|
|
60
|
+
state="Choose the action matching the spoken request.",
|
|
61
|
+
questions=questions,
|
|
62
|
+
)
|
|
63
|
+
print(result.answers["action"])
|
|
64
|
+
print(result.request_id, result.idempotency_key)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`model` defaults to `tazo-large`. Choice and noul dictionaries or the optional
|
|
68
|
+
`ChoiceQuestion` / `NoulQuestion` models are accepted. Check `models.list()` for
|
|
69
|
+
model-specific capabilities. Score questions aren't supported by this SDK release.
|
|
70
|
+
|
|
71
|
+
Audio can be a path, bytes, or a binary stream. For bytes, pass `filename` and
|
|
72
|
+
`content_type` when known. Uploads are snapshotted once, up to 16 MiB, so retries
|
|
73
|
+
use the same bytes and MIME type. Caller-provided streams aren't closed;
|
|
74
|
+
seekable streams are restored to their initial position. Nonseekable streams are
|
|
75
|
+
consumed once. No prompt word limit is imposed by the SDK.
|
|
76
|
+
|
|
77
|
+
## Models and health
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from tazo import Tazo
|
|
81
|
+
|
|
82
|
+
with Tazo() as client:
|
|
83
|
+
print(client.health.check().status) # ok or unavailable; no auth sent
|
|
84
|
+
for model in client.models.list().models:
|
|
85
|
+
print(model.id, model.ready, model.capabilities.question_types)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Credentials are required only for protected calls. HTTP 503 with the documented
|
|
89
|
+
unavailable health body returns `HealthStatus(status="unavailable")`.
|
|
90
|
+
|
|
91
|
+
## Async
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
import asyncio
|
|
95
|
+
from tazo import AsyncTazo
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
async def main():
|
|
99
|
+
async with AsyncTazo() as client:
|
|
100
|
+
print((await client.models.list()).models)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
asyncio.run(main())
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Await `decisions.create`, `models.list`, and `health.check`. Async streaming is an
|
|
107
|
+
async context manager, not an awaitable factory.
|
|
108
|
+
|
|
109
|
+
## Streaming
|
|
110
|
+
|
|
111
|
+
Both clients expose `decisions.stream(state=..., questions=...)`. Entering the
|
|
112
|
+
context authenticates in `session.start` and waits for `session.ready`. Inspect
|
|
113
|
+
`session.ready` for limits. Send raw mono 16 kHz PCM16 little-endian bytes, at most
|
|
114
|
+
`max_audio_message_bytes` per message. The `wav_chunks` helper strips WAV headers
|
|
115
|
+
and validates the format; it does not resample or pace audio.
|
|
116
|
+
|
|
117
|
+
Send audio in one task while another consumes events:
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
import asyncio
|
|
121
|
+
from tazo import AsyncTazo, wav_chunks
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
async def stream_recording(questions):
|
|
125
|
+
async with AsyncTazo() as client:
|
|
126
|
+
async with client.decisions.stream(
|
|
127
|
+
state="Choose an action.", questions=questions, audio_scope="turn"
|
|
128
|
+
) as session:
|
|
129
|
+
|
|
130
|
+
async def send():
|
|
131
|
+
for chunk in wav_chunks("request.wav"):
|
|
132
|
+
await asyncio.sleep(len(chunk) / 32000) # microphone pacing
|
|
133
|
+
await session.send_audio(chunk)
|
|
134
|
+
await session.commit()
|
|
135
|
+
|
|
136
|
+
async def receive():
|
|
137
|
+
async for event in session:
|
|
138
|
+
if event.type in {"decision.updated", "decision.finalized"}:
|
|
139
|
+
print(event.model_dump())
|
|
140
|
+
if event.type == "decision.finalized":
|
|
141
|
+
await session.finish()
|
|
142
|
+
|
|
143
|
+
async with asyncio.TaskGroup() as group:
|
|
144
|
+
group.create_task(send())
|
|
145
|
+
group.create_task(receive())
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
The executable `examples/stream.py` also propagates producer failures immediately.
|
|
149
|
+
For synchronous streaming, use a sender thread and iterate the session in the
|
|
150
|
+
receiving thread. Never receive concurrently from multiple tasks or threads.
|
|
151
|
+
|
|
152
|
+
`commit()` sends a control message; consume `decision.finalized` before another
|
|
153
|
+
turn. `update(state=..., questions=...)` is allowed between turns; consume
|
|
154
|
+
`session.updated` before audio. `finish()` requests finalization and closure;
|
|
155
|
+
continue iterating through `session.closed`. Context exit closes immediately.
|
|
156
|
+
Fatal server errors raise `StreamingError`; recoverable errors are `ErrorEvent`s.
|
|
157
|
+
Future event types become `UnknownEvent`, preserving their fields.
|
|
158
|
+
|
|
159
|
+
Default `audio_scope="turn"` evaluates cumulative audio. `chunk` evaluates only
|
|
160
|
+
new audio; its final result covers the last window, not the whole turn. Each
|
|
161
|
+
evaluation counts against the account's per-model limits. Long recordings must
|
|
162
|
+
be divided into turns within the server's advertised duration. There is no
|
|
163
|
+
automatic reconnect, audio replay, silence detection, or microphone dependency.
|
|
164
|
+
|
|
165
|
+
## Retries and errors
|
|
166
|
+
|
|
167
|
+
Each `decisions.create()` call generates a UUID operation key, unless you supply
|
|
168
|
+
`idempotency_key`. All automatic attempts reuse the key, JSON, and audio. A new
|
|
169
|
+
method call creates a new operation unless you explicitly reuse a retained key.
|
|
170
|
+
Use a caller-generated key if you need recovery across process crashes or async
|
|
171
|
+
cancellation. Accepted durable work can continue after a disconnect.
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
from pathlib import Path
|
|
175
|
+
from uuid import uuid4
|
|
176
|
+
from tazo import DecisionPendingError, Tazo
|
|
177
|
+
|
|
178
|
+
key = str(uuid4()) # persist alongside your original request before submission
|
|
179
|
+
with Tazo() as client:
|
|
180
|
+
try:
|
|
181
|
+
result = client.decisions.create(
|
|
182
|
+
audio=Path("request.wav"),
|
|
183
|
+
state="Choose an action.",
|
|
184
|
+
questions=questions,
|
|
185
|
+
idempotency_key=key,
|
|
186
|
+
)
|
|
187
|
+
except DecisionPendingError as error:
|
|
188
|
+
print(error.request_id, error.idempotency_key)
|
|
189
|
+
# Later: call create with this key and the exact same input and MIME type.
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Default `max_retries=2` means at most three attempts. Retryable service/network
|
|
193
|
+
errors use bounded exponential backoff with jitter and respect `Retry-After`.
|
|
194
|
+
Authentication, invalid input, conflicts, and oversized uploads are not retried.
|
|
195
|
+
`decision_pending` may be retried with the retained key. There is no job-status
|
|
196
|
+
endpoint. Recovery requires calling create again with the original input.
|
|
197
|
+
|
|
198
|
+
Exceptions expose `status_code`, `code`, `request_id`, `idempotency_key`,
|
|
199
|
+
`retryable`, and `retry_after` where available. Invalid server responses raise
|
|
200
|
+
`ProtocolError`. HTTP errors without JSON receive a safe generic message.
|
|
201
|
+
The SDK does not log request content, credentials, or audio. Don't enable wire
|
|
202
|
+
debug logging in applications that must keep these private.
|
|
203
|
+
|
|
204
|
+
## Configuration and lifecycle
|
|
205
|
+
|
|
206
|
+
Defaults: `base_url="https://api.tazolabs.com"`, connect timeout 5 seconds,
|
|
207
|
+
read timeout 65 seconds, write timeout 30 seconds, pool timeout 5 seconds, and
|
|
208
|
+
`operation_timeout=180` seconds. Set a float or an `httpx.Timeout` for `timeout`.
|
|
209
|
+
|
|
210
|
+
The operation timeout bounds the HTTP retry budget and caps each network phase
|
|
211
|
+
by the remaining time. Sync calls cannot forcibly interrupt a response that keeps
|
|
212
|
+
delivering chunks or spans multiple phases; async HTTP additionally enforces a
|
|
213
|
+
hard per-attempt deadline within the remaining budget. Upload snapshotting is
|
|
214
|
+
before this budget. Streaming has its own `event_timeout` (default 65 seconds),
|
|
215
|
+
5-second connection timeout, and 2-second close timeout. All are seconds.
|
|
216
|
+
|
|
217
|
+
Custom `base_url` supports local HTTP and path-prefixed proxies; omit `/v1`.
|
|
218
|
+
Use `max_retries=0` with direct-inference development servers that don't persist
|
|
219
|
+
idempotency keys. Safe replay requires a target honoring durable idempotency.
|
|
220
|
+
WebSocket URLs are derived as ws/wss from that URL. Redirects aren't followed.
|
|
221
|
+
Clients are reusable connection pools; close them after their streaming contexts.
|
|
222
|
+
An injected `http_client` remains caller-owned. Injected clients should not have
|
|
223
|
+
default authorization headers if health requests must remain unauthenticated.
|
|
224
|
+
|
|
225
|
+
## Development and release
|
|
226
|
+
|
|
227
|
+
From the repository root, `uv sync --all-packages --all-groups` prepares development.
|
|
228
|
+
CI uses an isolated environment and installs this package directly, preventing
|
|
229
|
+
backend dependencies from masking missing SDK dependencies.
|
|
230
|
+
|
|
231
|
+
```sh
|
|
232
|
+
uv run --package tazo-sdk --group dev pytest packages/tazo-sdk/tests
|
|
233
|
+
uv run --package tazo-sdk --group dev ruff check packages/tazo-sdk
|
|
234
|
+
uv run --package tazo-sdk --group dev mypy --config-file packages/tazo-sdk/pyproject.toml packages/tazo-sdk/src/tazo
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
See [RELEASING.md](RELEASING.md) before publishing. API v1 and SDK versions are
|
|
238
|
+
independent. This beta may change its Python interface before 1.0; changes are
|
|
239
|
+
recorded in [CHANGELOG.md](CHANGELOG.md). Response fields are additive-compatible.
|
tazo_sdk-0.1.0/README.md
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# Tazo Python SDK
|
|
2
|
+
|
|
3
|
+
Typed, synchronous and asynchronous clients for Tazo audio decisions.
|
|
4
|
+
Supports exactly four public operations: uploaded decisions, streaming decisions,
|
|
5
|
+
model discovery, and health. API-key management and internal APIs are outside this package.
|
|
6
|
+
|
|
7
|
+
**Release status:** This repository's 0.1.0 release has not been published to PyPI. `tazo-sdk` is the proposed PyPI name; verify ownership
|
|
8
|
+
before publishing. Until then, install from source.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
Python 3.11 or newer is required. From the repository root:
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
python -m pip install ./packages/tazo-sdk
|
|
16
|
+
export TAZO_API_KEY='your-key'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
After publication, use `python -m pip install tazo-sdk`.
|
|
20
|
+
Create a key in the [console](https://app.tazolabs.com); the SDK never manages keys.
|
|
21
|
+
|
|
22
|
+
## Uploaded decision
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
from tazo import Tazo
|
|
27
|
+
|
|
28
|
+
questions = {
|
|
29
|
+
"action": {
|
|
30
|
+
"type": "choice",
|
|
31
|
+
"instructions": "Which action should be taken?",
|
|
32
|
+
"criteria": {
|
|
33
|
+
"get_weather": "Get weather for a city.",
|
|
34
|
+
"NO_TOOL": "No tool is needed.",
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
with Tazo() as client:
|
|
40
|
+
result = client.decisions.create(
|
|
41
|
+
audio=Path("request.wav"),
|
|
42
|
+
state="Choose the action matching the spoken request.",
|
|
43
|
+
questions=questions,
|
|
44
|
+
)
|
|
45
|
+
print(result.answers["action"])
|
|
46
|
+
print(result.request_id, result.idempotency_key)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`model` defaults to `tazo-large`. Choice and noul dictionaries or the optional
|
|
50
|
+
`ChoiceQuestion` / `NoulQuestion` models are accepted. Check `models.list()` for
|
|
51
|
+
model-specific capabilities. Score questions aren't supported by this SDK release.
|
|
52
|
+
|
|
53
|
+
Audio can be a path, bytes, or a binary stream. For bytes, pass `filename` and
|
|
54
|
+
`content_type` when known. Uploads are snapshotted once, up to 16 MiB, so retries
|
|
55
|
+
use the same bytes and MIME type. Caller-provided streams aren't closed;
|
|
56
|
+
seekable streams are restored to their initial position. Nonseekable streams are
|
|
57
|
+
consumed once. No prompt word limit is imposed by the SDK.
|
|
58
|
+
|
|
59
|
+
## Models and health
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from tazo import Tazo
|
|
63
|
+
|
|
64
|
+
with Tazo() as client:
|
|
65
|
+
print(client.health.check().status) # ok or unavailable; no auth sent
|
|
66
|
+
for model in client.models.list().models:
|
|
67
|
+
print(model.id, model.ready, model.capabilities.question_types)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Credentials are required only for protected calls. HTTP 503 with the documented
|
|
71
|
+
unavailable health body returns `HealthStatus(status="unavailable")`.
|
|
72
|
+
|
|
73
|
+
## Async
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
import asyncio
|
|
77
|
+
from tazo import AsyncTazo
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
async def main():
|
|
81
|
+
async with AsyncTazo() as client:
|
|
82
|
+
print((await client.models.list()).models)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
asyncio.run(main())
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Await `decisions.create`, `models.list`, and `health.check`. Async streaming is an
|
|
89
|
+
async context manager, not an awaitable factory.
|
|
90
|
+
|
|
91
|
+
## Streaming
|
|
92
|
+
|
|
93
|
+
Both clients expose `decisions.stream(state=..., questions=...)`. Entering the
|
|
94
|
+
context authenticates in `session.start` and waits for `session.ready`. Inspect
|
|
95
|
+
`session.ready` for limits. Send raw mono 16 kHz PCM16 little-endian bytes, at most
|
|
96
|
+
`max_audio_message_bytes` per message. The `wav_chunks` helper strips WAV headers
|
|
97
|
+
and validates the format; it does not resample or pace audio.
|
|
98
|
+
|
|
99
|
+
Send audio in one task while another consumes events:
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
import asyncio
|
|
103
|
+
from tazo import AsyncTazo, wav_chunks
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
async def stream_recording(questions):
|
|
107
|
+
async with AsyncTazo() as client:
|
|
108
|
+
async with client.decisions.stream(
|
|
109
|
+
state="Choose an action.", questions=questions, audio_scope="turn"
|
|
110
|
+
) as session:
|
|
111
|
+
|
|
112
|
+
async def send():
|
|
113
|
+
for chunk in wav_chunks("request.wav"):
|
|
114
|
+
await asyncio.sleep(len(chunk) / 32000) # microphone pacing
|
|
115
|
+
await session.send_audio(chunk)
|
|
116
|
+
await session.commit()
|
|
117
|
+
|
|
118
|
+
async def receive():
|
|
119
|
+
async for event in session:
|
|
120
|
+
if event.type in {"decision.updated", "decision.finalized"}:
|
|
121
|
+
print(event.model_dump())
|
|
122
|
+
if event.type == "decision.finalized":
|
|
123
|
+
await session.finish()
|
|
124
|
+
|
|
125
|
+
async with asyncio.TaskGroup() as group:
|
|
126
|
+
group.create_task(send())
|
|
127
|
+
group.create_task(receive())
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The executable `examples/stream.py` also propagates producer failures immediately.
|
|
131
|
+
For synchronous streaming, use a sender thread and iterate the session in the
|
|
132
|
+
receiving thread. Never receive concurrently from multiple tasks or threads.
|
|
133
|
+
|
|
134
|
+
`commit()` sends a control message; consume `decision.finalized` before another
|
|
135
|
+
turn. `update(state=..., questions=...)` is allowed between turns; consume
|
|
136
|
+
`session.updated` before audio. `finish()` requests finalization and closure;
|
|
137
|
+
continue iterating through `session.closed`. Context exit closes immediately.
|
|
138
|
+
Fatal server errors raise `StreamingError`; recoverable errors are `ErrorEvent`s.
|
|
139
|
+
Future event types become `UnknownEvent`, preserving their fields.
|
|
140
|
+
|
|
141
|
+
Default `audio_scope="turn"` evaluates cumulative audio. `chunk` evaluates only
|
|
142
|
+
new audio; its final result covers the last window, not the whole turn. Each
|
|
143
|
+
evaluation counts against the account's per-model limits. Long recordings must
|
|
144
|
+
be divided into turns within the server's advertised duration. There is no
|
|
145
|
+
automatic reconnect, audio replay, silence detection, or microphone dependency.
|
|
146
|
+
|
|
147
|
+
## Retries and errors
|
|
148
|
+
|
|
149
|
+
Each `decisions.create()` call generates a UUID operation key, unless you supply
|
|
150
|
+
`idempotency_key`. All automatic attempts reuse the key, JSON, and audio. A new
|
|
151
|
+
method call creates a new operation unless you explicitly reuse a retained key.
|
|
152
|
+
Use a caller-generated key if you need recovery across process crashes or async
|
|
153
|
+
cancellation. Accepted durable work can continue after a disconnect.
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
from pathlib import Path
|
|
157
|
+
from uuid import uuid4
|
|
158
|
+
from tazo import DecisionPendingError, Tazo
|
|
159
|
+
|
|
160
|
+
key = str(uuid4()) # persist alongside your original request before submission
|
|
161
|
+
with Tazo() as client:
|
|
162
|
+
try:
|
|
163
|
+
result = client.decisions.create(
|
|
164
|
+
audio=Path("request.wav"),
|
|
165
|
+
state="Choose an action.",
|
|
166
|
+
questions=questions,
|
|
167
|
+
idempotency_key=key,
|
|
168
|
+
)
|
|
169
|
+
except DecisionPendingError as error:
|
|
170
|
+
print(error.request_id, error.idempotency_key)
|
|
171
|
+
# Later: call create with this key and the exact same input and MIME type.
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Default `max_retries=2` means at most three attempts. Retryable service/network
|
|
175
|
+
errors use bounded exponential backoff with jitter and respect `Retry-After`.
|
|
176
|
+
Authentication, invalid input, conflicts, and oversized uploads are not retried.
|
|
177
|
+
`decision_pending` may be retried with the retained key. There is no job-status
|
|
178
|
+
endpoint. Recovery requires calling create again with the original input.
|
|
179
|
+
|
|
180
|
+
Exceptions expose `status_code`, `code`, `request_id`, `idempotency_key`,
|
|
181
|
+
`retryable`, and `retry_after` where available. Invalid server responses raise
|
|
182
|
+
`ProtocolError`. HTTP errors without JSON receive a safe generic message.
|
|
183
|
+
The SDK does not log request content, credentials, or audio. Don't enable wire
|
|
184
|
+
debug logging in applications that must keep these private.
|
|
185
|
+
|
|
186
|
+
## Configuration and lifecycle
|
|
187
|
+
|
|
188
|
+
Defaults: `base_url="https://api.tazolabs.com"`, connect timeout 5 seconds,
|
|
189
|
+
read timeout 65 seconds, write timeout 30 seconds, pool timeout 5 seconds, and
|
|
190
|
+
`operation_timeout=180` seconds. Set a float or an `httpx.Timeout` for `timeout`.
|
|
191
|
+
|
|
192
|
+
The operation timeout bounds the HTTP retry budget and caps each network phase
|
|
193
|
+
by the remaining time. Sync calls cannot forcibly interrupt a response that keeps
|
|
194
|
+
delivering chunks or spans multiple phases; async HTTP additionally enforces a
|
|
195
|
+
hard per-attempt deadline within the remaining budget. Upload snapshotting is
|
|
196
|
+
before this budget. Streaming has its own `event_timeout` (default 65 seconds),
|
|
197
|
+
5-second connection timeout, and 2-second close timeout. All are seconds.
|
|
198
|
+
|
|
199
|
+
Custom `base_url` supports local HTTP and path-prefixed proxies; omit `/v1`.
|
|
200
|
+
Use `max_retries=0` with direct-inference development servers that don't persist
|
|
201
|
+
idempotency keys. Safe replay requires a target honoring durable idempotency.
|
|
202
|
+
WebSocket URLs are derived as ws/wss from that URL. Redirects aren't followed.
|
|
203
|
+
Clients are reusable connection pools; close them after their streaming contexts.
|
|
204
|
+
An injected `http_client` remains caller-owned. Injected clients should not have
|
|
205
|
+
default authorization headers if health requests must remain unauthenticated.
|
|
206
|
+
|
|
207
|
+
## Development and release
|
|
208
|
+
|
|
209
|
+
From the repository root, `uv sync --all-packages --all-groups` prepares development.
|
|
210
|
+
CI uses an isolated environment and installs this package directly, preventing
|
|
211
|
+
backend dependencies from masking missing SDK dependencies.
|
|
212
|
+
|
|
213
|
+
```sh
|
|
214
|
+
uv run --package tazo-sdk --group dev pytest packages/tazo-sdk/tests
|
|
215
|
+
uv run --package tazo-sdk --group dev ruff check packages/tazo-sdk
|
|
216
|
+
uv run --package tazo-sdk --group dev mypy --config-file packages/tazo-sdk/pyproject.toml packages/tazo-sdk/src/tazo
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
See [RELEASING.md](RELEASING.md) before publishing. API v1 and SDK versions are
|
|
220
|
+
independent. This beta may change its Python interface before 1.0; changes are
|
|
221
|
+
recorded in [CHANGELOG.md](CHANGELOG.md). Response fields are additive-compatible.
|