indexify 0.0.28__py3-none-any.whl → 0.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.
indexify/__init__.py CHANGED
@@ -2,10 +2,12 @@ from .index import Index
2
2
  from .client import IndexifyClient
3
3
  from .extraction_policy import ExtractionGraph
4
4
  from .client import IndexifyClient, Document, generate_hash_from_string, generate_unique_hex_id
5
+ from .data_containers import Content
5
6
  from .settings import DEFAULT_SERVICE_URL
6
7
 
7
8
  __all__ = [
8
9
  "Index",
10
+ "Content",
9
11
  "Document",
10
12
  "IndexifyClient",
11
13
  "ExtractionGraph",
indexify/client.py CHANGED
@@ -10,7 +10,7 @@ from .extraction_policy import ExtractionPolicy, ExtractionGraph
10
10
  from .index import Index
11
11
  from .utils import json_set_default
12
12
  from .error import Error
13
- from .data_containers import TextChunk
13
+ from .data_containers import TextChunk, Content
14
14
  from indexify.exceptions import ApiException
15
15
  from dataclasses import dataclass
16
16
  from typing import List, Optional, Union, Dict
@@ -153,7 +153,9 @@ class IndexifyClient:
153
153
  try:
154
154
  response = self._client.request(method, timeout=self._timeout, **kwargs)
155
155
  status_code = str(response.status_code)
156
- if status_code.startswith("4") or status_code.startswith("5"):
156
+ if status_code.startswith("4"):
157
+ raise ApiException("status code: " + status_code + " request args: " + str(kwargs))
158
+ if status_code.startswith("5"):
157
159
  raise ApiException(response.text)
158
160
  # error = Error.from_tonic_error_string(str(response.url), response.text)
159
161
  # self.__print_additional_error_context(error)
@@ -511,6 +513,30 @@ class IndexifyClient:
511
513
  headers={"Content-Type": "application/json"},
512
514
  )
513
515
  return response.json()["results"]
516
+
517
+ def list_content(self, extraction_graph: str, extraction_policy: str = "", start_id: str="", limit: int=10) -> List[Content]:
518
+ """
519
+ List content in the current namespace.
520
+
521
+ Args:
522
+ - extraction_graph (str): extraction graph name
523
+ - start_index (str): start index for pagination
524
+ - limit (int): number of items to return
525
+ """
526
+ params = {"graph": extraction_graph, "start_id": start_id, "limit": limit}
527
+ if extraction_policy:
528
+ params["source"] = extraction_policy
529
+ else:
530
+ params["source"] = "ingestion"
531
+ response = self.get(
532
+ f"namespaces/{self.namespace}/content",
533
+ params=params,
534
+ )
535
+ content_list = response.json()["content_list"]
536
+ content = []
537
+ for item in content_list:
538
+ content.append(Content.from_dict(item))
539
+ return content
514
540
 
515
541
  def upload_file(
516
542
  self,
@@ -2,6 +2,25 @@ from enum import Enum
2
2
  from typing import List
3
3
  from dataclasses import dataclass, field
4
4
 
5
+ @dataclass
6
+ class Content:
7
+ id: str
8
+ parent_id: str
9
+ labels: dict[str, any]
10
+ extraction_graph_names: List[str]
11
+ extraction_policy: str
12
+ mime_type: str
13
+
14
+ @classmethod
15
+ def from_dict(cls, json: dict):
16
+ return Content(
17
+ id=json["id"],
18
+ parent_id=json["parent_id"],
19
+ labels=json["labels"],
20
+ extraction_graph_names=json["extraction_graph_names"],
21
+ extraction_policy=json["source"],
22
+ mime_type=json["mime_type"],
23
+ )
5
24
 
6
25
  @dataclass
7
26
  class TextChunk:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: indexify
3
- Version: 0.0.28
3
+ Version: 0.0.29
4
4
  Summary: Python Client for Indexify
5
5
  Home-page: https://github.com/tensorlakeai/indexify
6
6
  License: Apache 2.0
@@ -1,6 +1,6 @@
1
- indexify/__init__.py,sha256=Y40-Ur_tL7kGGs-reh9BTfEYGe-KyGxgdg-CmoFsXRQ,473
2
- indexify/client.py,sha256=qECQvvVPvzMDra8OQ-94u7J5ABFWSEmEx_uIEdJ3RiU,22159
3
- indexify/data_containers.py,sha256=r1wxJPtsmXbyKvb17fqxm-dPjKz51oZ62f8A8Zxls1c,361
1
+ indexify/__init__.py,sha256=xqymbwqaiHiWXFpm7Cll2j-_V1lNQH2EEGlevtCTZK4,525
2
+ indexify/client.py,sha256=14O63O_D1xatnRItS6ecs9juREooYQKelDz0Zc9TSrY,23197
3
+ indexify/data_containers.py,sha256=fIX_rghpojrCUtmZ0grywoq_HWniDgN1mnR7yXDej-Y,874
4
4
  indexify/error.py,sha256=3umTeYb0ugtUyehV1ibfvaeACxAONPyWPc-1HRN4d1M,856
5
5
  indexify/exceptions.py,sha256=vjd5SPPNFIEW35GorSIodsqvm9RKHQm9kdp8t9gv-WM,111
6
6
  indexify/extraction_policy.py,sha256=POluredrBw6DzTN0OyfPLaLFP5-2DoWGRK0V6w68R28,2080
@@ -8,7 +8,7 @@ indexify/extractor.py,sha256=sWFLlXHgEfWlmiKAXN6ytUt_uG7th-XGNHqz-TG39gs,1216
8
8
  indexify/index.py,sha256=RvxYhJXEth-GKvqzlMiz5PuN1eIbZk84pt20piA1Gsw,504
9
9
  indexify/settings.py,sha256=LSaWZ0ADIVmUv6o6dHWRC3-Ry5uLbCw2sBSg1e_U7UM,99
10
10
  indexify/utils.py,sha256=rDN2lrsAs9noJEIjfx6ukmC2SAIyrlUt7QU-kaBjujM,125
11
- indexify-0.0.28.dist-info/LICENSE.txt,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
12
- indexify-0.0.28.dist-info/METADATA,sha256=3r9wATECrfXFfmI68yU2cUOtrOBR4nT_ajPnag8IdZg,1798
13
- indexify-0.0.28.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
14
- indexify-0.0.28.dist-info/RECORD,,
11
+ indexify-0.0.29.dist-info/LICENSE.txt,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
12
+ indexify-0.0.29.dist-info/METADATA,sha256=c-2NDf8ayGuboLyMkc0tVXACfp9L30QbxQTCARfuFeA,1798
13
+ indexify-0.0.29.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
14
+ indexify-0.0.29.dist-info/RECORD,,