indexify 0.0.22__tar.gz → 0.0.23__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: indexify
3
- Version: 0.0.22
3
+ Version: 0.0.23
4
4
  Summary: Python Client for Indexify
5
5
  Home-page: https://github.com/tensorlakeai/indexify
6
6
  License: Apache 2.0
@@ -1,7 +1,7 @@
1
1
  from .index import Index
2
2
  from .client import IndexifyClient
3
- from .extraction_policy import ExtractionPolicy, ExtractionGraphBuilder, ExtractionGraph
4
- from .client import IndexifyClient, Document
3
+ from .extraction_policy import ExtractionGraph
4
+ from .client import IndexifyClient, Document, generate_hash_from_string, generate_unique_hex_id
5
5
  from .settings import DEFAULT_SERVICE_URL
6
6
 
7
7
  __all__ = [
@@ -11,4 +11,6 @@ __all__ = [
11
11
  "ExtractionGraph",
12
12
  "ExtractionGraphBuilder" "ExtractionPolicy",
13
13
  "DEFAULT_SERVICE_URL",
14
+ "generate_hash_from_string",
15
+ "generate_unique_hex_id",
14
16
  ]
@@ -14,11 +14,34 @@ from .data_containers import TextChunk
14
14
  from indexify.exceptions import ApiException
15
15
  from dataclasses import dataclass
16
16
  from typing import List, Optional, Union, Dict
17
+ import logging
17
18
 
18
19
  Document = namedtuple("Document", ["text", "labels", "id"])
19
20
 
20
21
  SQLQueryRow = namedtuple("SQLQueryRow", ["content_id", "data"])
21
22
 
23
+ def generate_unique_hex_id():
24
+ """
25
+ Generate a unique hexadecimal identifier
26
+
27
+ Returns:
28
+ str: a unique hexadecimal string
29
+ """
30
+ return uuid.uuid4().hex[:16]
31
+
32
+ def generate_hash_from_string(input_string: str):
33
+ """
34
+ Generate a hash for the given string and return it as a hexadecimal string.
35
+
36
+ Args:
37
+ input_string (str): The input string to hash.
38
+
39
+ Returns:
40
+ str: The hexadecimal hash of the input string.
41
+ """
42
+ hash_object = hashlib.sha256(input_string.encode())
43
+ return hash_object.hexdigest()[:16]
44
+
22
45
 
23
46
  @dataclass
24
47
  class SqlQueryResult:
@@ -129,9 +152,10 @@ class IndexifyClient:
129
152
  response = self._client.request(method, timeout=self._timeout, **kwargs)
130
153
  status_code = str(response.status_code)
131
154
  if status_code.startswith("4") or status_code.startswith("5"):
132
- error = Error.from_tonic_error_string(str(response.url), response.text)
133
- self.__print_additional_error_context(error)
134
- raise error
155
+ raise ApiException(response.text)
156
+ #error = Error.from_tonic_error_string(str(response.url), response.text)
157
+ #self.__print_additional_error_context(error)
158
+ #raise error
135
159
  except httpx.ConnectError:
136
160
  message = f"Make sure the server is running and accesible at {self._service_url}"
137
161
  error = Error(status="ConnectionError", message=message)
@@ -590,6 +614,7 @@ class IndexifyClient:
590
614
  Returns:
591
615
  str: a unique hexadecimal string
592
616
  """
617
+ logging.warning("This method is deprecated. Use generate_unique_hex_id from indexify instead.")
593
618
  return uuid.uuid4().hex[:16]
594
619
 
595
620
  def generate_hash_from_string(self, input_string: str):
@@ -602,6 +627,7 @@ class IndexifyClient:
602
627
  Returns:
603
628
  str: The hexadecimal hash of the input string.
604
629
  """
630
+ logging.warning("This method is deprecated. Use generate_hash_from_string from indexify instead.")
605
631
  hash_object = hashlib.sha256(input_string.encode())
606
632
  return hash_object.hexdigest()[:16]
607
633
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "indexify"
3
- version = "0.0.22"
3
+ version = "0.0.23"
4
4
  description = "Python Client for Indexify"
5
5
  authors = ["Diptanu Gon Choudhury <diptanuc@gmail.com>", "Vijay Parthasarathy <vijay2win@gmail.com>"]
6
6
  license = "Apache 2.0"
File without changes
File without changes
File without changes
File without changes
File without changes