cartesia 1.3.1__py3-none-any.whl → 2.0.0a0__py3-none-any.whl
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.
- cartesia/__init__.py +288 -3
- cartesia/api_status/__init__.py +6 -0
- cartesia/api_status/client.py +104 -0
- cartesia/api_status/requests/__init__.py +5 -0
- cartesia/api_status/requests/api_info.py +8 -0
- cartesia/api_status/types/__init__.py +5 -0
- cartesia/api_status/types/api_info.py +20 -0
- cartesia/base_client.py +160 -0
- cartesia/client.py +163 -40
- cartesia/core/__init__.py +47 -0
- cartesia/core/api_error.py +15 -0
- cartesia/core/client_wrapper.py +55 -0
- cartesia/core/datetime_utils.py +28 -0
- cartesia/core/file.py +67 -0
- cartesia/core/http_client.py +499 -0
- cartesia/core/jsonable_encoder.py +101 -0
- cartesia/core/pydantic_utilities.py +296 -0
- cartesia/core/query_encoder.py +58 -0
- cartesia/core/remove_none_from_dict.py +11 -0
- cartesia/core/request_options.py +35 -0
- cartesia/core/serialization.py +272 -0
- cartesia/datasets/__init__.py +24 -0
- cartesia/datasets/client.py +422 -0
- cartesia/datasets/requests/__init__.py +15 -0
- cartesia/datasets/requests/create_dataset_request.py +7 -0
- cartesia/datasets/requests/dataset.py +9 -0
- cartesia/datasets/requests/dataset_file.py +9 -0
- cartesia/datasets/requests/paginated_dataset_files.py +10 -0
- cartesia/datasets/requests/paginated_datasets.py +10 -0
- cartesia/datasets/types/__init__.py +17 -0
- cartesia/datasets/types/create_dataset_request.py +19 -0
- cartesia/datasets/types/dataset.py +21 -0
- cartesia/datasets/types/dataset_file.py +21 -0
- cartesia/datasets/types/file_purpose.py +5 -0
- cartesia/datasets/types/paginated_dataset_files.py +21 -0
- cartesia/datasets/types/paginated_datasets.py +21 -0
- cartesia/embedding/__init__.py +5 -0
- cartesia/embedding/types/__init__.py +5 -0
- cartesia/embedding/types/embedding.py +201 -0
- cartesia/environment.py +7 -0
- cartesia/infill/__init__.py +2 -0
- cartesia/infill/client.py +294 -0
- cartesia/tts/__init__.py +167 -0
- cartesia/{_async_websocket.py → tts/_async_websocket.py} +159 -84
- cartesia/tts/_websocket.py +430 -0
- cartesia/tts/client.py +407 -0
- cartesia/tts/requests/__init__.py +76 -0
- cartesia/tts/requests/cancel_context_request.py +17 -0
- cartesia/tts/requests/controls.py +11 -0
- cartesia/tts/requests/generation_request.py +53 -0
- cartesia/tts/requests/mp_3_output_format.py +11 -0
- cartesia/tts/requests/output_format.py +30 -0
- cartesia/tts/requests/phoneme_timestamps.py +10 -0
- cartesia/tts/requests/raw_output_format.py +11 -0
- cartesia/tts/requests/speed.py +7 -0
- cartesia/tts/requests/tts_request.py +24 -0
- cartesia/tts/requests/tts_request_embedding_specifier.py +16 -0
- cartesia/tts/requests/tts_request_id_specifier.py +16 -0
- cartesia/tts/requests/tts_request_voice_specifier.py +7 -0
- cartesia/tts/requests/wav_output_format.py +7 -0
- cartesia/tts/requests/web_socket_base_response.py +11 -0
- cartesia/tts/requests/web_socket_chunk_response.py +8 -0
- cartesia/tts/requests/web_socket_done_response.py +7 -0
- cartesia/tts/requests/web_socket_error_response.py +7 -0
- cartesia/tts/requests/web_socket_flush_done_response.py +9 -0
- cartesia/tts/requests/web_socket_phoneme_timestamps_response.py +9 -0
- cartesia/tts/requests/web_socket_raw_output_format.py +11 -0
- cartesia/tts/requests/web_socket_request.py +7 -0
- cartesia/tts/requests/web_socket_response.py +69 -0
- cartesia/tts/requests/web_socket_stream_options.py +8 -0
- cartesia/tts/requests/web_socket_timestamps_response.py +9 -0
- cartesia/tts/requests/web_socket_tts_output.py +18 -0
- cartesia/tts/requests/web_socket_tts_request.py +24 -0
- cartesia/tts/requests/word_timestamps.py +10 -0
- cartesia/tts/socket_client.py +302 -0
- cartesia/tts/types/__init__.py +90 -0
- cartesia/tts/types/cancel_context_request.py +28 -0
- cartesia/tts/types/context_id.py +3 -0
- cartesia/tts/types/controls.py +22 -0
- cartesia/tts/types/emotion.py +29 -0
- cartesia/tts/types/flush_id.py +3 -0
- cartesia/tts/types/generation_request.py +66 -0
- cartesia/tts/types/mp_3_output_format.py +23 -0
- cartesia/tts/types/natural_specifier.py +5 -0
- cartesia/tts/types/numerical_specifier.py +3 -0
- cartesia/tts/types/output_format.py +58 -0
- cartesia/tts/types/phoneme_timestamps.py +21 -0
- cartesia/tts/types/raw_encoding.py +5 -0
- cartesia/tts/types/raw_output_format.py +22 -0
- cartesia/tts/types/speed.py +7 -0
- cartesia/tts/types/supported_language.py +7 -0
- cartesia/tts/types/tts_request.py +35 -0
- cartesia/tts/types/tts_request_embedding_specifier.py +27 -0
- cartesia/tts/types/tts_request_id_specifier.py +27 -0
- cartesia/tts/types/tts_request_voice_specifier.py +7 -0
- cartesia/tts/types/wav_output_format.py +17 -0
- cartesia/tts/types/web_socket_base_response.py +22 -0
- cartesia/tts/types/web_socket_chunk_response.py +20 -0
- cartesia/tts/types/web_socket_done_response.py +17 -0
- cartesia/tts/types/web_socket_error_response.py +19 -0
- cartesia/tts/types/web_socket_flush_done_response.py +21 -0
- cartesia/tts/types/web_socket_phoneme_timestamps_response.py +20 -0
- cartesia/tts/types/web_socket_raw_output_format.py +22 -0
- cartesia/tts/types/web_socket_request.py +7 -0
- cartesia/tts/types/web_socket_response.py +124 -0
- cartesia/tts/types/web_socket_stream_options.py +19 -0
- cartesia/tts/types/web_socket_timestamps_response.py +20 -0
- cartesia/tts/types/web_socket_tts_output.py +27 -0
- cartesia/tts/types/web_socket_tts_request.py +36 -0
- cartesia/tts/types/word_timestamps.py +21 -0
- cartesia/tts/utils/tts.py +64 -0
- cartesia/tts/utils/types.py +70 -0
- cartesia/version.py +3 -1
- cartesia/voice_changer/__init__.py +27 -0
- cartesia/voice_changer/client.py +395 -0
- cartesia/voice_changer/requests/__init__.py +15 -0
- cartesia/voice_changer/requests/streaming_response.py +36 -0
- cartesia/voice_changer/types/__init__.py +17 -0
- cartesia/voice_changer/types/output_format_container.py +5 -0
- cartesia/voice_changer/types/streaming_response.py +62 -0
- cartesia/voices/__init__.py +67 -0
- cartesia/voices/client.py +1812 -0
- cartesia/voices/requests/__init__.py +27 -0
- cartesia/voices/requests/create_voice_request.py +21 -0
- cartesia/voices/requests/embedding_response.py +8 -0
- cartesia/voices/requests/embedding_specifier.py +10 -0
- cartesia/voices/requests/id_specifier.py +10 -0
- cartesia/voices/requests/localize_dialect.py +6 -0
- cartesia/voices/requests/localize_voice_request.py +15 -0
- cartesia/voices/requests/mix_voice_specifier.py +7 -0
- cartesia/voices/requests/mix_voices_request.py +9 -0
- cartesia/voices/requests/update_voice_request.py +15 -0
- cartesia/voices/requests/voice.py +39 -0
- cartesia/voices/requests/voice_metadata.py +36 -0
- cartesia/voices/types/__init__.py +41 -0
- cartesia/voices/types/base_voice_id.py +5 -0
- cartesia/voices/types/clone_mode.py +5 -0
- cartesia/voices/types/create_voice_request.py +32 -0
- cartesia/voices/types/embedding_response.py +20 -0
- cartesia/voices/types/embedding_specifier.py +22 -0
- cartesia/voices/types/gender.py +5 -0
- cartesia/voices/types/id_specifier.py +22 -0
- cartesia/voices/types/localize_dialect.py +6 -0
- cartesia/voices/types/localize_english_dialect.py +5 -0
- cartesia/voices/types/localize_target_language.py +7 -0
- cartesia/voices/types/localize_voice_request.py +26 -0
- cartesia/voices/types/mix_voice_specifier.py +7 -0
- cartesia/voices/types/mix_voices_request.py +20 -0
- cartesia/voices/types/update_voice_request.py +27 -0
- cartesia/voices/types/voice.py +50 -0
- cartesia/voices/types/voice_id.py +3 -0
- cartesia/voices/types/voice_metadata.py +48 -0
- cartesia/voices/types/weight.py +3 -0
- cartesia-2.0.0a0.dist-info/METADATA +306 -0
- cartesia-2.0.0a0.dist-info/RECORD +158 -0
- {cartesia-1.3.1.dist-info → cartesia-2.0.0a0.dist-info}/WHEEL +1 -1
- cartesia/_async_sse.py +0 -95
- cartesia/_logger.py +0 -3
- cartesia/_sse.py +0 -143
- cartesia/_types.py +0 -70
- cartesia/_websocket.py +0 -358
- cartesia/async_client.py +0 -82
- cartesia/async_tts.py +0 -63
- cartesia/resource.py +0 -44
- cartesia/tts.py +0 -137
- cartesia/utils/deprecated.py +0 -55
- cartesia/utils/retry.py +0 -87
- cartesia/utils/tts.py +0 -78
- cartesia/voices.py +0 -208
- cartesia-1.3.1.dist-info/METADATA +0 -661
- cartesia-1.3.1.dist-info/RECORD +0 -23
- cartesia-1.3.1.dist-info/licenses/LICENSE.md +0 -21
- /cartesia/{utils/__init__.py → py.typed} +0 -0
- /cartesia/{_constants.py → tts/utils/constants.py} +0 -0
@@ -0,0 +1,422 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
import typing
|
4
|
+
from ..core.client_wrapper import SyncClientWrapper
|
5
|
+
from ..core.request_options import RequestOptions
|
6
|
+
from .types.paginated_datasets import PaginatedDatasets
|
7
|
+
from ..core.pydantic_utilities import parse_obj_as
|
8
|
+
from json.decoder import JSONDecodeError
|
9
|
+
from ..core.api_error import ApiError
|
10
|
+
from .types.dataset import Dataset
|
11
|
+
from .types.paginated_dataset_files import PaginatedDatasetFiles
|
12
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
13
|
+
from .. import core
|
14
|
+
from .types.file_purpose import FilePurpose
|
15
|
+
from ..core.client_wrapper import AsyncClientWrapper
|
16
|
+
|
17
|
+
# this is used as the default value for optional parameters
|
18
|
+
OMIT = typing.cast(typing.Any, ...)
|
19
|
+
|
20
|
+
|
21
|
+
class DatasetsClient:
|
22
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
23
|
+
self._client_wrapper = client_wrapper
|
24
|
+
|
25
|
+
def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> PaginatedDatasets:
|
26
|
+
"""
|
27
|
+
Parameters
|
28
|
+
----------
|
29
|
+
request_options : typing.Optional[RequestOptions]
|
30
|
+
Request-specific configuration.
|
31
|
+
|
32
|
+
Returns
|
33
|
+
-------
|
34
|
+
PaginatedDatasets
|
35
|
+
|
36
|
+
Examples
|
37
|
+
--------
|
38
|
+
from cartesia import Cartesia
|
39
|
+
|
40
|
+
client = Cartesia(
|
41
|
+
api_key="YOUR_API_KEY",
|
42
|
+
)
|
43
|
+
client.datasets.list()
|
44
|
+
"""
|
45
|
+
_response = self._client_wrapper.httpx_client.request(
|
46
|
+
"datasets/",
|
47
|
+
method="GET",
|
48
|
+
request_options=request_options,
|
49
|
+
)
|
50
|
+
try:
|
51
|
+
if 200 <= _response.status_code < 300:
|
52
|
+
return typing.cast(
|
53
|
+
PaginatedDatasets,
|
54
|
+
parse_obj_as(
|
55
|
+
type_=PaginatedDatasets, # type: ignore
|
56
|
+
object_=_response.json(),
|
57
|
+
),
|
58
|
+
)
|
59
|
+
_response_json = _response.json()
|
60
|
+
except JSONDecodeError:
|
61
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
62
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
63
|
+
|
64
|
+
def create(self, *, name: str, request_options: typing.Optional[RequestOptions] = None) -> Dataset:
|
65
|
+
"""
|
66
|
+
Parameters
|
67
|
+
----------
|
68
|
+
name : str
|
69
|
+
|
70
|
+
request_options : typing.Optional[RequestOptions]
|
71
|
+
Request-specific configuration.
|
72
|
+
|
73
|
+
Returns
|
74
|
+
-------
|
75
|
+
Dataset
|
76
|
+
|
77
|
+
Examples
|
78
|
+
--------
|
79
|
+
from cartesia import Cartesia
|
80
|
+
|
81
|
+
client = Cartesia(
|
82
|
+
api_key="YOUR_API_KEY",
|
83
|
+
)
|
84
|
+
client.datasets.create(
|
85
|
+
name="string",
|
86
|
+
)
|
87
|
+
"""
|
88
|
+
_response = self._client_wrapper.httpx_client.request(
|
89
|
+
"datasets/",
|
90
|
+
method="POST",
|
91
|
+
json={
|
92
|
+
"name": name,
|
93
|
+
},
|
94
|
+
request_options=request_options,
|
95
|
+
omit=OMIT,
|
96
|
+
)
|
97
|
+
try:
|
98
|
+
if 200 <= _response.status_code < 300:
|
99
|
+
return typing.cast(
|
100
|
+
Dataset,
|
101
|
+
parse_obj_as(
|
102
|
+
type_=Dataset, # type: ignore
|
103
|
+
object_=_response.json(),
|
104
|
+
),
|
105
|
+
)
|
106
|
+
_response_json = _response.json()
|
107
|
+
except JSONDecodeError:
|
108
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
109
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
110
|
+
|
111
|
+
def list_files(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> PaginatedDatasetFiles:
|
112
|
+
"""
|
113
|
+
Parameters
|
114
|
+
----------
|
115
|
+
id : str
|
116
|
+
|
117
|
+
request_options : typing.Optional[RequestOptions]
|
118
|
+
Request-specific configuration.
|
119
|
+
|
120
|
+
Returns
|
121
|
+
-------
|
122
|
+
PaginatedDatasetFiles
|
123
|
+
|
124
|
+
Examples
|
125
|
+
--------
|
126
|
+
from cartesia import Cartesia
|
127
|
+
|
128
|
+
client = Cartesia(
|
129
|
+
api_key="YOUR_API_KEY",
|
130
|
+
)
|
131
|
+
client.datasets.list_files(
|
132
|
+
id="string",
|
133
|
+
)
|
134
|
+
"""
|
135
|
+
_response = self._client_wrapper.httpx_client.request(
|
136
|
+
f"datasets/{jsonable_encoder(id)}/files",
|
137
|
+
method="GET",
|
138
|
+
request_options=request_options,
|
139
|
+
)
|
140
|
+
try:
|
141
|
+
if 200 <= _response.status_code < 300:
|
142
|
+
return typing.cast(
|
143
|
+
PaginatedDatasetFiles,
|
144
|
+
parse_obj_as(
|
145
|
+
type_=PaginatedDatasetFiles, # type: ignore
|
146
|
+
object_=_response.json(),
|
147
|
+
),
|
148
|
+
)
|
149
|
+
_response_json = _response.json()
|
150
|
+
except JSONDecodeError:
|
151
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
152
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
153
|
+
|
154
|
+
def upload_file(
|
155
|
+
self, id: str, *, file: core.File, purpose: FilePurpose, request_options: typing.Optional[RequestOptions] = None
|
156
|
+
) -> None:
|
157
|
+
"""
|
158
|
+
Parameters
|
159
|
+
----------
|
160
|
+
id : str
|
161
|
+
|
162
|
+
file : core.File
|
163
|
+
See core.File for more documentation
|
164
|
+
|
165
|
+
purpose : FilePurpose
|
166
|
+
|
167
|
+
request_options : typing.Optional[RequestOptions]
|
168
|
+
Request-specific configuration.
|
169
|
+
|
170
|
+
Returns
|
171
|
+
-------
|
172
|
+
None
|
173
|
+
|
174
|
+
Examples
|
175
|
+
--------
|
176
|
+
from cartesia import Cartesia
|
177
|
+
|
178
|
+
client = Cartesia(
|
179
|
+
api_key="YOUR_API_KEY",
|
180
|
+
)
|
181
|
+
client.datasets.upload_file(
|
182
|
+
id="string",
|
183
|
+
)
|
184
|
+
"""
|
185
|
+
_response = self._client_wrapper.httpx_client.request(
|
186
|
+
f"datasets/{jsonable_encoder(id)}/files",
|
187
|
+
method="POST",
|
188
|
+
data={
|
189
|
+
"purpose": purpose,
|
190
|
+
},
|
191
|
+
files={
|
192
|
+
"file": file,
|
193
|
+
},
|
194
|
+
request_options=request_options,
|
195
|
+
omit=OMIT,
|
196
|
+
)
|
197
|
+
try:
|
198
|
+
if 200 <= _response.status_code < 300:
|
199
|
+
return
|
200
|
+
_response_json = _response.json()
|
201
|
+
except JSONDecodeError:
|
202
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
203
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
204
|
+
|
205
|
+
|
206
|
+
class AsyncDatasetsClient:
|
207
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
208
|
+
self._client_wrapper = client_wrapper
|
209
|
+
|
210
|
+
async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> PaginatedDatasets:
|
211
|
+
"""
|
212
|
+
Parameters
|
213
|
+
----------
|
214
|
+
request_options : typing.Optional[RequestOptions]
|
215
|
+
Request-specific configuration.
|
216
|
+
|
217
|
+
Returns
|
218
|
+
-------
|
219
|
+
PaginatedDatasets
|
220
|
+
|
221
|
+
Examples
|
222
|
+
--------
|
223
|
+
import asyncio
|
224
|
+
|
225
|
+
from cartesia import AsyncCartesia
|
226
|
+
|
227
|
+
client = AsyncCartesia(
|
228
|
+
api_key="YOUR_API_KEY",
|
229
|
+
)
|
230
|
+
|
231
|
+
|
232
|
+
async def main() -> None:
|
233
|
+
await client.datasets.list()
|
234
|
+
|
235
|
+
|
236
|
+
asyncio.run(main())
|
237
|
+
"""
|
238
|
+
_response = await self._client_wrapper.httpx_client.request(
|
239
|
+
"datasets/",
|
240
|
+
method="GET",
|
241
|
+
request_options=request_options,
|
242
|
+
)
|
243
|
+
try:
|
244
|
+
if 200 <= _response.status_code < 300:
|
245
|
+
return typing.cast(
|
246
|
+
PaginatedDatasets,
|
247
|
+
parse_obj_as(
|
248
|
+
type_=PaginatedDatasets, # type: ignore
|
249
|
+
object_=_response.json(),
|
250
|
+
),
|
251
|
+
)
|
252
|
+
_response_json = _response.json()
|
253
|
+
except JSONDecodeError:
|
254
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
255
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
256
|
+
|
257
|
+
async def create(self, *, name: str, request_options: typing.Optional[RequestOptions] = None) -> Dataset:
|
258
|
+
"""
|
259
|
+
Parameters
|
260
|
+
----------
|
261
|
+
name : str
|
262
|
+
|
263
|
+
request_options : typing.Optional[RequestOptions]
|
264
|
+
Request-specific configuration.
|
265
|
+
|
266
|
+
Returns
|
267
|
+
-------
|
268
|
+
Dataset
|
269
|
+
|
270
|
+
Examples
|
271
|
+
--------
|
272
|
+
import asyncio
|
273
|
+
|
274
|
+
from cartesia import AsyncCartesia
|
275
|
+
|
276
|
+
client = AsyncCartesia(
|
277
|
+
api_key="YOUR_API_KEY",
|
278
|
+
)
|
279
|
+
|
280
|
+
|
281
|
+
async def main() -> None:
|
282
|
+
await client.datasets.create(
|
283
|
+
name="string",
|
284
|
+
)
|
285
|
+
|
286
|
+
|
287
|
+
asyncio.run(main())
|
288
|
+
"""
|
289
|
+
_response = await self._client_wrapper.httpx_client.request(
|
290
|
+
"datasets/",
|
291
|
+
method="POST",
|
292
|
+
json={
|
293
|
+
"name": name,
|
294
|
+
},
|
295
|
+
request_options=request_options,
|
296
|
+
omit=OMIT,
|
297
|
+
)
|
298
|
+
try:
|
299
|
+
if 200 <= _response.status_code < 300:
|
300
|
+
return typing.cast(
|
301
|
+
Dataset,
|
302
|
+
parse_obj_as(
|
303
|
+
type_=Dataset, # type: ignore
|
304
|
+
object_=_response.json(),
|
305
|
+
),
|
306
|
+
)
|
307
|
+
_response_json = _response.json()
|
308
|
+
except JSONDecodeError:
|
309
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
310
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
311
|
+
|
312
|
+
async def list_files(
|
313
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
314
|
+
) -> PaginatedDatasetFiles:
|
315
|
+
"""
|
316
|
+
Parameters
|
317
|
+
----------
|
318
|
+
id : str
|
319
|
+
|
320
|
+
request_options : typing.Optional[RequestOptions]
|
321
|
+
Request-specific configuration.
|
322
|
+
|
323
|
+
Returns
|
324
|
+
-------
|
325
|
+
PaginatedDatasetFiles
|
326
|
+
|
327
|
+
Examples
|
328
|
+
--------
|
329
|
+
import asyncio
|
330
|
+
|
331
|
+
from cartesia import AsyncCartesia
|
332
|
+
|
333
|
+
client = AsyncCartesia(
|
334
|
+
api_key="YOUR_API_KEY",
|
335
|
+
)
|
336
|
+
|
337
|
+
|
338
|
+
async def main() -> None:
|
339
|
+
await client.datasets.list_files(
|
340
|
+
id="string",
|
341
|
+
)
|
342
|
+
|
343
|
+
|
344
|
+
asyncio.run(main())
|
345
|
+
"""
|
346
|
+
_response = await self._client_wrapper.httpx_client.request(
|
347
|
+
f"datasets/{jsonable_encoder(id)}/files",
|
348
|
+
method="GET",
|
349
|
+
request_options=request_options,
|
350
|
+
)
|
351
|
+
try:
|
352
|
+
if 200 <= _response.status_code < 300:
|
353
|
+
return typing.cast(
|
354
|
+
PaginatedDatasetFiles,
|
355
|
+
parse_obj_as(
|
356
|
+
type_=PaginatedDatasetFiles, # type: ignore
|
357
|
+
object_=_response.json(),
|
358
|
+
),
|
359
|
+
)
|
360
|
+
_response_json = _response.json()
|
361
|
+
except JSONDecodeError:
|
362
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
363
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
364
|
+
|
365
|
+
async def upload_file(
|
366
|
+
self, id: str, *, file: core.File, purpose: FilePurpose, request_options: typing.Optional[RequestOptions] = None
|
367
|
+
) -> None:
|
368
|
+
"""
|
369
|
+
Parameters
|
370
|
+
----------
|
371
|
+
id : str
|
372
|
+
|
373
|
+
file : core.File
|
374
|
+
See core.File for more documentation
|
375
|
+
|
376
|
+
purpose : FilePurpose
|
377
|
+
|
378
|
+
request_options : typing.Optional[RequestOptions]
|
379
|
+
Request-specific configuration.
|
380
|
+
|
381
|
+
Returns
|
382
|
+
-------
|
383
|
+
None
|
384
|
+
|
385
|
+
Examples
|
386
|
+
--------
|
387
|
+
import asyncio
|
388
|
+
|
389
|
+
from cartesia import AsyncCartesia
|
390
|
+
|
391
|
+
client = AsyncCartesia(
|
392
|
+
api_key="YOUR_API_KEY",
|
393
|
+
)
|
394
|
+
|
395
|
+
|
396
|
+
async def main() -> None:
|
397
|
+
await client.datasets.upload_file(
|
398
|
+
id="string",
|
399
|
+
)
|
400
|
+
|
401
|
+
|
402
|
+
asyncio.run(main())
|
403
|
+
"""
|
404
|
+
_response = await self._client_wrapper.httpx_client.request(
|
405
|
+
f"datasets/{jsonable_encoder(id)}/files",
|
406
|
+
method="POST",
|
407
|
+
data={
|
408
|
+
"purpose": purpose,
|
409
|
+
},
|
410
|
+
files={
|
411
|
+
"file": file,
|
412
|
+
},
|
413
|
+
request_options=request_options,
|
414
|
+
omit=OMIT,
|
415
|
+
)
|
416
|
+
try:
|
417
|
+
if 200 <= _response.status_code < 300:
|
418
|
+
return
|
419
|
+
_response_json = _response.json()
|
420
|
+
except JSONDecodeError:
|
421
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
422
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
from .create_dataset_request import CreateDatasetRequestParams
|
4
|
+
from .dataset import DatasetParams
|
5
|
+
from .dataset_file import DatasetFileParams
|
6
|
+
from .paginated_dataset_files import PaginatedDatasetFilesParams
|
7
|
+
from .paginated_datasets import PaginatedDatasetsParams
|
8
|
+
|
9
|
+
__all__ = [
|
10
|
+
"CreateDatasetRequestParams",
|
11
|
+
"DatasetFileParams",
|
12
|
+
"DatasetParams",
|
13
|
+
"PaginatedDatasetFilesParams",
|
14
|
+
"PaginatedDatasetsParams",
|
15
|
+
]
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
import typing_extensions
|
4
|
+
import typing
|
5
|
+
from .dataset_file import DatasetFileParams
|
6
|
+
|
7
|
+
|
8
|
+
class PaginatedDatasetFilesParams(typing_extensions.TypedDict):
|
9
|
+
data: typing.Sequence[DatasetFileParams]
|
10
|
+
has_more: bool
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
import typing_extensions
|
4
|
+
import typing
|
5
|
+
from .dataset import DatasetParams
|
6
|
+
|
7
|
+
|
8
|
+
class PaginatedDatasetsParams(typing_extensions.TypedDict):
|
9
|
+
data: typing.Sequence[DatasetParams]
|
10
|
+
has_more: bool
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
from .create_dataset_request import CreateDatasetRequest
|
4
|
+
from .dataset import Dataset
|
5
|
+
from .dataset_file import DatasetFile
|
6
|
+
from .file_purpose import FilePurpose
|
7
|
+
from .paginated_dataset_files import PaginatedDatasetFiles
|
8
|
+
from .paginated_datasets import PaginatedDatasets
|
9
|
+
|
10
|
+
__all__ = [
|
11
|
+
"CreateDatasetRequest",
|
12
|
+
"Dataset",
|
13
|
+
"DatasetFile",
|
14
|
+
"FilePurpose",
|
15
|
+
"PaginatedDatasetFiles",
|
16
|
+
"PaginatedDatasets",
|
17
|
+
]
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
from ...core.pydantic_utilities import UniversalBaseModel
|
4
|
+
from ...core.pydantic_utilities import IS_PYDANTIC_V2
|
5
|
+
import typing
|
6
|
+
import pydantic
|
7
|
+
|
8
|
+
|
9
|
+
class CreateDatasetRequest(UniversalBaseModel):
|
10
|
+
name: str
|
11
|
+
|
12
|
+
if IS_PYDANTIC_V2:
|
13
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
14
|
+
else:
|
15
|
+
|
16
|
+
class Config:
|
17
|
+
frozen = True
|
18
|
+
smart_union = True
|
19
|
+
extra = pydantic.Extra.allow
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
from ...core.pydantic_utilities import UniversalBaseModel
|
4
|
+
from ...core.pydantic_utilities import IS_PYDANTIC_V2
|
5
|
+
import typing
|
6
|
+
import pydantic
|
7
|
+
|
8
|
+
|
9
|
+
class Dataset(UniversalBaseModel):
|
10
|
+
id: str
|
11
|
+
name: str
|
12
|
+
created_at: str
|
13
|
+
|
14
|
+
if IS_PYDANTIC_V2:
|
15
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
16
|
+
else:
|
17
|
+
|
18
|
+
class Config:
|
19
|
+
frozen = True
|
20
|
+
smart_union = True
|
21
|
+
extra = pydantic.Extra.allow
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
from ...core.pydantic_utilities import UniversalBaseModel
|
4
|
+
from ...core.pydantic_utilities import IS_PYDANTIC_V2
|
5
|
+
import typing
|
6
|
+
import pydantic
|
7
|
+
|
8
|
+
|
9
|
+
class DatasetFile(UniversalBaseModel):
|
10
|
+
id: str
|
11
|
+
filename: str
|
12
|
+
created_at: str
|
13
|
+
|
14
|
+
if IS_PYDANTIC_V2:
|
15
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
16
|
+
else:
|
17
|
+
|
18
|
+
class Config:
|
19
|
+
frozen = True
|
20
|
+
smart_union = True
|
21
|
+
extra = pydantic.Extra.allow
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
from ...core.pydantic_utilities import UniversalBaseModel
|
4
|
+
import typing
|
5
|
+
from .dataset_file import DatasetFile
|
6
|
+
from ...core.pydantic_utilities import IS_PYDANTIC_V2
|
7
|
+
import pydantic
|
8
|
+
|
9
|
+
|
10
|
+
class PaginatedDatasetFiles(UniversalBaseModel):
|
11
|
+
data: typing.List[DatasetFile]
|
12
|
+
has_more: bool
|
13
|
+
|
14
|
+
if IS_PYDANTIC_V2:
|
15
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
16
|
+
else:
|
17
|
+
|
18
|
+
class Config:
|
19
|
+
frozen = True
|
20
|
+
smart_union = True
|
21
|
+
extra = pydantic.Extra.allow
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
from ...core.pydantic_utilities import UniversalBaseModel
|
4
|
+
import typing
|
5
|
+
from .dataset import Dataset
|
6
|
+
from ...core.pydantic_utilities import IS_PYDANTIC_V2
|
7
|
+
import pydantic
|
8
|
+
|
9
|
+
|
10
|
+
class PaginatedDatasets(UniversalBaseModel):
|
11
|
+
data: typing.List[Dataset]
|
12
|
+
has_more: bool
|
13
|
+
|
14
|
+
if IS_PYDANTIC_V2:
|
15
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
16
|
+
else:
|
17
|
+
|
18
|
+
class Config:
|
19
|
+
frozen = True
|
20
|
+
smart_union = True
|
21
|
+
extra = pydantic.Extra.allow
|