groundx 2.3.8__tar.gz → 2.4.0__tar.gz

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.
Files changed (96) hide show
  1. {groundx-2.3.8 → groundx-2.4.0}/PKG-INFO +1 -1
  2. {groundx-2.3.8 → groundx-2.4.0}/pyproject.toml +1 -1
  3. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/core/client_wrapper.py +2 -2
  4. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/ingest.py +83 -38
  5. {groundx-2.3.8 → groundx-2.4.0}/LICENSE +0 -0
  6. {groundx-2.3.8 → groundx-2.4.0}/README.md +0 -0
  7. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/__init__.py +0 -0
  8. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/buckets/__init__.py +0 -0
  9. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/buckets/client.py +0 -0
  10. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/buckets/raw_client.py +0 -0
  11. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/client.py +0 -0
  12. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/core/__init__.py +0 -0
  13. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/core/api_error.py +0 -0
  14. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/core/datetime_utils.py +0 -0
  15. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/core/file.py +0 -0
  16. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/core/force_multipart.py +0 -0
  17. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/core/http_client.py +0 -0
  18. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/core/http_response.py +0 -0
  19. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/core/jsonable_encoder.py +0 -0
  20. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/core/pydantic_utilities.py +0 -0
  21. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/core/query_encoder.py +0 -0
  22. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/core/remove_none_from_dict.py +0 -0
  23. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/core/request_options.py +0 -0
  24. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/core/serialization.py +0 -0
  25. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/csv_splitter.py +0 -0
  26. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/customer/__init__.py +0 -0
  27. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/customer/client.py +0 -0
  28. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/customer/raw_client.py +0 -0
  29. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/documents/__init__.py +0 -0
  30. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/documents/client.py +0 -0
  31. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/documents/raw_client.py +0 -0
  32. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/environment.py +0 -0
  33. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/errors/__init__.py +0 -0
  34. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/errors/bad_request_error.py +0 -0
  35. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/errors/unauthorized_error.py +0 -0
  36. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/groups/__init__.py +0 -0
  37. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/groups/client.py +0 -0
  38. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/groups/raw_client.py +0 -0
  39. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/health/__init__.py +0 -0
  40. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/health/client.py +0 -0
  41. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/health/raw_client.py +0 -0
  42. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/py.typed +0 -0
  43. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/search/__init__.py +0 -0
  44. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/search/client.py +0 -0
  45. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/search/raw_client.py +0 -0
  46. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/search/types/__init__.py +0 -0
  47. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/search/types/search_content_request_id.py +0 -0
  48. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/__init__.py +0 -0
  49. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/bounding_box_detail.py +0 -0
  50. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/bucket_detail.py +0 -0
  51. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/bucket_list_response.py +0 -0
  52. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/bucket_response.py +0 -0
  53. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/bucket_update_detail.py +0 -0
  54. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/bucket_update_response.py +0 -0
  55. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/customer_detail.py +0 -0
  56. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/customer_response.py +0 -0
  57. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/document.py +0 -0
  58. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/document_detail.py +0 -0
  59. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/document_list_response.py +0 -0
  60. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/document_local_ingest_request.py +0 -0
  61. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/document_lookup_response.py +0 -0
  62. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/document_response.py +0 -0
  63. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/document_type.py +0 -0
  64. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/group_detail.py +0 -0
  65. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/group_list_response.py +0 -0
  66. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/group_response.py +0 -0
  67. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/health_response.py +0 -0
  68. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/health_response_health.py +0 -0
  69. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/health_service.py +0 -0
  70. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/health_service_status.py +0 -0
  71. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/ingest_local_document.py +0 -0
  72. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/ingest_local_document_metadata.py +0 -0
  73. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/ingest_remote_document.py +0 -0
  74. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/ingest_response.py +0 -0
  75. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/ingest_status.py +0 -0
  76. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/ingest_status_light.py +0 -0
  77. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/ingest_status_progress.py +0 -0
  78. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/ingest_status_progress_cancelled.py +0 -0
  79. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/ingest_status_progress_complete.py +0 -0
  80. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/ingest_status_progress_errors.py +0 -0
  81. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/ingest_status_progress_processing.py +0 -0
  82. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/message_response.py +0 -0
  83. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/meter_detail.py +0 -0
  84. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/process_level.py +0 -0
  85. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/processes_status_response.py +0 -0
  86. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/processing_status.py +0 -0
  87. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/search_response.py +0 -0
  88. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/search_response_search.py +0 -0
  89. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/search_result_item.py +0 -0
  90. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/search_result_item_pages_item.py +0 -0
  91. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/sort.py +0 -0
  92. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/sort_order.py +0 -0
  93. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/subscription_detail.py +0 -0
  94. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/subscription_detail_meters.py +0 -0
  95. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/types/website_source.py +0 -0
  96. {groundx-2.3.8 → groundx-2.4.0}/src/groundx/version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: groundx
