vellum-ai 1.1.0__py3-none-any.whl → 1.1.2__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.
- vellum/client/README.md +0 -55
- vellum/client/__init__.py +159 -873
- vellum/client/core/__init__.py +3 -0
- vellum/client/core/client_wrapper.py +2 -2
- vellum/client/core/http_response.py +47 -0
- vellum/client/core/pydantic_utilities.py +10 -3
- vellum/client/raw_client.py +1561 -0
- vellum/client/reference.md +20 -693
- vellum/client/resources/ad_hoc/client.py +55 -161
- vellum/client/resources/ad_hoc/raw_client.py +278 -0
- vellum/client/resources/container_images/client.py +62 -172
- vellum/client/resources/container_images/raw_client.py +400 -0
- vellum/client/resources/deployments/client.py +112 -437
- vellum/client/resources/deployments/raw_client.py +995 -0
- vellum/client/resources/document_indexes/client.py +108 -317
- vellum/client/resources/document_indexes/raw_client.py +847 -0
- vellum/client/resources/documents/client.py +88 -285
- vellum/client/resources/documents/raw_client.py +655 -0
- vellum/client/resources/folder_entities/client.py +54 -92
- vellum/client/resources/folder_entities/raw_client.py +277 -0
- vellum/client/resources/metric_definitions/client.py +48 -95
- vellum/client/resources/metric_definitions/raw_client.py +225 -0
- vellum/client/resources/ml_models/client.py +36 -40
- vellum/client/resources/ml_models/raw_client.py +103 -0
- vellum/client/resources/organizations/client.py +34 -39
- vellum/client/resources/organizations/raw_client.py +96 -0
- vellum/client/resources/prompts/client.py +50 -193
- vellum/client/resources/prompts/raw_client.py +346 -0
- vellum/client/resources/sandboxes/client.py +68 -141
- vellum/client/resources/sandboxes/raw_client.py +393 -0
- vellum/client/resources/test_suite_runs/client.py +58 -141
- vellum/client/resources/test_suite_runs/raw_client.py +355 -0
- vellum/client/resources/test_suites/client.py +73 -141
- vellum/client/resources/test_suites/raw_client.py +379 -0
- vellum/client/resources/workflow_deployments/client.py +118 -362
- vellum/client/resources/workflow_deployments/raw_client.py +931 -0
- vellum/client/resources/workflow_executions/client.py +36 -40
- vellum/client/resources/workflow_executions/raw_client.py +97 -0
- vellum/client/resources/workflow_sandboxes/client.py +60 -108
- vellum/client/resources/workflow_sandboxes/raw_client.py +300 -0
- vellum/client/resources/workflows/client.py +68 -133
- vellum/client/resources/workflows/raw_client.py +307 -0
- vellum/client/resources/workspace_secrets/client.py +46 -90
- vellum/client/resources/workspace_secrets/raw_client.py +220 -0
- vellum/client/resources/workspaces/client.py +34 -39
- vellum/client/resources/workspaces/raw_client.py +96 -0
- vellum/core/http_response.py +3 -0
- vellum/raw_client.py +3 -0
- vellum/resources/ad_hoc/raw_client.py +3 -0
- vellum/resources/container_images/raw_client.py +3 -0
- vellum/resources/deployments/raw_client.py +3 -0
- vellum/resources/document_indexes/raw_client.py +3 -0
- vellum/resources/documents/raw_client.py +3 -0
- vellum/resources/folder_entities/raw_client.py +3 -0
- vellum/resources/metric_definitions/raw_client.py +3 -0
- vellum/resources/ml_models/raw_client.py +3 -0
- vellum/resources/organizations/raw_client.py +3 -0
- vellum/resources/prompts/raw_client.py +3 -0
- vellum/resources/sandboxes/raw_client.py +3 -0
- vellum/resources/test_suite_runs/raw_client.py +3 -0
- vellum/resources/test_suites/raw_client.py +3 -0
- vellum/resources/workflow_deployments/raw_client.py +3 -0
- vellum/resources/workflow_executions/raw_client.py +3 -0
- vellum/resources/workflow_sandboxes/raw_client.py +3 -0
- vellum/resources/workflows/raw_client.py +3 -0
- vellum/resources/workspace_secrets/raw_client.py +3 -0
- vellum/resources/workspaces/raw_client.py +3 -0
- {vellum_ai-1.1.0.dist-info → vellum_ai-1.1.2.dist-info}/METADATA +1 -1
- {vellum_ai-1.1.0.dist-info → vellum_ai-1.1.2.dist-info}/RECORD +76 -33
- vellum_ee/workflows/display/exceptions.py +7 -0
- vellum_ee/workflows/display/nodes/vellum/code_execution_node.py +2 -1
- vellum_ee/workflows/display/nodes/vellum/tests/test_code_execution_node.py +53 -2
- vellum_ee/workflows/display/workflows/base_workflow_display.py +2 -1
- {vellum_ai-1.1.0.dist-info → vellum_ai-1.1.2.dist-info}/LICENSE +0 -0
- {vellum_ai-1.1.0.dist-info → vellum_ai-1.1.2.dist-info}/WHEEL +0 -0
- {vellum_ai-1.1.0.dist-info → vellum_ai-1.1.2.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,655 @@
|
|
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 ...core.http_response import HttpResponse
|
7
|
+
from ...types.paginated_slim_document_list import PaginatedSlimDocumentList
|
8
|
+
from ...core.pydantic_utilities import parse_obj_as
|
9
|
+
from json.decoder import JSONDecodeError
|
10
|
+
from ...core.api_error import ApiError
|
11
|
+
from ...types.document_read import DocumentRead
|
12
|
+
from ...core.jsonable_encoder import jsonable_encoder
|
13
|
+
from ...types.document_status import DocumentStatus
|
14
|
+
from ... import core
|
15
|
+
from ...types.upload_document_response import UploadDocumentResponse
|
16
|
+
from ...errors.bad_request_error import BadRequestError
|
17
|
+
from ...errors.not_found_error import NotFoundError
|
18
|
+
from ...errors.internal_server_error import InternalServerError
|
19
|
+
from ...core.client_wrapper import AsyncClientWrapper
|
20
|
+
from ...core.http_response import AsyncHttpResponse
|
21
|
+
|
22
|
+
# this is used as the default value for optional parameters
|
23
|
+
OMIT = typing.cast(typing.Any, ...)
|
24
|
+
|
25
|
+
|
26
|
+
class RawDocumentsClient:
|
27
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
28
|
+
self._client_wrapper = client_wrapper
|
29
|
+
|
30
|
+
def list(
|
31
|
+
self,
|
32
|
+
*,
|
33
|
+
document_index_id: typing.Optional[str] = None,
|
34
|
+
limit: typing.Optional[int] = None,
|
35
|
+
offset: typing.Optional[int] = None,
|
36
|
+
ordering: typing.Optional[str] = None,
|
37
|
+
search: typing.Optional[str] = None,
|
38
|
+
request_options: typing.Optional[RequestOptions] = None,
|
39
|
+
) -> HttpResponse[PaginatedSlimDocumentList]:
|
40
|
+
"""
|
41
|
+
Used to list documents. Optionally filter on supported fields.
|
42
|
+
|
43
|
+
Parameters
|
44
|
+
----------
|
45
|
+
document_index_id : typing.Optional[str]
|
46
|
+
Filter down to only those documents that are included in the specified index. You may provide either the Vellum-generated ID or the unique name of the index specified upon initial creation.
|
47
|
+
|
48
|
+
limit : typing.Optional[int]
|
49
|
+
Number of results to return per page.
|
50
|
+
|
51
|
+
offset : typing.Optional[int]
|
52
|
+
The initial index from which to return the results.
|
53
|
+
|
54
|
+
ordering : typing.Optional[str]
|
55
|
+
Which field to use when ordering the results.
|
56
|
+
|
57
|
+
search : typing.Optional[str]
|
58
|
+
A search term.
|
59
|
+
|
60
|
+
request_options : typing.Optional[RequestOptions]
|
61
|
+
Request-specific configuration.
|
62
|
+
|
63
|
+
Returns
|
64
|
+
-------
|
65
|
+
HttpResponse[PaginatedSlimDocumentList]
|
66
|
+
|
67
|
+
"""
|
68
|
+
_response = self._client_wrapper.httpx_client.request(
|
69
|
+
"v1/documents",
|
70
|
+
base_url=self._client_wrapper.get_environment().default,
|
71
|
+
method="GET",
|
72
|
+
params={
|
73
|
+
"document_index_id": document_index_id,
|
74
|
+
"limit": limit,
|
75
|
+
"offset": offset,
|
76
|
+
"ordering": ordering,
|
77
|
+
"search": search,
|
78
|
+
},
|
79
|
+
request_options=request_options,
|
80
|
+
)
|
81
|
+
try:
|
82
|
+
if 200 <= _response.status_code < 300:
|
83
|
+
_data = typing.cast(
|
84
|
+
PaginatedSlimDocumentList,
|
85
|
+
parse_obj_as(
|
86
|
+
type_=PaginatedSlimDocumentList, # type: ignore
|
87
|
+
object_=_response.json(),
|
88
|
+
),
|
89
|
+
)
|
90
|
+
return HttpResponse(response=_response, data=_data)
|
91
|
+
_response_json = _response.json()
|
92
|
+
except JSONDecodeError:
|
93
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
94
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
95
|
+
|
96
|
+
def retrieve(
|
97
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
98
|
+
) -> HttpResponse[DocumentRead]:
|
99
|
+
"""
|
100
|
+
Retrieve a Document, keying off of either its Vellum-generated ID or its external ID.
|
101
|
+
|
102
|
+
Parameters
|
103
|
+
----------
|
104
|
+
id : str
|
105
|
+
|
106
|
+
request_options : typing.Optional[RequestOptions]
|
107
|
+
Request-specific configuration.
|
108
|
+
|
109
|
+
Returns
|
110
|
+
-------
|
111
|
+
HttpResponse[DocumentRead]
|
112
|
+
|
113
|
+
"""
|
114
|
+
_response = self._client_wrapper.httpx_client.request(
|
115
|
+
f"v1/documents/{jsonable_encoder(id)}",
|
116
|
+
base_url=self._client_wrapper.get_environment().default,
|
117
|
+
method="GET",
|
118
|
+
request_options=request_options,
|
119
|
+
)
|
120
|
+
try:
|
121
|
+
if 200 <= _response.status_code < 300:
|
122
|
+
_data = typing.cast(
|
123
|
+
DocumentRead,
|
124
|
+
parse_obj_as(
|
125
|
+
type_=DocumentRead, # type: ignore
|
126
|
+
object_=_response.json(),
|
127
|
+
),
|
128
|
+
)
|
129
|
+
return HttpResponse(response=_response, data=_data)
|
130
|
+
_response_json = _response.json()
|
131
|
+
except JSONDecodeError:
|
132
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
133
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
134
|
+
|
135
|
+
def destroy(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]:
|
136
|
+
"""
|
137
|
+
Delete a Document, keying off of either its Vellum-generated ID or its external ID.
|
138
|
+
|
139
|
+
Parameters
|
140
|
+
----------
|
141
|
+
id : str
|
142
|
+
|
143
|
+
request_options : typing.Optional[RequestOptions]
|
144
|
+
Request-specific configuration.
|
145
|
+
|
146
|
+
Returns
|
147
|
+
-------
|
148
|
+
HttpResponse[None]
|
149
|
+
"""
|
150
|
+
_response = self._client_wrapper.httpx_client.request(
|
151
|
+
f"v1/documents/{jsonable_encoder(id)}",
|
152
|
+
base_url=self._client_wrapper.get_environment().documents,
|
153
|
+
method="DELETE",
|
154
|
+
request_options=request_options,
|
155
|
+
)
|
156
|
+
try:
|
157
|
+
if 200 <= _response.status_code < 300:
|
158
|
+
return HttpResponse(response=_response, data=None)
|
159
|
+
_response_json = _response.json()
|
160
|
+
except JSONDecodeError:
|
161
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
162
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
163
|
+
|
164
|
+
def partial_update(
|
165
|
+
self,
|
166
|
+
id: str,
|
167
|
+
*,
|
168
|
+
label: typing.Optional[str] = OMIT,
|
169
|
+
status: typing.Optional[DocumentStatus] = OMIT,
|
170
|
+
keywords: typing.Optional[typing.Sequence[str]] = OMIT,
|
171
|
+
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
172
|
+
request_options: typing.Optional[RequestOptions] = None,
|
173
|
+
) -> HttpResponse[DocumentRead]:
|
174
|
+
"""
|
175
|
+
Update a Document, keying off of either its Vellum-generated ID or its external ID. Particularly useful for updating its metadata.
|
176
|
+
|
177
|
+
Parameters
|
178
|
+
----------
|
179
|
+
id : str
|
180
|
+
|
181
|
+
label : typing.Optional[str]
|
182
|
+
A human-readable label for the document. Defaults to the originally uploaded file's file name.
|
183
|
+
|
184
|
+
status : typing.Optional[DocumentStatus]
|
185
|
+
The current status of the document
|
186
|
+
|
187
|
+
* `ACTIVE` - Active
|
188
|
+
|
189
|
+
keywords : typing.Optional[typing.Sequence[str]]
|
190
|
+
A list of keywords that'll be associated with the document. Used as part of keyword search.
|
191
|
+
|
192
|
+
metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
193
|
+
A JSON object containing any metadata associated with the document that you'd like to filter upon later.
|
194
|
+
|
195
|
+
request_options : typing.Optional[RequestOptions]
|
196
|
+
Request-specific configuration.
|
197
|
+
|
198
|
+
Returns
|
199
|
+
-------
|
200
|
+
HttpResponse[DocumentRead]
|
201
|
+
|
202
|
+
"""
|
203
|
+
_response = self._client_wrapper.httpx_client.request(
|
204
|
+
f"v1/documents/{jsonable_encoder(id)}",
|
205
|
+
base_url=self._client_wrapper.get_environment().default,
|
206
|
+
method="PATCH",
|
207
|
+
json={
|
208
|
+
"label": label,
|
209
|
+
"status": status,
|
210
|
+
"keywords": keywords,
|
211
|
+
"metadata": metadata,
|
212
|
+
},
|
213
|
+
headers={
|
214
|
+
"content-type": "application/json",
|
215
|
+
},
|
216
|
+
request_options=request_options,
|
217
|
+
omit=OMIT,
|
218
|
+
)
|
219
|
+
try:
|
220
|
+
if 200 <= _response.status_code < 300:
|
221
|
+
_data = typing.cast(
|
222
|
+
DocumentRead,
|
223
|
+
parse_obj_as(
|
224
|
+
type_=DocumentRead, # type: ignore
|
225
|
+
object_=_response.json(),
|
226
|
+
),
|
227
|
+
)
|
228
|
+
return HttpResponse(response=_response, data=_data)
|
229
|
+
_response_json = _response.json()
|
230
|
+
except JSONDecodeError:
|
231
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
232
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
233
|
+
|
234
|
+
def upload(
|
235
|
+
self,
|
236
|
+
*,
|
237
|
+
label: str,
|
238
|
+
contents: core.File,
|
239
|
+
add_to_index_names: typing.Optional[typing.List[str]] = OMIT,
|
240
|
+
external_id: typing.Optional[str] = OMIT,
|
241
|
+
keywords: typing.Optional[typing.List[str]] = OMIT,
|
242
|
+
metadata: typing.Optional[str] = OMIT,
|
243
|
+
request_options: typing.Optional[RequestOptions] = None,
|
244
|
+
) -> HttpResponse[UploadDocumentResponse]:
|
245
|
+
"""
|
246
|
+
Upload a document to be indexed and used for search.
|
247
|
+
|
248
|
+
**Note:** Uses a base url of `https://documents.vellum.ai`.
|
249
|
+
|
250
|
+
Parameters
|
251
|
+
----------
|
252
|
+
label : str
|
253
|
+
A human-friendly name for this document. Typically the filename.
|
254
|
+
|
255
|
+
contents : core.File
|
256
|
+
See core.File for more documentation
|
257
|
+
|
258
|
+
add_to_index_names : typing.Optional[typing.List[str]]
|
259
|
+
Optionally include the names of all indexes that you'd like this document to be included in
|
260
|
+
|
261
|
+
external_id : typing.Optional[str]
|
262
|
+
Optionally include an external ID for this document. This is useful if you want to re-upload the same document later when its contents change and would like it to be re-indexed.
|
263
|
+
|
264
|
+
keywords : typing.Optional[typing.List[str]]
|
265
|
+
Optionally include a list of keywords that'll be associated with this document. Used when performing keyword searches.
|
266
|
+
|
267
|
+
metadata : typing.Optional[str]
|
268
|
+
A stringified JSON object containing any metadata associated with the document that you'd like to filter upon later.
|
269
|
+
|
270
|
+
request_options : typing.Optional[RequestOptions]
|
271
|
+
Request-specific configuration.
|
272
|
+
|
273
|
+
Returns
|
274
|
+
-------
|
275
|
+
HttpResponse[UploadDocumentResponse]
|
276
|
+
|
277
|
+
"""
|
278
|
+
_response = self._client_wrapper.httpx_client.request(
|
279
|
+
"v1/upload-document",
|
280
|
+
base_url=self._client_wrapper.get_environment().documents,
|
281
|
+
method="POST",
|
282
|
+
data={
|
283
|
+
"add_to_index_names": add_to_index_names,
|
284
|
+
"external_id": external_id,
|
285
|
+
"label": label,
|
286
|
+
"keywords": keywords,
|
287
|
+
"metadata": metadata,
|
288
|
+
},
|
289
|
+
files={
|
290
|
+
"contents": contents,
|
291
|
+
},
|
292
|
+
request_options=request_options,
|
293
|
+
omit=OMIT,
|
294
|
+
)
|
295
|
+
try:
|
296
|
+
if 200 <= _response.status_code < 300:
|
297
|
+
_data = typing.cast(
|
298
|
+
UploadDocumentResponse,
|
299
|
+
parse_obj_as(
|
300
|
+
type_=UploadDocumentResponse, # type: ignore
|
301
|
+
object_=_response.json(),
|
302
|
+
),
|
303
|
+
)
|
304
|
+
return HttpResponse(response=_response, data=_data)
|
305
|
+
if _response.status_code == 400:
|
306
|
+
raise BadRequestError(
|
307
|
+
typing.cast(
|
308
|
+
typing.Optional[typing.Any],
|
309
|
+
parse_obj_as(
|
310
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
311
|
+
object_=_response.json(),
|
312
|
+
),
|
313
|
+
)
|
314
|
+
)
|
315
|
+
if _response.status_code == 404:
|
316
|
+
raise NotFoundError(
|
317
|
+
typing.cast(
|
318
|
+
typing.Optional[typing.Any],
|
319
|
+
parse_obj_as(
|
320
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
321
|
+
object_=_response.json(),
|
322
|
+
),
|
323
|
+
)
|
324
|
+
)
|
325
|
+
if _response.status_code == 500:
|
326
|
+
raise InternalServerError(
|
327
|
+
typing.cast(
|
328
|
+
typing.Optional[typing.Any],
|
329
|
+
parse_obj_as(
|
330
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
331
|
+
object_=_response.json(),
|
332
|
+
),
|
333
|
+
)
|
334
|
+
)
|
335
|
+
_response_json = _response.json()
|
336
|
+
except JSONDecodeError:
|
337
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
338
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
339
|
+
|
340
|
+
|
341
|
+
class AsyncRawDocumentsClient:
|
342
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
343
|
+
self._client_wrapper = client_wrapper
|
344
|
+
|
345
|
+
async def list(
|
346
|
+
self,
|
347
|
+
*,
|
348
|
+
document_index_id: typing.Optional[str] = None,
|
349
|
+
limit: typing.Optional[int] = None,
|
350
|
+
offset: typing.Optional[int] = None,
|
351
|
+
ordering: typing.Optional[str] = None,
|
352
|
+
search: typing.Optional[str] = None,
|
353
|
+
request_options: typing.Optional[RequestOptions] = None,
|
354
|
+
) -> AsyncHttpResponse[PaginatedSlimDocumentList]:
|
355
|
+
"""
|
356
|
+
Used to list documents. Optionally filter on supported fields.
|
357
|
+
|
358
|
+
Parameters
|
359
|
+
----------
|
360
|
+
document_index_id : typing.Optional[str]
|
361
|
+
Filter down to only those documents that are included in the specified index. You may provide either the Vellum-generated ID or the unique name of the index specified upon initial creation.
|
362
|
+
|
363
|
+
limit : typing.Optional[int]
|
364
|
+
Number of results to return per page.
|
365
|
+
|
366
|
+
offset : typing.Optional[int]
|
367
|
+
The initial index from which to return the results.
|
368
|
+
|
369
|
+
ordering : typing.Optional[str]
|
370
|
+
Which field to use when ordering the results.
|
371
|
+
|
372
|
+
search : typing.Optional[str]
|
373
|
+
A search term.
|
374
|
+
|
375
|
+
request_options : typing.Optional[RequestOptions]
|
376
|
+
Request-specific configuration.
|
377
|
+
|
378
|
+
Returns
|
379
|
+
-------
|
380
|
+
AsyncHttpResponse[PaginatedSlimDocumentList]
|
381
|
+
|
382
|
+
"""
|
383
|
+
_response = await self._client_wrapper.httpx_client.request(
|
384
|
+
"v1/documents",
|
385
|
+
base_url=self._client_wrapper.get_environment().default,
|
386
|
+
method="GET",
|
387
|
+
params={
|
388
|
+
"document_index_id": document_index_id,
|
389
|
+
"limit": limit,
|
390
|
+
"offset": offset,
|
391
|
+
"ordering": ordering,
|
392
|
+
"search": search,
|
393
|
+
},
|
394
|
+
request_options=request_options,
|
395
|
+
)
|
396
|
+
try:
|
397
|
+
if 200 <= _response.status_code < 300:
|
398
|
+
_data = typing.cast(
|
399
|
+
PaginatedSlimDocumentList,
|
400
|
+
parse_obj_as(
|
401
|
+
type_=PaginatedSlimDocumentList, # type: ignore
|
402
|
+
object_=_response.json(),
|
403
|
+
),
|
404
|
+
)
|
405
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
406
|
+
_response_json = _response.json()
|
407
|
+
except JSONDecodeError:
|
408
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
409
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
410
|
+
|
411
|
+
async def retrieve(
|
412
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
413
|
+
) -> AsyncHttpResponse[DocumentRead]:
|
414
|
+
"""
|
415
|
+
Retrieve a Document, keying off of either its Vellum-generated ID or its external ID.
|
416
|
+
|
417
|
+
Parameters
|
418
|
+
----------
|
419
|
+
id : str
|
420
|
+
|
421
|
+
request_options : typing.Optional[RequestOptions]
|
422
|
+
Request-specific configuration.
|
423
|
+
|
424
|
+
Returns
|
425
|
+
-------
|
426
|
+
AsyncHttpResponse[DocumentRead]
|
427
|
+
|
428
|
+
"""
|
429
|
+
_response = await self._client_wrapper.httpx_client.request(
|
430
|
+
f"v1/documents/{jsonable_encoder(id)}",
|
431
|
+
base_url=self._client_wrapper.get_environment().default,
|
432
|
+
method="GET",
|
433
|
+
request_options=request_options,
|
434
|
+
)
|
435
|
+
try:
|
436
|
+
if 200 <= _response.status_code < 300:
|
437
|
+
_data = typing.cast(
|
438
|
+
DocumentRead,
|
439
|
+
parse_obj_as(
|
440
|
+
type_=DocumentRead, # type: ignore
|
441
|
+
object_=_response.json(),
|
442
|
+
),
|
443
|
+
)
|
444
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
445
|
+
_response_json = _response.json()
|
446
|
+
except JSONDecodeError:
|
447
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
448
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
449
|
+
|
450
|
+
async def destroy(
|
451
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
452
|
+
) -> AsyncHttpResponse[None]:
|
453
|
+
"""
|
454
|
+
Delete a Document, keying off of either its Vellum-generated ID or its external ID.
|
455
|
+
|
456
|
+
Parameters
|
457
|
+
----------
|
458
|
+
id : str
|
459
|
+
|
460
|
+
request_options : typing.Optional[RequestOptions]
|
461
|
+
Request-specific configuration.
|
462
|
+
|
463
|
+
Returns
|
464
|
+
-------
|
465
|
+
AsyncHttpResponse[None]
|
466
|
+
"""
|
467
|
+
_response = await self._client_wrapper.httpx_client.request(
|
468
|
+
f"v1/documents/{jsonable_encoder(id)}",
|
469
|
+
base_url=self._client_wrapper.get_environment().documents,
|
470
|
+
method="DELETE",
|
471
|
+
request_options=request_options,
|
472
|
+
)
|
473
|
+
try:
|
474
|
+
if 200 <= _response.status_code < 300:
|
475
|
+
return AsyncHttpResponse(response=_response, data=None)
|
476
|
+
_response_json = _response.json()
|
477
|
+
except JSONDecodeError:
|
478
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
479
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
480
|
+
|
481
|
+
async def partial_update(
|
482
|
+
self,
|
483
|
+
id: str,
|
484
|
+
*,
|
485
|
+
label: typing.Optional[str] = OMIT,
|
486
|
+
status: typing.Optional[DocumentStatus] = OMIT,
|
487
|
+
keywords: typing.Optional[typing.Sequence[str]] = OMIT,
|
488
|
+
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
489
|
+
request_options: typing.Optional[RequestOptions] = None,
|
490
|
+
) -> AsyncHttpResponse[DocumentRead]:
|
491
|
+
"""
|
492
|
+
Update a Document, keying off of either its Vellum-generated ID or its external ID. Particularly useful for updating its metadata.
|
493
|
+
|
494
|
+
Parameters
|
495
|
+
----------
|
496
|
+
id : str
|
497
|
+
|
498
|
+
label : typing.Optional[str]
|
499
|
+
A human-readable label for the document. Defaults to the originally uploaded file's file name.
|
500
|
+
|
501
|
+
status : typing.Optional[DocumentStatus]
|
502
|
+
The current status of the document
|
503
|
+
|
504
|
+
* `ACTIVE` - Active
|
505
|
+
|
506
|
+
keywords : typing.Optional[typing.Sequence[str]]
|
507
|
+
A list of keywords that'll be associated with the document. Used as part of keyword search.
|
508
|
+
|
509
|
+
metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
510
|
+
A JSON object containing any metadata associated with the document that you'd like to filter upon later.
|
511
|
+
|
512
|
+
request_options : typing.Optional[RequestOptions]
|
513
|
+
Request-specific configuration.
|
514
|
+
|
515
|
+
Returns
|
516
|
+
-------
|
517
|
+
AsyncHttpResponse[DocumentRead]
|
518
|
+
|
519
|
+
"""
|
520
|
+
_response = await self._client_wrapper.httpx_client.request(
|
521
|
+
f"v1/documents/{jsonable_encoder(id)}",
|
522
|
+
base_url=self._client_wrapper.get_environment().default,
|
523
|
+
method="PATCH",
|
524
|
+
json={
|
525
|
+
"label": label,
|
526
|
+
"status": status,
|
527
|
+
"keywords": keywords,
|
528
|
+
"metadata": metadata,
|
529
|
+
},
|
530
|
+
headers={
|
531
|
+
"content-type": "application/json",
|
532
|
+
},
|
533
|
+
request_options=request_options,
|
534
|
+
omit=OMIT,
|
535
|
+
)
|
536
|
+
try:
|
537
|
+
if 200 <= _response.status_code < 300:
|
538
|
+
_data = typing.cast(
|
539
|
+
DocumentRead,
|
540
|
+
parse_obj_as(
|
541
|
+
type_=DocumentRead, # type: ignore
|
542
|
+
object_=_response.json(),
|
543
|
+
),
|
544
|
+
)
|
545
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
546
|
+
_response_json = _response.json()
|
547
|
+
except JSONDecodeError:
|
548
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
549
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
550
|
+
|
551
|
+
async def upload(
|
552
|
+
self,
|
553
|
+
*,
|
554
|
+
label: str,
|
555
|
+
contents: core.File,
|
556
|
+
add_to_index_names: typing.Optional[typing.List[str]] = OMIT,
|
557
|
+
external_id: typing.Optional[str] = OMIT,
|
558
|
+
keywords: typing.Optional[typing.List[str]] = OMIT,
|
559
|
+
metadata: typing.Optional[str] = OMIT,
|
560
|
+
request_options: typing.Optional[RequestOptions] = None,
|
561
|
+
) -> AsyncHttpResponse[UploadDocumentResponse]:
|
562
|
+
"""
|
563
|
+
Upload a document to be indexed and used for search.
|
564
|
+
|
565
|
+
**Note:** Uses a base url of `https://documents.vellum.ai`.
|
566
|
+
|
567
|
+
Parameters
|
568
|
+
----------
|
569
|
+
label : str
|
570
|
+
A human-friendly name for this document. Typically the filename.
|
571
|
+
|
572
|
+
contents : core.File
|
573
|
+
See core.File for more documentation
|
574
|
+
|
575
|
+
add_to_index_names : typing.Optional[typing.List[str]]
|
576
|
+
Optionally include the names of all indexes that you'd like this document to be included in
|
577
|
+
|
578
|
+
external_id : typing.Optional[str]
|
579
|
+
Optionally include an external ID for this document. This is useful if you want to re-upload the same document later when its contents change and would like it to be re-indexed.
|
580
|
+
|
581
|
+
keywords : typing.Optional[typing.List[str]]
|
582
|
+
Optionally include a list of keywords that'll be associated with this document. Used when performing keyword searches.
|
583
|
+
|
584
|
+
metadata : typing.Optional[str]
|
585
|
+
A stringified JSON object containing any metadata associated with the document that you'd like to filter upon later.
|
586
|
+
|
587
|
+
request_options : typing.Optional[RequestOptions]
|
588
|
+
Request-specific configuration.
|
589
|
+
|
590
|
+
Returns
|
591
|
+
-------
|
592
|
+
AsyncHttpResponse[UploadDocumentResponse]
|
593
|
+
|
594
|
+
"""
|
595
|
+
_response = await self._client_wrapper.httpx_client.request(
|
596
|
+
"v1/upload-document",
|
597
|
+
base_url=self._client_wrapper.get_environment().documents,
|
598
|
+
method="POST",
|
599
|
+
data={
|
600
|
+
"add_to_index_names": add_to_index_names,
|
601
|
+
"external_id": external_id,
|
602
|
+
"label": label,
|
603
|
+
"keywords": keywords,
|
604
|
+
"metadata": metadata,
|
605
|
+
},
|
606
|
+
files={
|
607
|
+
"contents": contents,
|
608
|
+
},
|
609
|
+
request_options=request_options,
|
610
|
+
omit=OMIT,
|
611
|
+
)
|
612
|
+
try:
|
613
|
+
if 200 <= _response.status_code < 300:
|
614
|
+
_data = typing.cast(
|
615
|
+
UploadDocumentResponse,
|
616
|
+
parse_obj_as(
|
617
|
+
type_=UploadDocumentResponse, # type: ignore
|
618
|
+
object_=_response.json(),
|
619
|
+
),
|
620
|
+
)
|
621
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
622
|
+
if _response.status_code == 400:
|
623
|
+
raise BadRequestError(
|
624
|
+
typing.cast(
|
625
|
+
typing.Optional[typing.Any],
|
626
|
+
parse_obj_as(
|
627
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
628
|
+
object_=_response.json(),
|
629
|
+
),
|
630
|
+
)
|
631
|
+
)
|
632
|
+
if _response.status_code == 404:
|
633
|
+
raise NotFoundError(
|
634
|
+
typing.cast(
|
635
|
+
typing.Optional[typing.Any],
|
636
|
+
parse_obj_as(
|
637
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
638
|
+
object_=_response.json(),
|
639
|
+
),
|
640
|
+
)
|
641
|
+
)
|
642
|
+
if _response.status_code == 500:
|
643
|
+
raise InternalServerError(
|
644
|
+
typing.cast(
|
645
|
+
typing.Optional[typing.Any],
|
646
|
+
parse_obj_as(
|
647
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
648
|
+
object_=_response.json(),
|
649
|
+
),
|
650
|
+
)
|
651
|
+
)
|
652
|
+
_response_json = _response.json()
|
653
|
+
except JSONDecodeError:
|
654
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
655
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|