groundx 2.0.19__py3-none-any.whl → 2.0.21__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.
- groundx/__init__.py +6 -4
- groundx/core/client_wrapper.py +1 -1
- groundx/documents/client.py +273 -460
- groundx/types/__init__.py +6 -4
- groundx/types/document_local_ingest_request.py +6 -0
- groundx/types/ingest_local_document.py +5 -23
- groundx/types/{ingest_document.py → ingest_local_document_metadata.py} +6 -9
- groundx/types/{crawl_website_source.py → website_source.py} +1 -1
- {groundx-2.0.19.dist-info → groundx-2.0.21.dist-info}/METADATA +14 -16
- {groundx-2.0.19.dist-info → groundx-2.0.21.dist-info}/RECORD +12 -11
- {groundx-2.0.19.dist-info → groundx-2.0.21.dist-info}/LICENSE +0 -0
- {groundx-2.0.19.dist-info → groundx-2.0.21.dist-info}/WHEEL +0 -0
groundx/documents/client.py
CHANGED
@@ -2,22 +2,21 @@
|
|
2
2
|
|
3
3
|
import typing
|
4
4
|
from ..core.client_wrapper import SyncClientWrapper
|
5
|
-
from ..types.
|
6
|
-
from ..types.sort_order import SortOrder
|
7
|
-
from ..types.processing_status import ProcessingStatus
|
5
|
+
from ..types.ingest_remote_document import IngestRemoteDocument
|
8
6
|
from ..core.request_options import RequestOptions
|
9
|
-
from ..types.document_list_response import DocumentListResponse
|
10
|
-
from ..core.pydantic_utilities import parse_obj_as
|
11
|
-
from json.decoder import JSONDecodeError
|
12
|
-
from ..core.api_error import ApiError
|
13
|
-
from ..types.ingest_document import IngestDocument
|
14
7
|
from ..types.ingest_response import IngestResponse
|
15
8
|
from ..core.serialization import convert_and_respect_annotation_metadata
|
9
|
+
from ..core.pydantic_utilities import parse_obj_as
|
16
10
|
from ..errors.bad_request_error import BadRequestError
|
17
11
|
from ..errors.unauthorized_error import UnauthorizedError
|
18
|
-
from
|
19
|
-
from ..
|
20
|
-
from ..types.
|
12
|
+
from json.decoder import JSONDecodeError
|
13
|
+
from ..core.api_error import ApiError
|
14
|
+
from ..types.document_local_ingest_request import DocumentLocalIngestRequest
|
15
|
+
from ..types.website_source import WebsiteSource
|
16
|
+
from ..types.sort import Sort
|
17
|
+
from ..types.sort_order import SortOrder
|
18
|
+
from ..types.processing_status import ProcessingStatus
|
19
|
+
from ..types.document_list_response import DocumentListResponse
|
21
20
|
from ..types.process_status_response import ProcessStatusResponse
|
22
21
|
from ..core.jsonable_encoder import jsonable_encoder
|
23
22
|
from ..types.document_lookup_response import DocumentLookupResponse
|
@@ -32,97 +31,20 @@ class DocumentsClient:
|
|
32
31
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
33
32
|
self._client_wrapper = client_wrapper
|
34
33
|
|
35
|
-
def
|
34
|
+
def ingest_remote(
|
36
35
|
self,
|
37
36
|
*,
|
38
|
-
|
39
|
-
filter: typing.Optional[str] = None,
|
40
|
-
sort: typing.Optional[Sort] = None,
|
41
|
-
sort_order: typing.Optional[SortOrder] = None,
|
42
|
-
status: typing.Optional[ProcessingStatus] = None,
|
43
|
-
next_token: typing.Optional[str] = None,
|
37
|
+
documents: typing.Sequence[IngestRemoteDocument],
|
44
38
|
request_options: typing.Optional[RequestOptions] = None,
|
45
|
-
) -> DocumentListResponse:
|
46
|
-
"""
|
47
|
-
lookup all documents across all resources which are currently on GroundX
|
48
|
-
|
49
|
-
Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
|
50
|
-
|
51
|
-
Parameters
|
52
|
-
----------
|
53
|
-
n : typing.Optional[int]
|
54
|
-
The maximum number of returned documents. Accepts 1-100 with a default of 20.
|
55
|
-
|
56
|
-
filter : typing.Optional[str]
|
57
|
-
Only documents with names that contain the filter string will be returned in the results.
|
58
|
-
|
59
|
-
sort : typing.Optional[Sort]
|
60
|
-
The document attribute that will be used to sort the results.
|
61
|
-
|
62
|
-
sort_order : typing.Optional[SortOrder]
|
63
|
-
The order in which to sort the results. A value for sort must also be set.
|
64
|
-
|
65
|
-
status : typing.Optional[ProcessingStatus]
|
66
|
-
A status filter on the get documents query. If this value is set, then only documents with this status will be returned in the results.
|
67
|
-
|
68
|
-
next_token : typing.Optional[str]
|
69
|
-
A token for pagination. If the number of documents for a given query is larger than n, the response will include a "nextToken" value. That token can be included in this field to retrieve the next batch of n documents.
|
70
|
-
|
71
|
-
request_options : typing.Optional[RequestOptions]
|
72
|
-
Request-specific configuration.
|
73
|
-
|
74
|
-
Returns
|
75
|
-
-------
|
76
|
-
DocumentListResponse
|
77
|
-
Look up success
|
78
|
-
|
79
|
-
Examples
|
80
|
-
--------
|
81
|
-
from groundx import GroundX
|
82
|
-
|
83
|
-
client = GroundX(
|
84
|
-
api_key="YOUR_API_KEY",
|
85
|
-
)
|
86
|
-
client.documents.list()
|
87
|
-
"""
|
88
|
-
_response = self._client_wrapper.httpx_client.request(
|
89
|
-
"v1/ingest/documents",
|
90
|
-
method="GET",
|
91
|
-
params={
|
92
|
-
"n": n,
|
93
|
-
"filter": filter,
|
94
|
-
"sort": sort,
|
95
|
-
"sortOrder": sort_order,
|
96
|
-
"status": status,
|
97
|
-
"nextToken": next_token,
|
98
|
-
},
|
99
|
-
request_options=request_options,
|
100
|
-
)
|
101
|
-
try:
|
102
|
-
if 200 <= _response.status_code < 300:
|
103
|
-
return typing.cast(
|
104
|
-
DocumentListResponse,
|
105
|
-
parse_obj_as(
|
106
|
-
type_=DocumentListResponse, # type: ignore
|
107
|
-
object_=_response.json(),
|
108
|
-
),
|
109
|
-
)
|
110
|
-
_response_json = _response.json()
|
111
|
-
except JSONDecodeError:
|
112
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
113
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
114
|
-
|
115
|
-
def ingest(
|
116
|
-
self, *, documents: typing.Sequence[IngestDocument], request_options: typing.Optional[RequestOptions] = None
|
117
39
|
) -> IngestResponse:
|
118
40
|
"""
|
119
|
-
Ingest documents hosted on public URLs
|
41
|
+
Ingest documents hosted on public URLs into a GroundX bucket.
|
120
42
|
|
121
43
|
Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
|
122
44
|
|
123
45
|
Parameters
|
124
46
|
----------
|
125
|
-
documents : typing.Sequence[
|
47
|
+
documents : typing.Sequence[IngestRemoteDocument]
|
126
48
|
|
127
49
|
request_options : typing.Optional[RequestOptions]
|
128
50
|
Request-specific configuration.
|
@@ -134,29 +56,28 @@ class DocumentsClient:
|
|
134
56
|
|
135
57
|
Examples
|
136
58
|
--------
|
137
|
-
from groundx import GroundX,
|
59
|
+
from groundx import GroundX, IngestRemoteDocument
|
138
60
|
|
139
61
|
client = GroundX(
|
140
62
|
api_key="YOUR_API_KEY",
|
141
63
|
)
|
142
|
-
client.documents.
|
64
|
+
client.documents.ingest_remote(
|
143
65
|
documents=[
|
144
|
-
|
66
|
+
IngestRemoteDocument(
|
145
67
|
bucket_id=1234,
|
146
|
-
file_name="
|
147
|
-
file_path="https://my.source.url.com/file.txt",
|
68
|
+
file_name="my_file1.txt",
|
148
69
|
file_type="txt",
|
149
|
-
|
70
|
+
source_url="https://my.source.url.com/file1.txt",
|
150
71
|
)
|
151
72
|
],
|
152
73
|
)
|
153
74
|
"""
|
154
75
|
_response = self._client_wrapper.httpx_client.request(
|
155
|
-
"v1/ingest/documents",
|
76
|
+
"v1/ingest/documents/remote",
|
156
77
|
method="POST",
|
157
78
|
json={
|
158
79
|
"documents": convert_and_respect_annotation_metadata(
|
159
|
-
object_=documents, annotation=typing.Sequence[
|
80
|
+
object_=documents, annotation=typing.Sequence[IngestRemoteDocument], direction="write"
|
160
81
|
),
|
161
82
|
},
|
162
83
|
headers={
|
@@ -199,21 +120,17 @@ class DocumentsClient:
|
|
199
120
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
200
121
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
201
122
|
|
202
|
-
def
|
203
|
-
self,
|
204
|
-
*,
|
205
|
-
document_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
206
|
-
request_options: typing.Optional[RequestOptions] = None,
|
123
|
+
def ingest_local(
|
124
|
+
self, *, request: DocumentLocalIngestRequest, request_options: typing.Optional[RequestOptions] = None
|
207
125
|
) -> IngestResponse:
|
208
126
|
"""
|
209
|
-
|
127
|
+
Upload documents hosted on a local file system into a GroundX bucket.
|
210
128
|
|
211
129
|
Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
|
212
130
|
|
213
131
|
Parameters
|
214
132
|
----------
|
215
|
-
|
216
|
-
A list of documentIds which correspond to documents ingested by GroundX
|
133
|
+
request : DocumentLocalIngestRequest
|
217
134
|
|
218
135
|
request_options : typing.Optional[RequestOptions]
|
219
136
|
Request-specific configuration.
|
@@ -221,24 +138,36 @@ class DocumentsClient:
|
|
221
138
|
Returns
|
222
139
|
-------
|
223
140
|
IngestResponse
|
224
|
-
Documents
|
141
|
+
Documents successfully uploaded
|
225
142
|
|
226
143
|
Examples
|
227
144
|
--------
|
228
|
-
from groundx import GroundX
|
145
|
+
from groundx import GroundX, IngestLocalDocument, IngestLocalDocumentMetadata
|
229
146
|
|
230
147
|
client = GroundX(
|
231
148
|
api_key="YOUR_API_KEY",
|
232
149
|
)
|
233
|
-
client.documents.
|
150
|
+
client.documents.ingest_local(
|
151
|
+
request=[
|
152
|
+
IngestLocalDocument(
|
153
|
+
blob="blob",
|
154
|
+
metadata=IngestLocalDocumentMetadata(
|
155
|
+
bucket_id=1234,
|
156
|
+
file_name="my_file1.txt",
|
157
|
+
file_type="txt",
|
158
|
+
),
|
159
|
+
)
|
160
|
+
],
|
161
|
+
)
|
234
162
|
"""
|
235
163
|
_response = self._client_wrapper.httpx_client.request(
|
236
|
-
"v1/ingest/documents",
|
237
|
-
method="
|
238
|
-
|
239
|
-
"
|
240
|
-
|
164
|
+
"v1/ingest/documents/local",
|
165
|
+
method="POST",
|
166
|
+
json=convert_and_respect_annotation_metadata(
|
167
|
+
object_=request, annotation=DocumentLocalIngestRequest, direction="write"
|
168
|
+
),
|
241
169
|
request_options=request_options,
|
170
|
+
omit=OMIT,
|
242
171
|
)
|
243
172
|
try:
|
244
173
|
if 200 <= _response.status_code < 300:
|
@@ -274,20 +203,17 @@ class DocumentsClient:
|
|
274
203
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
275
204
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
276
205
|
|
277
|
-
def
|
278
|
-
self,
|
279
|
-
*,
|
280
|
-
documents: typing.Sequence[IngestRemoteDocument],
|
281
|
-
request_options: typing.Optional[RequestOptions] = None,
|
206
|
+
def crawl_website(
|
207
|
+
self, *, websites: typing.Sequence[WebsiteSource], request_options: typing.Optional[RequestOptions] = None
|
282
208
|
) -> IngestResponse:
|
283
209
|
"""
|
284
|
-
|
210
|
+
Upload the content of a publicly accessible website for ingestion into a GroundX bucket. This is done by following links within a specified URL, recursively, up to a specified depth or number of pages.
|
285
211
|
|
286
212
|
Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
|
287
213
|
|
288
214
|
Parameters
|
289
215
|
----------
|
290
|
-
|
216
|
+
websites : typing.Sequence[WebsiteSource]
|
291
217
|
|
292
218
|
request_options : typing.Optional[RequestOptions]
|
293
219
|
Request-specific configuration.
|
@@ -295,33 +221,33 @@ class DocumentsClient:
|
|
295
221
|
Returns
|
296
222
|
-------
|
297
223
|
IngestResponse
|
298
|
-
|
224
|
+
Website successfully queued
|
299
225
|
|
300
226
|
Examples
|
301
227
|
--------
|
302
|
-
from groundx import GroundX,
|
228
|
+
from groundx import GroundX, WebsiteSource
|
303
229
|
|
304
230
|
client = GroundX(
|
305
231
|
api_key="YOUR_API_KEY",
|
306
232
|
)
|
307
|
-
client.documents.
|
308
|
-
|
309
|
-
|
233
|
+
client.documents.crawl_website(
|
234
|
+
websites=[
|
235
|
+
WebsiteSource(
|
310
236
|
bucket_id=1234,
|
311
|
-
|
312
|
-
|
237
|
+
cap=100,
|
238
|
+
depth=3,
|
313
239
|
search_data={"key": "value"},
|
314
|
-
source_url="https://my.
|
240
|
+
source_url="https://my.website.com",
|
315
241
|
)
|
316
242
|
],
|
317
243
|
)
|
318
244
|
"""
|
319
245
|
_response = self._client_wrapper.httpx_client.request(
|
320
|
-
"v1/ingest/documents/
|
246
|
+
"v1/ingest/documents/website",
|
321
247
|
method="POST",
|
322
248
|
json={
|
323
|
-
"
|
324
|
-
object_=
|
249
|
+
"websites": convert_and_respect_annotation_metadata(
|
250
|
+
object_=websites, annotation=typing.Sequence[WebsiteSource], direction="write"
|
325
251
|
),
|
326
252
|
},
|
327
253
|
headers={
|
@@ -364,103 +290,101 @@ class DocumentsClient:
|
|
364
290
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
365
291
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
366
292
|
|
367
|
-
def
|
293
|
+
def list(
|
368
294
|
self,
|
369
295
|
*,
|
370
|
-
|
296
|
+
n: typing.Optional[int] = None,
|
297
|
+
filter: typing.Optional[str] = None,
|
298
|
+
sort: typing.Optional[Sort] = None,
|
299
|
+
sort_order: typing.Optional[SortOrder] = None,
|
300
|
+
status: typing.Optional[ProcessingStatus] = None,
|
301
|
+
next_token: typing.Optional[str] = None,
|
371
302
|
request_options: typing.Optional[RequestOptions] = None,
|
372
|
-
) ->
|
303
|
+
) -> DocumentListResponse:
|
373
304
|
"""
|
374
|
-
|
305
|
+
lookup all documents across all resources which are currently on GroundX
|
375
306
|
|
376
307
|
Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
|
377
308
|
|
378
309
|
Parameters
|
379
310
|
----------
|
380
|
-
|
311
|
+
n : typing.Optional[int]
|
312
|
+
The maximum number of returned documents. Accepts 1-100 with a default of 20.
|
313
|
+
|
314
|
+
filter : typing.Optional[str]
|
315
|
+
Only documents with names that contain the filter string will be returned in the results.
|
316
|
+
|
317
|
+
sort : typing.Optional[Sort]
|
318
|
+
The document attribute that will be used to sort the results.
|
319
|
+
|
320
|
+
sort_order : typing.Optional[SortOrder]
|
321
|
+
The order in which to sort the results. A value for sort must also be set.
|
322
|
+
|
323
|
+
status : typing.Optional[ProcessingStatus]
|
324
|
+
A status filter on the get documents query. If this value is set, then only documents with this status will be returned in the results.
|
325
|
+
|
326
|
+
next_token : typing.Optional[str]
|
327
|
+
A token for pagination. If the number of documents for a given query is larger than n, the response will include a "nextToken" value. That token can be included in this field to retrieve the next batch of n documents.
|
381
328
|
|
382
329
|
request_options : typing.Optional[RequestOptions]
|
383
330
|
Request-specific configuration.
|
384
331
|
|
385
332
|
Returns
|
386
333
|
-------
|
387
|
-
|
388
|
-
|
334
|
+
DocumentListResponse
|
335
|
+
Look up success
|
389
336
|
|
390
337
|
Examples
|
391
338
|
--------
|
392
|
-
from groundx import GroundX
|
339
|
+
from groundx import GroundX
|
393
340
|
|
394
341
|
client = GroundX(
|
395
342
|
api_key="YOUR_API_KEY",
|
396
343
|
)
|
397
|
-
client.documents.
|
398
|
-
documents=[
|
399
|
-
IngestLocalDocument(
|
400
|
-
bucket_id=1234,
|
401
|
-
file_data="binary data",
|
402
|
-
file_name="my_file.txt",
|
403
|
-
file_type="txt",
|
404
|
-
search_data={"key": "value"},
|
405
|
-
)
|
406
|
-
],
|
407
|
-
)
|
344
|
+
client.documents.list()
|
408
345
|
"""
|
409
346
|
_response = self._client_wrapper.httpx_client.request(
|
410
|
-
"v1/ingest/documents
|
411
|
-
method="
|
412
|
-
|
413
|
-
"
|
347
|
+
"v1/ingest/documents",
|
348
|
+
method="GET",
|
349
|
+
params={
|
350
|
+
"n": n,
|
351
|
+
"filter": filter,
|
352
|
+
"sort": sort,
|
353
|
+
"sortOrder": sort_order,
|
354
|
+
"status": status,
|
355
|
+
"nextToken": next_token,
|
414
356
|
},
|
415
|
-
files={},
|
416
357
|
request_options=request_options,
|
417
|
-
omit=OMIT,
|
418
358
|
)
|
419
359
|
try:
|
420
360
|
if 200 <= _response.status_code < 300:
|
421
361
|
return typing.cast(
|
422
|
-
|
362
|
+
DocumentListResponse,
|
423
363
|
parse_obj_as(
|
424
|
-
type_=
|
364
|
+
type_=DocumentListResponse, # type: ignore
|
425
365
|
object_=_response.json(),
|
426
366
|
),
|
427
367
|
)
|
428
|
-
if _response.status_code == 400:
|
429
|
-
raise BadRequestError(
|
430
|
-
typing.cast(
|
431
|
-
typing.Optional[typing.Any],
|
432
|
-
parse_obj_as(
|
433
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
434
|
-
object_=_response.json(),
|
435
|
-
),
|
436
|
-
)
|
437
|
-
)
|
438
|
-
if _response.status_code == 401:
|
439
|
-
raise UnauthorizedError(
|
440
|
-
typing.cast(
|
441
|
-
typing.Optional[typing.Any],
|
442
|
-
parse_obj_as(
|
443
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
444
|
-
object_=_response.json(),
|
445
|
-
),
|
446
|
-
)
|
447
|
-
)
|
448
368
|
_response_json = _response.json()
|
449
369
|
except JSONDecodeError:
|
450
370
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
451
371
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
452
372
|
|
453
|
-
def
|
454
|
-
self,
|
373
|
+
def delete(
|
374
|
+
self,
|
375
|
+
*,
|
376
|
+
document_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
377
|
+
request_options: typing.Optional[RequestOptions] = None,
|
455
378
|
) -> IngestResponse:
|
456
379
|
"""
|
457
|
-
|
380
|
+
Delete multiple documents hosted on GroundX
|
458
381
|
|
459
382
|
Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
|
460
383
|
|
461
384
|
Parameters
|
462
385
|
----------
|
463
|
-
|
386
|
+
document_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
387
|
+
A list of documentIds which correspond to documents ingested by GroundX
|
464
388
|
|
465
389
|
request_options : typing.Optional[RequestOptions]
|
466
390
|
Request-specific configuration.
|
@@ -468,40 +392,24 @@ class DocumentsClient:
|
|
468
392
|
Returns
|
469
393
|
-------
|
470
394
|
IngestResponse
|
471
|
-
|
395
|
+
Documents are queued to be deleted
|
472
396
|
|
473
397
|
Examples
|
474
398
|
--------
|
475
|
-
from groundx import
|
399
|
+
from groundx import GroundX
|
476
400
|
|
477
401
|
client = GroundX(
|
478
402
|
api_key="YOUR_API_KEY",
|
479
403
|
)
|
480
|
-
client.documents.
|
481
|
-
websites=[
|
482
|
-
CrawlWebsiteSource(
|
483
|
-
bucket_id=1234,
|
484
|
-
cap=100,
|
485
|
-
depth=3,
|
486
|
-
search_data={"key": "value"},
|
487
|
-
source_url="https://my.website.com",
|
488
|
-
)
|
489
|
-
],
|
490
|
-
)
|
404
|
+
client.documents.delete()
|
491
405
|
"""
|
492
406
|
_response = self._client_wrapper.httpx_client.request(
|
493
|
-
"v1/ingest/documents
|
494
|
-
method="
|
495
|
-
|
496
|
-
"
|
497
|
-
object_=websites, annotation=typing.Sequence[CrawlWebsiteSource], direction="write"
|
498
|
-
),
|
499
|
-
},
|
500
|
-
headers={
|
501
|
-
"content-type": "application/json",
|
407
|
+
"v1/ingest/documents",
|
408
|
+
method="DELETE",
|
409
|
+
params={
|
410
|
+
"documentIds": document_ids,
|
502
411
|
},
|
503
412
|
request_options=request_options,
|
504
|
-
omit=OMIT,
|
505
413
|
)
|
506
414
|
try:
|
507
415
|
if 200 <= _response.status_code < 300:
|
@@ -786,178 +694,93 @@ class DocumentsClient:
|
|
786
694
|
def delete_by_id(
|
787
695
|
self, document_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
788
696
|
) -> IngestResponse:
|
789
|
-
"""
|
790
|
-
Delete a single document hosted on GroundX
|
791
|
-
|
792
|
-
Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
|
793
|
-
|
794
|
-
Parameters
|
795
|
-
----------
|
796
|
-
document_id : str
|
797
|
-
A documentId which correspond to a document ingested by GroundX
|
798
|
-
|
799
|
-
request_options : typing.Optional[RequestOptions]
|
800
|
-
Request-specific configuration.
|
801
|
-
|
802
|
-
Returns
|
803
|
-
-------
|
804
|
-
IngestResponse
|
805
|
-
Document successfully deleted
|
806
|
-
|
807
|
-
Examples
|
808
|
-
--------
|
809
|
-
from groundx import GroundX
|
810
|
-
|
811
|
-
client = GroundX(
|
812
|
-
api_key="YOUR_API_KEY",
|
813
|
-
)
|
814
|
-
client.documents.delete_by_id(
|
815
|
-
document_id="documentId",
|
816
|
-
)
|
817
|
-
"""
|
818
|
-
_response = self._client_wrapper.httpx_client.request(
|
819
|
-
f"v1/ingest/document/{jsonable_encoder(document_id)}",
|
820
|
-
method="DELETE",
|
821
|
-
request_options=request_options,
|
822
|
-
)
|
823
|
-
try:
|
824
|
-
if 200 <= _response.status_code < 300:
|
825
|
-
return typing.cast(
|
826
|
-
IngestResponse,
|
827
|
-
parse_obj_as(
|
828
|
-
type_=IngestResponse, # type: ignore
|
829
|
-
object_=_response.json(),
|
830
|
-
),
|
831
|
-
)
|
832
|
-
if _response.status_code == 400:
|
833
|
-
raise BadRequestError(
|
834
|
-
typing.cast(
|
835
|
-
typing.Optional[typing.Any],
|
836
|
-
parse_obj_as(
|
837
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
838
|
-
object_=_response.json(),
|
839
|
-
),
|
840
|
-
)
|
841
|
-
)
|
842
|
-
if _response.status_code == 401:
|
843
|
-
raise UnauthorizedError(
|
844
|
-
typing.cast(
|
845
|
-
typing.Optional[typing.Any],
|
846
|
-
parse_obj_as(
|
847
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
848
|
-
object_=_response.json(),
|
849
|
-
),
|
850
|
-
)
|
851
|
-
)
|
852
|
-
_response_json = _response.json()
|
853
|
-
except JSONDecodeError:
|
854
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
855
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
856
|
-
|
857
|
-
|
858
|
-
class AsyncDocumentsClient:
|
859
|
-
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
860
|
-
self._client_wrapper = client_wrapper
|
861
|
-
|
862
|
-
async def list(
|
863
|
-
self,
|
864
|
-
*,
|
865
|
-
n: typing.Optional[int] = None,
|
866
|
-
filter: typing.Optional[str] = None,
|
867
|
-
sort: typing.Optional[Sort] = None,
|
868
|
-
sort_order: typing.Optional[SortOrder] = None,
|
869
|
-
status: typing.Optional[ProcessingStatus] = None,
|
870
|
-
next_token: typing.Optional[str] = None,
|
871
|
-
request_options: typing.Optional[RequestOptions] = None,
|
872
|
-
) -> DocumentListResponse:
|
873
|
-
"""
|
874
|
-
lookup all documents across all resources which are currently on GroundX
|
875
|
-
|
876
|
-
Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
|
877
|
-
|
878
|
-
Parameters
|
879
|
-
----------
|
880
|
-
n : typing.Optional[int]
|
881
|
-
The maximum number of returned documents. Accepts 1-100 with a default of 20.
|
882
|
-
|
883
|
-
filter : typing.Optional[str]
|
884
|
-
Only documents with names that contain the filter string will be returned in the results.
|
885
|
-
|
886
|
-
sort : typing.Optional[Sort]
|
887
|
-
The document attribute that will be used to sort the results.
|
888
|
-
|
889
|
-
sort_order : typing.Optional[SortOrder]
|
890
|
-
The order in which to sort the results. A value for sort must also be set.
|
697
|
+
"""
|
698
|
+
Delete a single document hosted on GroundX
|
891
699
|
|
892
|
-
|
893
|
-
A status filter on the get documents query. If this value is set, then only documents with this status will be returned in the results.
|
700
|
+
Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
|
894
701
|
|
895
|
-
|
896
|
-
|
702
|
+
Parameters
|
703
|
+
----------
|
704
|
+
document_id : str
|
705
|
+
A documentId which correspond to a document ingested by GroundX
|
897
706
|
|
898
707
|
request_options : typing.Optional[RequestOptions]
|
899
708
|
Request-specific configuration.
|
900
709
|
|
901
710
|
Returns
|
902
711
|
-------
|
903
|
-
|
904
|
-
|
712
|
+
IngestResponse
|
713
|
+
Document successfully deleted
|
905
714
|
|
906
715
|
Examples
|
907
716
|
--------
|
908
|
-
import
|
909
|
-
|
910
|
-
from groundx import AsyncGroundX
|
717
|
+
from groundx import GroundX
|
911
718
|
|
912
|
-
client =
|
719
|
+
client = GroundX(
|
913
720
|
api_key="YOUR_API_KEY",
|
914
721
|
)
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
await client.documents.list()
|
919
|
-
|
920
|
-
|
921
|
-
asyncio.run(main())
|
722
|
+
client.documents.delete_by_id(
|
723
|
+
document_id="documentId",
|
724
|
+
)
|
922
725
|
"""
|
923
|
-
_response =
|
924
|
-
"v1/ingest/
|
925
|
-
method="
|
926
|
-
params={
|
927
|
-
"n": n,
|
928
|
-
"filter": filter,
|
929
|
-
"sort": sort,
|
930
|
-
"sortOrder": sort_order,
|
931
|
-
"status": status,
|
932
|
-
"nextToken": next_token,
|
933
|
-
},
|
726
|
+
_response = self._client_wrapper.httpx_client.request(
|
727
|
+
f"v1/ingest/document/{jsonable_encoder(document_id)}",
|
728
|
+
method="DELETE",
|
934
729
|
request_options=request_options,
|
935
730
|
)
|
936
731
|
try:
|
937
732
|
if 200 <= _response.status_code < 300:
|
938
733
|
return typing.cast(
|
939
|
-
|
734
|
+
IngestResponse,
|
940
735
|
parse_obj_as(
|
941
|
-
type_=
|
736
|
+
type_=IngestResponse, # type: ignore
|
942
737
|
object_=_response.json(),
|
943
738
|
),
|
944
739
|
)
|
740
|
+
if _response.status_code == 400:
|
741
|
+
raise BadRequestError(
|
742
|
+
typing.cast(
|
743
|
+
typing.Optional[typing.Any],
|
744
|
+
parse_obj_as(
|
745
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
746
|
+
object_=_response.json(),
|
747
|
+
),
|
748
|
+
)
|
749
|
+
)
|
750
|
+
if _response.status_code == 401:
|
751
|
+
raise UnauthorizedError(
|
752
|
+
typing.cast(
|
753
|
+
typing.Optional[typing.Any],
|
754
|
+
parse_obj_as(
|
755
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
756
|
+
object_=_response.json(),
|
757
|
+
),
|
758
|
+
)
|
759
|
+
)
|
945
760
|
_response_json = _response.json()
|
946
761
|
except JSONDecodeError:
|
947
762
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
948
763
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
949
764
|
|
950
|
-
|
951
|
-
|
765
|
+
|
766
|
+
class AsyncDocumentsClient:
|
767
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
768
|
+
self._client_wrapper = client_wrapper
|
769
|
+
|
770
|
+
async def ingest_remote(
|
771
|
+
self,
|
772
|
+
*,
|
773
|
+
documents: typing.Sequence[IngestRemoteDocument],
|
774
|
+
request_options: typing.Optional[RequestOptions] = None,
|
952
775
|
) -> IngestResponse:
|
953
776
|
"""
|
954
|
-
Ingest documents hosted on public URLs
|
777
|
+
Ingest documents hosted on public URLs into a GroundX bucket.
|
955
778
|
|
956
779
|
Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
|
957
780
|
|
958
781
|
Parameters
|
959
782
|
----------
|
960
|
-
documents : typing.Sequence[
|
783
|
+
documents : typing.Sequence[IngestRemoteDocument]
|
961
784
|
|
962
785
|
request_options : typing.Optional[RequestOptions]
|
963
786
|
Request-specific configuration.
|
@@ -971,7 +794,7 @@ class AsyncDocumentsClient:
|
|
971
794
|
--------
|
972
795
|
import asyncio
|
973
796
|
|
974
|
-
from groundx import AsyncGroundX,
|
797
|
+
from groundx import AsyncGroundX, IngestRemoteDocument
|
975
798
|
|
976
799
|
client = AsyncGroundX(
|
977
800
|
api_key="YOUR_API_KEY",
|
@@ -979,14 +802,13 @@ class AsyncDocumentsClient:
|
|
979
802
|
|
980
803
|
|
981
804
|
async def main() -> None:
|
982
|
-
await client.documents.
|
805
|
+
await client.documents.ingest_remote(
|
983
806
|
documents=[
|
984
|
-
|
807
|
+
IngestRemoteDocument(
|
985
808
|
bucket_id=1234,
|
986
|
-
file_name="
|
987
|
-
file_path="https://my.source.url.com/file.txt",
|
809
|
+
file_name="my_file1.txt",
|
988
810
|
file_type="txt",
|
989
|
-
|
811
|
+
source_url="https://my.source.url.com/file1.txt",
|
990
812
|
)
|
991
813
|
],
|
992
814
|
)
|
@@ -995,11 +817,11 @@ class AsyncDocumentsClient:
|
|
995
817
|
asyncio.run(main())
|
996
818
|
"""
|
997
819
|
_response = await self._client_wrapper.httpx_client.request(
|
998
|
-
"v1/ingest/documents",
|
820
|
+
"v1/ingest/documents/remote",
|
999
821
|
method="POST",
|
1000
822
|
json={
|
1001
823
|
"documents": convert_and_respect_annotation_metadata(
|
1002
|
-
object_=documents, annotation=typing.Sequence[
|
824
|
+
object_=documents, annotation=typing.Sequence[IngestRemoteDocument], direction="write"
|
1003
825
|
),
|
1004
826
|
},
|
1005
827
|
headers={
|
@@ -1042,21 +864,17 @@ class AsyncDocumentsClient:
|
|
1042
864
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
1043
865
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
1044
866
|
|
1045
|
-
async def
|
1046
|
-
self,
|
1047
|
-
*,
|
1048
|
-
document_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
1049
|
-
request_options: typing.Optional[RequestOptions] = None,
|
867
|
+
async def ingest_local(
|
868
|
+
self, *, request: DocumentLocalIngestRequest, request_options: typing.Optional[RequestOptions] = None
|
1050
869
|
) -> IngestResponse:
|
1051
870
|
"""
|
1052
|
-
|
871
|
+
Upload documents hosted on a local file system into a GroundX bucket.
|
1053
872
|
|
1054
873
|
Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
|
1055
874
|
|
1056
875
|
Parameters
|
1057
876
|
----------
|
1058
|
-
|
1059
|
-
A list of documentIds which correspond to documents ingested by GroundX
|
877
|
+
request : DocumentLocalIngestRequest
|
1060
878
|
|
1061
879
|
request_options : typing.Optional[RequestOptions]
|
1062
880
|
Request-specific configuration.
|
@@ -1064,13 +882,17 @@ class AsyncDocumentsClient:
|
|
1064
882
|
Returns
|
1065
883
|
-------
|
1066
884
|
IngestResponse
|
1067
|
-
Documents
|
885
|
+
Documents successfully uploaded
|
1068
886
|
|
1069
887
|
Examples
|
1070
888
|
--------
|
1071
889
|
import asyncio
|
1072
890
|
|
1073
|
-
from groundx import
|
891
|
+
from groundx import (
|
892
|
+
AsyncGroundX,
|
893
|
+
IngestLocalDocument,
|
894
|
+
IngestLocalDocumentMetadata,
|
895
|
+
)
|
1074
896
|
|
1075
897
|
client = AsyncGroundX(
|
1076
898
|
api_key="YOUR_API_KEY",
|
@@ -1078,18 +900,30 @@ class AsyncDocumentsClient:
|
|
1078
900
|
|
1079
901
|
|
1080
902
|
async def main() -> None:
|
1081
|
-
await client.documents.
|
903
|
+
await client.documents.ingest_local(
|
904
|
+
request=[
|
905
|
+
IngestLocalDocument(
|
906
|
+
blob="blob",
|
907
|
+
metadata=IngestLocalDocumentMetadata(
|
908
|
+
bucket_id=1234,
|
909
|
+
file_name="my_file1.txt",
|
910
|
+
file_type="txt",
|
911
|
+
),
|
912
|
+
)
|
913
|
+
],
|
914
|
+
)
|
1082
915
|
|
1083
916
|
|
1084
917
|
asyncio.run(main())
|
1085
918
|
"""
|
1086
919
|
_response = await self._client_wrapper.httpx_client.request(
|
1087
|
-
"v1/ingest/documents",
|
1088
|
-
method="
|
1089
|
-
|
1090
|
-
"
|
1091
|
-
|
920
|
+
"v1/ingest/documents/local",
|
921
|
+
method="POST",
|
922
|
+
json=convert_and_respect_annotation_metadata(
|
923
|
+
object_=request, annotation=DocumentLocalIngestRequest, direction="write"
|
924
|
+
),
|
1092
925
|
request_options=request_options,
|
926
|
+
omit=OMIT,
|
1093
927
|
)
|
1094
928
|
try:
|
1095
929
|
if 200 <= _response.status_code < 300:
|
@@ -1125,20 +959,17 @@ class AsyncDocumentsClient:
|
|
1125
959
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
1126
960
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
1127
961
|
|
1128
|
-
async def
|
1129
|
-
self,
|
1130
|
-
*,
|
1131
|
-
documents: typing.Sequence[IngestRemoteDocument],
|
1132
|
-
request_options: typing.Optional[RequestOptions] = None,
|
962
|
+
async def crawl_website(
|
963
|
+
self, *, websites: typing.Sequence[WebsiteSource], request_options: typing.Optional[RequestOptions] = None
|
1133
964
|
) -> IngestResponse:
|
1134
965
|
"""
|
1135
|
-
|
966
|
+
Upload the content of a publicly accessible website for ingestion into a GroundX bucket. This is done by following links within a specified URL, recursively, up to a specified depth or number of pages.
|
1136
967
|
|
1137
968
|
Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
|
1138
969
|
|
1139
970
|
Parameters
|
1140
971
|
----------
|
1141
|
-
|
972
|
+
websites : typing.Sequence[WebsiteSource]
|
1142
973
|
|
1143
974
|
request_options : typing.Optional[RequestOptions]
|
1144
975
|
Request-specific configuration.
|
@@ -1146,13 +977,13 @@ class AsyncDocumentsClient:
|
|
1146
977
|
Returns
|
1147
978
|
-------
|
1148
979
|
IngestResponse
|
1149
|
-
|
980
|
+
Website successfully queued
|
1150
981
|
|
1151
982
|
Examples
|
1152
983
|
--------
|
1153
984
|
import asyncio
|
1154
985
|
|
1155
|
-
from groundx import AsyncGroundX,
|
986
|
+
from groundx import AsyncGroundX, WebsiteSource
|
1156
987
|
|
1157
988
|
client = AsyncGroundX(
|
1158
989
|
api_key="YOUR_API_KEY",
|
@@ -1160,14 +991,14 @@ class AsyncDocumentsClient:
|
|
1160
991
|
|
1161
992
|
|
1162
993
|
async def main() -> None:
|
1163
|
-
await client.documents.
|
1164
|
-
|
1165
|
-
|
994
|
+
await client.documents.crawl_website(
|
995
|
+
websites=[
|
996
|
+
WebsiteSource(
|
1166
997
|
bucket_id=1234,
|
1167
|
-
|
1168
|
-
|
998
|
+
cap=100,
|
999
|
+
depth=3,
|
1169
1000
|
search_data={"key": "value"},
|
1170
|
-
source_url="https://my.
|
1001
|
+
source_url="https://my.website.com",
|
1171
1002
|
)
|
1172
1003
|
],
|
1173
1004
|
)
|
@@ -1176,11 +1007,11 @@ class AsyncDocumentsClient:
|
|
1176
1007
|
asyncio.run(main())
|
1177
1008
|
"""
|
1178
1009
|
_response = await self._client_wrapper.httpx_client.request(
|
1179
|
-
"v1/ingest/documents/
|
1010
|
+
"v1/ingest/documents/website",
|
1180
1011
|
method="POST",
|
1181
1012
|
json={
|
1182
|
-
"
|
1183
|
-
object_=
|
1013
|
+
"websites": convert_and_respect_annotation_metadata(
|
1014
|
+
object_=websites, annotation=typing.Sequence[WebsiteSource], direction="write"
|
1184
1015
|
),
|
1185
1016
|
},
|
1186
1017
|
headers={
|
@@ -1223,34 +1054,55 @@ class AsyncDocumentsClient:
|
|
1223
1054
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
1224
1055
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
1225
1056
|
|
1226
|
-
async def
|
1057
|
+
async def list(
|
1227
1058
|
self,
|
1228
1059
|
*,
|
1229
|
-
|
1060
|
+
n: typing.Optional[int] = None,
|
1061
|
+
filter: typing.Optional[str] = None,
|
1062
|
+
sort: typing.Optional[Sort] = None,
|
1063
|
+
sort_order: typing.Optional[SortOrder] = None,
|
1064
|
+
status: typing.Optional[ProcessingStatus] = None,
|
1065
|
+
next_token: typing.Optional[str] = None,
|
1230
1066
|
request_options: typing.Optional[RequestOptions] = None,
|
1231
|
-
) ->
|
1067
|
+
) -> DocumentListResponse:
|
1232
1068
|
"""
|
1233
|
-
|
1069
|
+
lookup all documents across all resources which are currently on GroundX
|
1234
1070
|
|
1235
1071
|
Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
|
1236
1072
|
|
1237
1073
|
Parameters
|
1238
1074
|
----------
|
1239
|
-
|
1075
|
+
n : typing.Optional[int]
|
1076
|
+
The maximum number of returned documents. Accepts 1-100 with a default of 20.
|
1077
|
+
|
1078
|
+
filter : typing.Optional[str]
|
1079
|
+
Only documents with names that contain the filter string will be returned in the results.
|
1080
|
+
|
1081
|
+
sort : typing.Optional[Sort]
|
1082
|
+
The document attribute that will be used to sort the results.
|
1083
|
+
|
1084
|
+
sort_order : typing.Optional[SortOrder]
|
1085
|
+
The order in which to sort the results. A value for sort must also be set.
|
1086
|
+
|
1087
|
+
status : typing.Optional[ProcessingStatus]
|
1088
|
+
A status filter on the get documents query. If this value is set, then only documents with this status will be returned in the results.
|
1089
|
+
|
1090
|
+
next_token : typing.Optional[str]
|
1091
|
+
A token for pagination. If the number of documents for a given query is larger than n, the response will include a "nextToken" value. That token can be included in this field to retrieve the next batch of n documents.
|
1240
1092
|
|
1241
1093
|
request_options : typing.Optional[RequestOptions]
|
1242
1094
|
Request-specific configuration.
|
1243
1095
|
|
1244
1096
|
Returns
|
1245
1097
|
-------
|
1246
|
-
|
1247
|
-
|
1098
|
+
DocumentListResponse
|
1099
|
+
Look up success
|
1248
1100
|
|
1249
1101
|
Examples
|
1250
1102
|
--------
|
1251
1103
|
import asyncio
|
1252
1104
|
|
1253
|
-
from groundx import AsyncGroundX
|
1105
|
+
from groundx import AsyncGroundX
|
1254
1106
|
|
1255
1107
|
client = AsyncGroundX(
|
1256
1108
|
api_key="YOUR_API_KEY",
|
@@ -1258,76 +1110,53 @@ class AsyncDocumentsClient:
|
|
1258
1110
|
|
1259
1111
|
|
1260
1112
|
async def main() -> None:
|
1261
|
-
await client.documents.
|
1262
|
-
documents=[
|
1263
|
-
IngestLocalDocument(
|
1264
|
-
bucket_id=1234,
|
1265
|
-
file_data="binary data",
|
1266
|
-
file_name="my_file.txt",
|
1267
|
-
file_type="txt",
|
1268
|
-
search_data={"key": "value"},
|
1269
|
-
)
|
1270
|
-
],
|
1271
|
-
)
|
1113
|
+
await client.documents.list()
|
1272
1114
|
|
1273
1115
|
|
1274
1116
|
asyncio.run(main())
|
1275
1117
|
"""
|
1276
1118
|
_response = await self._client_wrapper.httpx_client.request(
|
1277
|
-
"v1/ingest/documents
|
1278
|
-
method="
|
1279
|
-
|
1280
|
-
"
|
1119
|
+
"v1/ingest/documents",
|
1120
|
+
method="GET",
|
1121
|
+
params={
|
1122
|
+
"n": n,
|
1123
|
+
"filter": filter,
|
1124
|
+
"sort": sort,
|
1125
|
+
"sortOrder": sort_order,
|
1126
|
+
"status": status,
|
1127
|
+
"nextToken": next_token,
|
1281
1128
|
},
|
1282
|
-
files={},
|
1283
1129
|
request_options=request_options,
|
1284
|
-
omit=OMIT,
|
1285
1130
|
)
|
1286
1131
|
try:
|
1287
1132
|
if 200 <= _response.status_code < 300:
|
1288
1133
|
return typing.cast(
|
1289
|
-
|
1134
|
+
DocumentListResponse,
|
1290
1135
|
parse_obj_as(
|
1291
|
-
type_=
|
1136
|
+
type_=DocumentListResponse, # type: ignore
|
1292
1137
|
object_=_response.json(),
|
1293
1138
|
),
|
1294
1139
|
)
|
1295
|
-
if _response.status_code == 400:
|
1296
|
-
raise BadRequestError(
|
1297
|
-
typing.cast(
|
1298
|
-
typing.Optional[typing.Any],
|
1299
|
-
parse_obj_as(
|
1300
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
1301
|
-
object_=_response.json(),
|
1302
|
-
),
|
1303
|
-
)
|
1304
|
-
)
|
1305
|
-
if _response.status_code == 401:
|
1306
|
-
raise UnauthorizedError(
|
1307
|
-
typing.cast(
|
1308
|
-
typing.Optional[typing.Any],
|
1309
|
-
parse_obj_as(
|
1310
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
1311
|
-
object_=_response.json(),
|
1312
|
-
),
|
1313
|
-
)
|
1314
|
-
)
|
1315
1140
|
_response_json = _response.json()
|
1316
1141
|
except JSONDecodeError:
|
1317
1142
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
1318
1143
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
1319
1144
|
|
1320
|
-
async def
|
1321
|
-
self,
|
1145
|
+
async def delete(
|
1146
|
+
self,
|
1147
|
+
*,
|
1148
|
+
document_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
1149
|
+
request_options: typing.Optional[RequestOptions] = None,
|
1322
1150
|
) -> IngestResponse:
|
1323
1151
|
"""
|
1324
|
-
|
1152
|
+
Delete multiple documents hosted on GroundX
|
1325
1153
|
|
1326
1154
|
Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
|
1327
1155
|
|
1328
1156
|
Parameters
|
1329
1157
|
----------
|
1330
|
-
|
1158
|
+
document_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
1159
|
+
A list of documentIds which correspond to documents ingested by GroundX
|
1331
1160
|
|
1332
1161
|
request_options : typing.Optional[RequestOptions]
|
1333
1162
|
Request-specific configuration.
|
@@ -1335,13 +1164,13 @@ class AsyncDocumentsClient:
|
|
1335
1164
|
Returns
|
1336
1165
|
-------
|
1337
1166
|
IngestResponse
|
1338
|
-
|
1167
|
+
Documents are queued to be deleted
|
1339
1168
|
|
1340
1169
|
Examples
|
1341
1170
|
--------
|
1342
1171
|
import asyncio
|
1343
1172
|
|
1344
|
-
from groundx import AsyncGroundX
|
1173
|
+
from groundx import AsyncGroundX
|
1345
1174
|
|
1346
1175
|
client = AsyncGroundX(
|
1347
1176
|
api_key="YOUR_API_KEY",
|
@@ -1349,34 +1178,18 @@ class AsyncDocumentsClient:
|
|
1349
1178
|
|
1350
1179
|
|
1351
1180
|
async def main() -> None:
|
1352
|
-
await client.documents.
|
1353
|
-
websites=[
|
1354
|
-
CrawlWebsiteSource(
|
1355
|
-
bucket_id=1234,
|
1356
|
-
cap=100,
|
1357
|
-
depth=3,
|
1358
|
-
search_data={"key": "value"},
|
1359
|
-
source_url="https://my.website.com",
|
1360
|
-
)
|
1361
|
-
],
|
1362
|
-
)
|
1181
|
+
await client.documents.delete()
|
1363
1182
|
|
1364
1183
|
|
1365
1184
|
asyncio.run(main())
|
1366
1185
|
"""
|
1367
1186
|
_response = await self._client_wrapper.httpx_client.request(
|
1368
|
-
"v1/ingest/documents
|
1369
|
-
method="
|
1370
|
-
|
1371
|
-
"
|
1372
|
-
object_=websites, annotation=typing.Sequence[CrawlWebsiteSource], direction="write"
|
1373
|
-
),
|
1374
|
-
},
|
1375
|
-
headers={
|
1376
|
-
"content-type": "application/json",
|
1187
|
+
"v1/ingest/documents",
|
1188
|
+
method="DELETE",
|
1189
|
+
params={
|
1190
|
+
"documentIds": document_ids,
|
1377
1191
|
},
|
1378
1192
|
request_options=request_options,
|
1379
|
-
omit=OMIT,
|
1380
1193
|
)
|
1381
1194
|
try:
|
1382
1195
|
if 200 <= _response.status_code < 300:
|