3
- Version: 2.3.8
3
+ Version: 2.4.0
4
4
  Summary:
5
5
  License: MIT
6
6
  Requires-Python: >=3.8,<4.0
@@ -3,7 +3,7 @@ name = "groundx"
3
3
 
4
4
  [tool.poetry]
5
5
  name = "groundx"
6
- version = "2.3.8"
6
+ version = "2.4.0"
7
7
  description = ""
8
8
  readme = "README.md"
9
9
  authors = []
@@ -14,10 +14,10 @@ class BaseClientWrapper:
14
14
 
15
15
  def get_headers(self) -> typing.Dict[str, str]:
16
16
  headers: typing.Dict[str, str] = {
17
- "User-Agent": "groundx/2.3.8",
17
+ "User-Agent": "groundx/2.4.0",
18
18
  "X-Fern-Language": "Python",
19
19
  "X-Fern-SDK-Name": "groundx",
20
- "X-Fern-SDK-Version": "2.3.8",
20
+ "X-Fern-SDK-Version": "2.4.0",
21
21
  }
22
22
  headers["X-API-Key"] = self.api_key
23
23
  return headers
@@ -125,7 +125,7 @@ def prep_documents(
125
125
  return remote_documents, local_documents
126
126
 
127
127
 
128
- def split_doc(file):
128
+ def split_doc(file: Path) -> typing.List[Path]:
129
129
  if file.is_file() and (
130
130
  file.suffix.lower() in ALLOWED_SUFFIXES
131
131
  or file.suffix.lower() in SUFFIX_ALIASES
@@ -142,9 +142,11 @@ class GroundX(GroundXBase):
142
142
  self,
143
143
  *,
144
144
  documents: typing.Sequence[Document],
145
- batch_size: typing.Optional[int] = 10,
146
- wait_for_complete: typing.Optional[bool] = False,
147
- upload_api: typing.Optional[str] = "https://api.eyelevel.ai/upload/file",
145
+ batch_size: int = 10,
146
+ wait_for_complete: bool = False,
147
+ upload_api: str = "https://api.eyelevel.ai/upload/file",
148
+ callback_url: typing.Optional[str] = None,
149
+ callback_data: typing.Optional[str] = None,
148
150
  request_options: typing.Optional[RequestOptions] = None,
149
151
  ) -> IngestResponse:
150
152
  """
@@ -165,6 +167,13 @@ class GroundX(GroundXBase):
165
167
  # and returns a presigned URL in a JSON dictionary with key 'URL'
166
168
  upload_api : typing.Optional[str]
167
169
 
170
+ # an endpoint that will receive processing event updates as POST
171
+ callback_url : typing.Optional[str]
172
+
173
+ # a string that is returned, along with processing event updates,
174
+ # to the callback URL.
175
+ callback_data : typing.Optional[str]
176
+
168
177
  request_options : typing.Optional[RequestOptions]
169
178
  Request-specific configuration.
170
179
 
@@ -209,6 +218,8 @@ class GroundX(GroundXBase):
209
218
  if len(remote_batch) >= n:
210
219
  ingest = self.documents.ingest_remote(
211
220
  documents=remote_batch,
221
+ callback_url=callback_url,
222
+ callback_data=callback_data,
212
223
  request_options=request_options,
213
224
  )
214
225
  ingest, progress = self._monitor_batch(ingest, progress, pbar)
@@ -222,6 +233,8 @@ class GroundX(GroundXBase):
222
233
  if remote_batch:
223
234
  ingest = self.documents.ingest_remote(
224
235
  documents=remote_batch,
236
+ callback_data=callback_data,
237
+ callback_url=callback_url,
225
238
  request_options=request_options,
226
239
  )
227
240
  ingest, progress = self._monitor_batch(ingest, progress, pbar)
@@ -243,6 +256,8 @@ class GroundX(GroundXBase):
243
256
 
244
257
  ingest = self.documents.ingest_remote(
245
258
  documents=up_docs,
259
+ callback_url=callback_url,
260
+ callback_data=callback_data,
246
261
  request_options=request_options,
247
262
  )
248
263
  ingest, progress = self._monitor_batch(ingest, progress, pbar)
@@ -258,6 +273,8 @@ class GroundX(GroundXBase):
258
273
 
259
274
  ingest = self.documents.ingest_remote(
260
275
  documents=up_docs,
276
+ callback_data=callback_data,
277
+ callback_url=callback_url,
261
278
  request_options=request_options,
262
279
  )
263
280
  ingest, progress = self._monitor_batch(ingest, progress, pbar)
@@ -270,11 +287,13 @@ class GroundX(GroundXBase):
270
287
  raise ValueError("You have sent too many documents in this request")
271
288
 
272
289
 
273
- up_docs, _ = self._process_local(local_documents, upload_api)
290
+ up_docs, _ = self._process_local(local_documents, upload_api, 0, None)
274
291
  remote_documents.extend(up_docs)
275
292
 
276
293
  return self.documents.ingest_remote(
277
294
  documents=remote_documents,
295
+ callback_url=callback_url,
296
+ callback_data=callback_data,
278
297
  request_options=request_options,
279
298
  )
280
299
 
@@ -283,8 +302,10 @@ class GroundX(GroundXBase):
283
302
  *,
284
303
  bucket_id: int,
285
304
  path: str,
286
- batch_size: typing.Optional[int] = 10,
287
- upload_api: typing.Optional[str] = "https://api.eyelevel.ai/upload/file",
305
+ batch_size: int = 10,
306
+ upload_api: str = "https://api.eyelevel.ai/upload/file",
307
+ callback_url: typing.Optional[str] = None,
308
+ callback_data: typing.Optional[str] = None,
288
309
  request_options: typing.Optional[RequestOptions] = None,
289
310
  ):
290
311
  """
@@ -300,6 +321,13 @@ class GroundX(GroundXBase):
300
321
  # and returns a presigned URL in a JSON dictionary with key 'URL'
301
322
  upload_api : typing.Optional[str]
302
323
 
324
+ # an endpoint that will receive processing event updates as POST
325
+ callback_url : typing.Optional[str]
326
+
327
+ # a string that is returned, along with processing event updates,
328
+ # to the callback URL.
329
+ callback_data : typing.Optional[str]
330
+
303
331
  request_options : typing.Optional[RequestOptions]
304
332
  Request-specific configuration.
305
333
 
@@ -357,7 +385,7 @@ class GroundX(GroundXBase):
357
385
  file_size = file.stat().st_size
358
386
 
359
387
  if (current_batch_size + file_size > MAX_BATCH_SIZE_BYTES) or (len(current_batch) >= n):
360
- self._upload_file_batch(bucket_id, current_batch, upload_api, request_options, pbar)
388
+ self._upload_file_batch(bucket_id, current_batch, upload_api, callback_url, callback_data, request_options, pbar)
361
389
  current_batch = []
362
390
  current_batch_size = 0
363
391
 
@@ -365,13 +393,13 @@ class GroundX(GroundXBase):
365
393
  current_batch_size += file_size
366
394
 
367
395
  if current_batch:
368
- self._upload_file_batch(bucket_id, current_batch, upload_api, request_options, pbar)
396
+ self._upload_file_batch(bucket_id, current_batch, upload_api, callback_url, callback_data, request_options, pbar)
369
397
 
370
398
  def _upload_file(
371
399
  self,
372
- endpoint,
373
- file_path,
374
- ):
400
+ endpoint: str,
401
+ file_path: Path,
402
+ ) -> str:
375
403
  file_name = os.path.basename(file_path)
