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