spitch 1.33.0__py3-none-any.whl → 1.35.0__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.
Potentially problematic release.
This version of spitch might be problematic. Click here for more details.
- spitch/__init__.py +3 -1
- spitch/_base_client.py +12 -12
- spitch/_client.py +33 -24
- spitch/_compat.py +47 -47
- spitch/_models.py +51 -45
- spitch/_qs.py +7 -7
- spitch/_types.py +53 -12
- spitch/_utils/__init__.py +9 -2
- spitch/_utils/_compat.py +45 -0
- spitch/_utils/_datetime_parse.py +136 -0
- spitch/_utils/_transform.py +13 -3
- spitch/_utils/_typing.py +6 -1
- spitch/_utils/_utils.py +4 -5
- spitch/_version.py +1 -1
- spitch/pagination.py +50 -0
- spitch/resources/__init__.py +14 -0
- spitch/resources/files.py +580 -0
- spitch/resources/speech.py +17 -17
- spitch/resources/text.py +5 -5
- spitch/types/__init__.py +7 -0
- spitch/types/file_delete_response.py +11 -0
- spitch/types/file_download_params.py +11 -0
- spitch/types/file_get_response.py +24 -0
- spitch/types/file_list_params.py +16 -0
- spitch/types/file_list_response.py +24 -0
- spitch/types/file_upload_params.py +13 -0
- spitch/types/file_upload_response.py +24 -0
- {spitch-1.33.0.dist-info → spitch-1.35.0.dist-info}/METADATA +10 -3
- spitch-1.35.0.dist-info/RECORD +52 -0
- spitch-1.33.0.dist-info/RECORD +0 -41
- {spitch-1.33.0.dist-info → spitch-1.35.0.dist-info}/WHEEL +0 -0
- {spitch-1.33.0.dist-info → spitch-1.35.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,580 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Mapping, Optional, cast
|
|
6
|
+
from typing_extensions import Literal
|
|
7
|
+
|
|
8
|
+
import httpx
|
|
9
|
+
|
|
10
|
+
from ..types import file_list_params, file_upload_params, file_download_params
|
|
11
|
+
from .._types import Body, Omit, Query, Headers, NotGiven, FileTypes, omit, not_given
|
|
12
|
+
from .._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
|
|
13
|
+
from .._compat import cached_property
|
|
14
|
+
from .._resource import SyncAPIResource, AsyncAPIResource
|
|
15
|
+
from .._response import (
|
|
16
|
+
to_raw_response_wrapper,
|
|
17
|
+
to_streamed_response_wrapper,
|
|
18
|
+
async_to_raw_response_wrapper,
|
|
19
|
+
async_to_streamed_response_wrapper,
|
|
20
|
+
)
|
|
21
|
+
from ..pagination import SyncFilesCursor, AsyncFilesCursor
|
|
22
|
+
from .._base_client import AsyncPaginator, make_request_options
|
|
23
|
+
from ..types.file_get_response import FileGetResponse
|
|
24
|
+
from ..types.file_list_response import FileListResponse
|
|
25
|
+
from ..types.file_delete_response import FileDeleteResponse
|
|
26
|
+
from ..types.file_upload_response import FileUploadResponse
|
|
27
|
+
|
|
28
|
+
__all__ = ["FilesResource", "AsyncFilesResource"]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class FilesResource(SyncAPIResource):
|
|
32
|
+
@cached_property
|
|
33
|
+
def with_raw_response(self) -> FilesResourceWithRawResponse:
|
|
34
|
+
"""
|
|
35
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
36
|
+
the raw response object instead of the parsed content.
|
|
37
|
+
|
|
38
|
+
For more information, see https://www.github.com/spi-tch/spitch-python#accessing-raw-response-data-eg-headers
|
|
39
|
+
"""
|
|
40
|
+
return FilesResourceWithRawResponse(self)
|
|
41
|
+
|
|
42
|
+
@cached_property
|
|
43
|
+
def with_streaming_response(self) -> FilesResourceWithStreamingResponse:
|
|
44
|
+
"""
|
|
45
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
46
|
+
|
|
47
|
+
For more information, see https://www.github.com/spi-tch/spitch-python#with_streaming_response
|
|
48
|
+
"""
|
|
49
|
+
return FilesResourceWithStreamingResponse(self)
|
|
50
|
+
|
|
51
|
+
def list(
|
|
52
|
+
self,
|
|
53
|
+
*,
|
|
54
|
+
cursor: Optional[str] | Omit = omit,
|
|
55
|
+
limit: int | Omit = omit,
|
|
56
|
+
status: Optional[Literal["uploading", "ready"]] | Omit = omit,
|
|
57
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
58
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
59
|
+
extra_headers: Headers | None = None,
|
|
60
|
+
extra_query: Query | None = None,
|
|
61
|
+
extra_body: Body | None = None,
|
|
62
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
63
|
+
) -> SyncFilesCursor[FileListResponse]:
|
|
64
|
+
"""
|
|
65
|
+
Get Files
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
extra_headers: Send extra headers
|
|
69
|
+
|
|
70
|
+
extra_query: Add additional query parameters to the request
|
|
71
|
+
|
|
72
|
+
extra_body: Add additional JSON properties to the request
|
|
73
|
+
|
|
74
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
75
|
+
"""
|
|
76
|
+
return self._get_api_list(
|
|
77
|
+
"/v1/files",
|
|
78
|
+
page=SyncFilesCursor[FileListResponse],
|
|
79
|
+
options=make_request_options(
|
|
80
|
+
extra_headers=extra_headers,
|
|
81
|
+
extra_query=extra_query,
|
|
82
|
+
extra_body=extra_body,
|
|
83
|
+
timeout=timeout,
|
|
84
|
+
query=maybe_transform(
|
|
85
|
+
{
|
|
86
|
+
"cursor": cursor,
|
|
87
|
+
"limit": limit,
|
|
88
|
+
"status": status,
|
|
89
|
+
},
|
|
90
|
+
file_list_params.FileListParams,
|
|
91
|
+
),
|
|
92
|
+
),
|
|
93
|
+
model=FileListResponse,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
def delete(
|
|
97
|
+
self,
|
|
98
|
+
file_id: str,
|
|
99
|
+
*,
|
|
100
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
101
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
102
|
+
extra_headers: Headers | None = None,
|
|
103
|
+
extra_query: Query | None = None,
|
|
104
|
+
extra_body: Body | None = None,
|
|
105
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
106
|
+
) -> FileDeleteResponse:
|
|
107
|
+
"""
|
|
108
|
+
Delete File
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
extra_headers: Send extra headers
|
|
112
|
+
|
|
113
|
+
extra_query: Add additional query parameters to the request
|
|
114
|
+
|
|
115
|
+
extra_body: Add additional JSON properties to the request
|
|
116
|
+
|
|
117
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
118
|
+
"""
|
|
119
|
+
if not file_id:
|
|
120
|
+
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
|
|
121
|
+
return self._delete(
|
|
122
|
+
f"/v1/files/{file_id}",
|
|
123
|
+
options=make_request_options(
|
|
124
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
125
|
+
),
|
|
126
|
+
cast_to=FileDeleteResponse,
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
def download(
|
|
130
|
+
self,
|
|
131
|
+
file_id: str,
|
|
132
|
+
*,
|
|
133
|
+
ttl: int | Omit = omit,
|
|
134
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
135
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
136
|
+
extra_headers: Headers | None = None,
|
|
137
|
+
extra_query: Query | None = None,
|
|
138
|
+
extra_body: Body | None = None,
|
|
139
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
140
|
+
) -> object:
|
|
141
|
+
"""
|
|
142
|
+
Download File
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
extra_headers: Send extra headers
|
|
146
|
+
|
|
147
|
+
extra_query: Add additional query parameters to the request
|
|
148
|
+
|
|
149
|
+
extra_body: Add additional JSON properties to the request
|
|
150
|
+
|
|
151
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
152
|
+
"""
|
|
153
|
+
if not file_id:
|
|
154
|
+
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
|
|
155
|
+
return self._get(
|
|
156
|
+
f"/v1/files/{file_id}/url",
|
|
157
|
+
options=make_request_options(
|
|
158
|
+
extra_headers=extra_headers,
|
|
159
|
+
extra_query=extra_query,
|
|
160
|
+
extra_body=extra_body,
|
|
161
|
+
timeout=timeout,
|
|
162
|
+
query=maybe_transform({"ttl": ttl}, file_download_params.FileDownloadParams),
|
|
163
|
+
),
|
|
164
|
+
cast_to=object,
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
def get(
|
|
168
|
+
self,
|
|
169
|
+
file_id: str,
|
|
170
|
+
*,
|
|
171
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
172
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
173
|
+
extra_headers: Headers | None = None,
|
|
174
|
+
extra_query: Query | None = None,
|
|
175
|
+
extra_body: Body | None = None,
|
|
176
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
177
|
+
) -> FileGetResponse:
|
|
178
|
+
"""
|
|
179
|
+
Get File
|
|
180
|
+
|
|
181
|
+
Args:
|
|
182
|
+
extra_headers: Send extra headers
|
|
183
|
+
|
|
184
|
+
extra_query: Add additional query parameters to the request
|
|
185
|
+
|
|
186
|
+
extra_body: Add additional JSON properties to the request
|
|
187
|
+
|
|
188
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
189
|
+
"""
|
|
190
|
+
if not file_id:
|
|
191
|
+
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
|
|
192
|
+
return self._get(
|
|
193
|
+
f"/v1/files/{file_id}",
|
|
194
|
+
options=make_request_options(
|
|
195
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
196
|
+
),
|
|
197
|
+
cast_to=FileGetResponse,
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
def upload(
|
|
201
|
+
self,
|
|
202
|
+
*,
|
|
203
|
+
file: FileTypes,
|
|
204
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
205
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
206
|
+
extra_headers: Headers | None = None,
|
|
207
|
+
extra_query: Query | None = None,
|
|
208
|
+
extra_body: Body | None = None,
|
|
209
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
210
|
+
) -> FileUploadResponse:
|
|
211
|
+
"""
|
|
212
|
+
Upload File
|
|
213
|
+
|
|
214
|
+
Args:
|
|
215
|
+
extra_headers: Send extra headers
|
|
216
|
+
|
|
217
|
+
extra_query: Add additional query parameters to the request
|
|
218
|
+
|
|
219
|
+
extra_body: Add additional JSON properties to the request
|
|
220
|
+
|
|
221
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
222
|
+
"""
|
|
223
|
+
body = deepcopy_minimal({"file": file})
|
|
224
|
+
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
|
|
225
|
+
# It should be noted that the actual Content-Type header that will be
|
|
226
|
+
# sent to the server will contain a `boundary` parameter, e.g.
|
|
227
|
+
# multipart/form-data; boundary=---abc--
|
|
228
|
+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
|
|
229
|
+
return self._post(
|
|
230
|
+
"/v1/files",
|
|
231
|
+
body=maybe_transform(body, file_upload_params.FileUploadParams),
|
|
232
|
+
files=files,
|
|
233
|
+
options=make_request_options(
|
|
234
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
235
|
+
),
|
|
236
|
+
cast_to=FileUploadResponse,
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
def usage(
|
|
240
|
+
self,
|
|
241
|
+
*,
|
|
242
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
243
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
244
|
+
extra_headers: Headers | None = None,
|
|
245
|
+
extra_query: Query | None = None,
|
|
246
|
+
extra_body: Body | None = None,
|
|
247
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
248
|
+
) -> object:
|
|
249
|
+
"""Get Usage"""
|
|
250
|
+
return self._get(
|
|
251
|
+
"/v1/files:usage",
|
|
252
|
+
options=make_request_options(
|
|
253
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
254
|
+
),
|
|
255
|
+
cast_to=object,
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
class AsyncFilesResource(AsyncAPIResource):
|
|
260
|
+
@cached_property
|
|
261
|
+
def with_raw_response(self) -> AsyncFilesResourceWithRawResponse:
|
|
262
|
+
"""
|
|
263
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
264
|
+
the raw response object instead of the parsed content.
|
|
265
|
+
|
|
266
|
+
For more information, see https://www.github.com/spi-tch/spitch-python#accessing-raw-response-data-eg-headers
|
|
267
|
+
"""
|
|
268
|
+
return AsyncFilesResourceWithRawResponse(self)
|
|
269
|
+
|
|
270
|
+
@cached_property
|
|
271
|
+
def with_streaming_response(self) -> AsyncFilesResourceWithStreamingResponse:
|
|
272
|
+
"""
|
|
273
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
274
|
+
|
|
275
|
+
For more information, see https://www.github.com/spi-tch/spitch-python#with_streaming_response
|
|
276
|
+
"""
|
|
277
|
+
return AsyncFilesResourceWithStreamingResponse(self)
|
|
278
|
+
|
|
279
|
+
def list(
|
|
280
|
+
self,
|
|
281
|
+
*,
|
|
282
|
+
cursor: Optional[str] | Omit = omit,
|
|
283
|
+
limit: int | Omit = omit,
|
|
284
|
+
status: Optional[Literal["uploading", "ready"]] | Omit = omit,
|
|
285
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
286
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
287
|
+
extra_headers: Headers | None = None,
|
|
288
|
+
extra_query: Query | None = None,
|
|
289
|
+
extra_body: Body | None = None,
|
|
290
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
291
|
+
) -> AsyncPaginator[FileListResponse, AsyncFilesCursor[FileListResponse]]:
|
|
292
|
+
"""
|
|
293
|
+
Get Files
|
|
294
|
+
|
|
295
|
+
Args:
|
|
296
|
+
extra_headers: Send extra headers
|
|
297
|
+
|
|
298
|
+
extra_query: Add additional query parameters to the request
|
|
299
|
+
|
|
300
|
+
extra_body: Add additional JSON properties to the request
|
|
301
|
+
|
|
302
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
303
|
+
"""
|
|
304
|
+
return self._get_api_list(
|
|
305
|
+
"/v1/files",
|
|
306
|
+
page=AsyncFilesCursor[FileListResponse],
|
|
307
|
+
options=make_request_options(
|
|
308
|
+
extra_headers=extra_headers,
|
|
309
|
+
extra_query=extra_query,
|
|
310
|
+
extra_body=extra_body,
|
|
311
|
+
timeout=timeout,
|
|
312
|
+
query=maybe_transform(
|
|
313
|
+
{
|
|
314
|
+
"cursor": cursor,
|
|
315
|
+
"limit": limit,
|
|
316
|
+
"status": status,
|
|
317
|
+
},
|
|
318
|
+
file_list_params.FileListParams,
|
|
319
|
+
),
|
|
320
|
+
),
|
|
321
|
+
model=FileListResponse,
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
async def delete(
|
|
325
|
+
self,
|
|
326
|
+
file_id: str,
|
|
327
|
+
*,
|
|
328
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
329
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
330
|
+
extra_headers: Headers | None = None,
|
|
331
|
+
extra_query: Query | None = None,
|
|
332
|
+
extra_body: Body | None = None,
|
|
333
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
334
|
+
) -> FileDeleteResponse:
|
|
335
|
+
"""
|
|
336
|
+
Delete File
|
|
337
|
+
|
|
338
|
+
Args:
|
|
339
|
+
extra_headers: Send extra headers
|
|
340
|
+
|
|
341
|
+
extra_query: Add additional query parameters to the request
|
|
342
|
+
|
|
343
|
+
extra_body: Add additional JSON properties to the request
|
|
344
|
+
|
|
345
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
346
|
+
"""
|
|
347
|
+
if not file_id:
|
|
348
|
+
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
|
|
349
|
+
return await self._delete(
|
|
350
|
+
f"/v1/files/{file_id}",
|
|
351
|
+
options=make_request_options(
|
|
352
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
353
|
+
),
|
|
354
|
+
cast_to=FileDeleteResponse,
|
|
355
|
+
)
|
|
356
|
+
|
|
357
|
+
async def download(
|
|
358
|
+
self,
|
|
359
|
+
file_id: str,
|
|
360
|
+
*,
|
|
361
|
+
ttl: int | Omit = omit,
|
|
362
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
363
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
364
|
+
extra_headers: Headers | None = None,
|
|
365
|
+
extra_query: Query | None = None,
|
|
366
|
+
extra_body: Body | None = None,
|
|
367
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
368
|
+
) -> object:
|
|
369
|
+
"""
|
|
370
|
+
Download File
|
|
371
|
+
|
|
372
|
+
Args:
|
|
373
|
+
extra_headers: Send extra headers
|
|
374
|
+
|
|
375
|
+
extra_query: Add additional query parameters to the request
|
|
376
|
+
|
|
377
|
+
extra_body: Add additional JSON properties to the request
|
|
378
|
+
|
|
379
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
380
|
+
"""
|
|
381
|
+
if not file_id:
|
|
382
|
+
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
|
|
383
|
+
return await self._get(
|
|
384
|
+
f"/v1/files/{file_id}/url",
|
|
385
|
+
options=make_request_options(
|
|
386
|
+
extra_headers=extra_headers,
|
|
387
|
+
extra_query=extra_query,
|
|
388
|
+
extra_body=extra_body,
|
|
389
|
+
timeout=timeout,
|
|
390
|
+
query=await async_maybe_transform({"ttl": ttl}, file_download_params.FileDownloadParams),
|
|
391
|
+
),
|
|
392
|
+
cast_to=object,
|
|
393
|
+
)
|
|
394
|
+
|
|
395
|
+
async def get(
|
|
396
|
+
self,
|
|
397
|
+
file_id: str,
|
|
398
|
+
*,
|
|
399
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
400
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
401
|
+
extra_headers: Headers | None = None,
|
|
402
|
+
extra_query: Query | None = None,
|
|
403
|
+
extra_body: Body | None = None,
|
|
404
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
405
|
+
) -> FileGetResponse:
|
|
406
|
+
"""
|
|
407
|
+
Get File
|
|
408
|
+
|
|
409
|
+
Args:
|
|
410
|
+
extra_headers: Send extra headers
|
|
411
|
+
|
|
412
|
+
extra_query: Add additional query parameters to the request
|
|
413
|
+
|
|
414
|
+
extra_body: Add additional JSON properties to the request
|
|
415
|
+
|
|
416
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
417
|
+
"""
|
|
418
|
+
if not file_id:
|
|
419
|
+
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
|
|
420
|
+
return await self._get(
|
|
421
|
+
f"/v1/files/{file_id}",
|
|
422
|
+
options=make_request_options(
|
|
423
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
424
|
+
),
|
|
425
|
+
cast_to=FileGetResponse,
|
|
426
|
+
)
|
|
427
|
+
|
|
428
|
+
async def upload(
|
|
429
|
+
self,
|
|
430
|
+
*,
|
|
431
|
+
file: FileTypes,
|
|
432
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
433
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
434
|
+
extra_headers: Headers | None = None,
|
|
435
|
+
extra_query: Query | None = None,
|
|
436
|
+
extra_body: Body | None = None,
|
|
437
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
438
|
+
) -> FileUploadResponse:
|
|
439
|
+
"""
|
|
440
|
+
Upload File
|
|
441
|
+
|
|
442
|
+
Args:
|
|
443
|
+
extra_headers: Send extra headers
|
|
444
|
+
|
|
445
|
+
extra_query: Add additional query parameters to the request
|
|
446
|
+
|
|
447
|
+
extra_body: Add additional JSON properties to the request
|
|
448
|
+
|
|
449
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
450
|
+
"""
|
|
451
|
+
body = deepcopy_minimal({"file": file})
|
|
452
|
+
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
|
|
453
|
+
# It should be noted that the actual Content-Type header that will be
|
|
454
|
+
# sent to the server will contain a `boundary` parameter, e.g.
|
|
455
|
+
# multipart/form-data; boundary=---abc--
|
|
456
|
+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
|
|
457
|
+
return await self._post(
|
|
458
|
+
"/v1/files",
|
|
459
|
+
body=await async_maybe_transform(body, file_upload_params.FileUploadParams),
|
|
460
|
+
files=files,
|
|
461
|
+
options=make_request_options(
|
|
462
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
463
|
+
),
|
|
464
|
+
cast_to=FileUploadResponse,
|
|
465
|
+
)
|
|
466
|
+
|
|
467
|
+
async def usage(
|
|
468
|
+
self,
|
|
469
|
+
*,
|
|
470
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
471
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
472
|
+
extra_headers: Headers | None = None,
|
|
473
|
+
extra_query: Query | None = None,
|
|
474
|
+
extra_body: Body | None = None,
|
|
475
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
476
|
+
) -> object:
|
|
477
|
+
"""Get Usage"""
|
|
478
|
+
return await self._get(
|
|
479
|
+
"/v1/files:usage",
|
|
480
|
+
options=make_request_options(
|
|
481
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
482
|
+
),
|
|
483
|
+
cast_to=object,
|
|
484
|
+
)
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
class FilesResourceWithRawResponse:
|
|
488
|
+
def __init__(self, files: FilesResource) -> None:
|
|
489
|
+
self._files = files
|
|
490
|
+
|
|
491
|
+
self.list = to_raw_response_wrapper(
|
|
492
|
+
files.list,
|
|
493
|
+
)
|
|
494
|
+
self.delete = to_raw_response_wrapper(
|
|
495
|
+
files.delete,
|
|
496
|
+
)
|
|
497
|
+
self.download = to_raw_response_wrapper(
|
|
498
|
+
files.download,
|
|
499
|
+
)
|
|
500
|
+
self.get = to_raw_response_wrapper(
|
|
501
|
+
files.get,
|
|
502
|
+
)
|
|
503
|
+
self.upload = to_raw_response_wrapper(
|
|
504
|
+
files.upload,
|
|
505
|
+
)
|
|
506
|
+
self.usage = to_raw_response_wrapper(
|
|
507
|
+
files.usage,
|
|
508
|
+
)
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
class AsyncFilesResourceWithRawResponse:
|
|
512
|
+
def __init__(self, files: AsyncFilesResource) -> None:
|
|
513
|
+
self._files = files
|
|
514
|
+
|
|
515
|
+
self.list = async_to_raw_response_wrapper(
|
|
516
|
+
files.list,
|
|
517
|
+
)
|
|
518
|
+
self.delete = async_to_raw_response_wrapper(
|
|
519
|
+
files.delete,
|
|
520
|
+
)
|
|
521
|
+
self.download = async_to_raw_response_wrapper(
|
|
522
|
+
files.download,
|
|
523
|
+
)
|
|
524
|
+
self.get = async_to_raw_response_wrapper(
|
|
525
|
+
files.get,
|
|
526
|
+
)
|
|
527
|
+
self.upload = async_to_raw_response_wrapper(
|
|
528
|
+
files.upload,
|
|
529
|
+
)
|
|
530
|
+
self.usage = async_to_raw_response_wrapper(
|
|
531
|
+
files.usage,
|
|
532
|
+
)
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
class FilesResourceWithStreamingResponse:
|
|
536
|
+
def __init__(self, files: FilesResource) -> None:
|
|
537
|
+
self._files = files
|
|
538
|
+
|
|
539
|
+
self.list = to_streamed_response_wrapper(
|
|
540
|
+
files.list,
|
|
541
|
+
)
|
|
542
|
+
self.delete = to_streamed_response_wrapper(
|
|
543
|
+
files.delete,
|
|
544
|
+
)
|
|
545
|
+
self.download = to_streamed_response_wrapper(
|
|
546
|
+
files.download,
|
|
547
|
+
)
|
|
548
|
+
self.get = to_streamed_response_wrapper(
|
|
549
|
+
files.get,
|
|
550
|
+
)
|
|
551
|
+
self.upload = to_streamed_response_wrapper(
|
|
552
|
+
files.upload,
|
|
553
|
+
)
|
|
554
|
+
self.usage = to_streamed_response_wrapper(
|
|
555
|
+
files.usage,
|
|
556
|
+
)
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
class AsyncFilesResourceWithStreamingResponse:
|
|
560
|
+
def __init__(self, files: AsyncFilesResource) -> None:
|
|
561
|
+
self._files = files
|
|
562
|
+
|
|
563
|
+
self.list = async_to_streamed_response_wrapper(
|
|
564
|
+
files.list,
|
|
565
|
+
)
|
|
566
|
+
self.delete = async_to_streamed_response_wrapper(
|
|
567
|
+
files.delete,
|
|
568
|
+
)
|
|
569
|
+
self.download = async_to_streamed_response_wrapper(
|
|
570
|
+
files.download,
|
|
571
|
+
)
|
|
572
|
+
self.get = async_to_streamed_response_wrapper(
|
|
573
|
+
files.get,
|
|
574
|
+
)
|
|
575
|
+
self.upload = async_to_streamed_response_wrapper(
|
|
576
|
+
files.upload,
|
|
577
|
+
)
|
|
578
|
+
self.usage = async_to_streamed_response_wrapper(
|
|
579
|
+
files.usage,
|
|
580
|
+
)
|
spitch/resources/speech.py
CHANGED
|
@@ -8,7 +8,7 @@ from typing_extensions import Literal
|
|
|
8
8
|
import httpx
|
|
9
9
|
|
|
10
10
|
from ..types import speech_generate_params, speech_transcribe_params
|
|
11
|
-
from .._types import
|
|
11
|
+
from .._types import Body, Omit, Query, Headers, NotGiven, FileTypes, omit, not_given
|
|
12
12
|
from .._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
|
|
13
13
|
from .._compat import cached_property
|
|
14
14
|
from .._resource import SyncAPIResource, AsyncAPIResource
|
|
@@ -81,13 +81,13 @@ class SpeechResource(SyncAPIResource):
|
|
|
81
81
|
"tena",
|
|
82
82
|
"tesfaye",
|
|
83
83
|
],
|
|
84
|
-
model: Optional[Literal["legacy"]] |
|
|
84
|
+
model: Optional[Literal["legacy"]] | Omit = omit,
|
|
85
85
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
86
86
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
87
87
|
extra_headers: Headers | None = None,
|
|
88
88
|
extra_query: Query | None = None,
|
|
89
89
|
extra_body: Body | None = None,
|
|
90
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
90
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
91
91
|
) -> BinaryAPIResponse:
|
|
92
92
|
"""
|
|
93
93
|
Synthesize
|
|
@@ -123,17 +123,17 @@ class SpeechResource(SyncAPIResource):
|
|
|
123
123
|
self,
|
|
124
124
|
*,
|
|
125
125
|
language: Literal["yo", "en", "ha", "ig", "am"],
|
|
126
|
-
content: Optional[FileTypes] |
|
|
127
|
-
model: Optional[Literal["mansa_v1", "legacy"]] |
|
|
128
|
-
special_words: Optional[str] |
|
|
129
|
-
timestamp: Optional[Literal["sentence", "word", "none"]] |
|
|
130
|
-
url: Optional[str] |
|
|
126
|
+
content: Optional[FileTypes] | Omit = omit,
|
|
127
|
+
model: Optional[Literal["mansa_v1", "legacy"]] | Omit = omit,
|
|
128
|
+
special_words: Optional[str] | Omit = omit,
|
|
129
|
+
timestamp: Optional[Literal["sentence", "word", "none"]] | Omit = omit,
|
|
130
|
+
url: Optional[str] | Omit = omit,
|
|
131
131
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
132
132
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
133
133
|
extra_headers: Headers | None = None,
|
|
134
134
|
extra_query: Query | None = None,
|
|
135
135
|
extra_body: Body | None = None,
|
|
136
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
136
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
137
137
|
) -> SpeechTranscribeResponse:
|
|
138
138
|
"""
|
|
139
139
|
Transcribe
|
|
@@ -222,13 +222,13 @@ class AsyncSpeechResource(AsyncAPIResource):
|
|
|
222
222
|
"tena",
|
|
223
223
|
"tesfaye",
|
|
224
224
|
],
|
|
225
|
-
model: Optional[Literal["legacy"]] |
|
|
225
|
+
model: Optional[Literal["legacy"]] | Omit = omit,
|
|
226
226
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
227
227
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
228
228
|
extra_headers: Headers | None = None,
|
|
229
229
|
extra_query: Query | None = None,
|
|
230
230
|
extra_body: Body | None = None,
|
|
231
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
231
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
232
232
|
) -> AsyncBinaryAPIResponse:
|
|
233
233
|
"""
|
|
234
234
|
Synthesize
|
|
@@ -264,17 +264,17 @@ class AsyncSpeechResource(AsyncAPIResource):
|
|
|
264
264
|
self,
|
|
265
265
|
*,
|
|
266
266
|
language: Literal["yo", "en", "ha", "ig", "am"],
|
|
267
|
-
content: Optional[FileTypes] |
|
|
268
|
-
model: Optional[Literal["mansa_v1", "legacy"]] |
|
|
269
|
-
special_words: Optional[str] |
|
|
270
|
-
timestamp: Optional[Literal["sentence", "word", "none"]] |
|
|
271
|
-
url: Optional[str] |
|
|
267
|
+
content: Optional[FileTypes] | Omit = omit,
|
|
268
|
+
model: Optional[Literal["mansa_v1", "legacy"]] | Omit = omit,
|
|
269
|
+
special_words: Optional[str] | Omit = omit,
|
|
270
|
+
timestamp: Optional[Literal["sentence", "word", "none"]] | Omit = omit,
|
|
271
|
+
url: Optional[str] | Omit = omit,
|
|
272
272
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
273
273
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
274
274
|
extra_headers: Headers | None = None,
|
|
275
275
|
extra_query: Query | None = None,
|
|
276
276
|
extra_body: Body | None = None,
|
|
277
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
277
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
278
278
|
) -> SpeechTranscribeResponse:
|
|
279
279
|
"""
|
|
280
280
|
Transcribe
|