376
404
  file_extension = os.path.splitext(file_name)[1][1:].lower()
377
405
  if f".{file_extension}" in SUFFIX_ALIASES:
@@ -407,12 +435,12 @@ class GroundX(GroundXBase):
407
435
 
408
436
  def _process_local(
409
437
  self,
410
- local_docs,
411
- upload_api,
412
- progress = None,
413
- pbar = None,
414
- ):
415
- remote_docs = []
438
+ local_docs: typing.List[Document],
439
+ upload_api: str,
440
+ progress: float,
441
+ pbar: typing.Optional[typing.Any] = None,
442
+ ) -> typing.Tuple[typing.List[IngestRemoteDocument], float]:
443
+ remote_docs: typing.List[IngestRemoteDocument] = []
416
444
  for d in local_docs:
417
445
  splits = split_doc(Path(os.path.expanduser(d.file_path)))
418
446
 
@@ -439,23 +467,22 @@ class GroundX(GroundXBase):
439
467
  )
440
468
  )
441
469
 
442
- if progress is not None and pbar is not None and pbar.update is not None:
470
+ progress -= 0.25
471
+ if pbar is not None and pbar.update is not None:
443
472
  pbar.update(0.25)
444
- progress -= 0.25
445
473
 
446
474
  return remote_docs, progress
