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