447
475
 
448
476
  def _monitor_batch(
449
477
  self,
450
- ingest,
451
- progress,
452
- pbar,
453
- ):
454
- completed_files = set()
478
+ ingest: IngestResponse,
479
+ progress: float,
480
+ pbar: typing.Any,
481
+ ) -> typing.Tuple[IngestResponse, float]:
482
+ completed_files: typing.Set[str] = set()
455
483
 
456
484
  while (
457
- ingest is not None
458
- and ingest.ingest.status not in ["complete", "error", "cancelled"]
485
+ ingest.ingest.status not in ["complete", "error", "cancelled"]
459
486
  ):
460
487
  time.sleep(3)
461
488
  ingest = self.documents.get_processing_status_by_id(ingest.ingest.process_id)
@@ -494,13 +521,15 @@ class GroundX(GroundXBase):
494
521
 
495
522
  def _upload_file_batch(
496
523
  self,
497
- bucket_id,
498
- batch,
499
- upload_api,
500
- request_options,
501
- pbar,
502
- ):
503
- docs = []
524
+ bucket_id: int,
525
+ batch: typing.List[Path],
526
+ upload_api: str,
527
+ callback_url: typing.Optional[str],
528
+ callback_data: typing.Optional[str],
529
+ request_options: typing.Optional[RequestOptions],
530
+ pbar: typing.Any,
531
+ ) -> None:
532
+ docs: typing.List[Document] = []
504
533
 
505
534
  progress = float(len(batch))
506
535
  for file in batch:
@@ -526,7 +555,12 @@ class GroundX(GroundXBase):
526
555
  progress -= 0.25
527
556
 
528
557
  if docs:
529
- ingest = self.ingest(documents=docs, request_options=request_options)
558
+ ingest = self.ingest(
559
+ documents=docs,
560
+ callback_data=callback_data,
561
+ callback_url=callback_url,
562
+ request_options=request_options,
563
+ )
530
564
  ingest, progress = self._monitor_batch(ingest, progress, pbar)
531
565
 
532
566
  if progress > 0:
@@ -540,6 +574,8 @@ class AsyncGroundX(AsyncGroundXBase):
540
574
  *,
541
575
  documents: typing.Sequence[Document],
542
576
  upload_api: str = "https://api.eyelevel.ai/upload/file",
577
+ callback_url: typing.Optional[str] = None,
578
+ callback_data: typing.Optional[str] = None,
543
579
  request_options: typing.Optional[RequestOptions] = None,
544
580
  ) -> IngestResponse:
545
581
  """
@@ -553,6 +589,13 @@ class AsyncGroundX(AsyncGroundXBase):
553
589
  # and returns a presigned URL in a JSON dictionary with key 'URL'
554
590
  upload_api : typing.Optional[str]
555
591
 
592
+ # an endpoint that will receive processing event updates as POST
593
+ callback_url : typing.Optional[str]
594
+
595
+ # a string that is returned, along with processing event updates,
596
+ # to the callback URL.
597
+ callback_data : typing.Optional[str]
598
+
556
599
  request_options : typing.Optional[RequestOptions]
557
600
  Request-specific configuration.
558
601
 
@@ -621,14 +664,16 @@ class AsyncGroundX(AsyncGroundXBase):
621
664
 
622
665
  return await self.documents.ingest_remote(
623
666
  documents=remote_documents,
667
+ callback_url=callback_url,
668
+ callback_data=callback_data,
624
669
  request_options=request_options,
625
670
  )
626
671
 
627
672
  def _upload_file(
628
673
  self,
629
- endpoint,
630
- file_path,
631
- ):
674
+ endpoint: str,
675
+ file_path: Path,
676
+ ) -> str:
632
677
  file_name = os.path.basename(file_path)
633
678
  file_extension = os.path.splitext(file_name)[1][1:].lower()
634
679
  if f".{file_extension}" in SUFFIX_ALIASES:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes