chunkr-ai 0.0.23__py3-none-any.whl → 0.0.24__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.
@@ -11,12 +11,20 @@ from typing import BinaryIO, Union
11
11
 
12
12
 
13
13
  class ChunkrBase(HeadersMixin):
14
- """Base class with shared functionality for Chunkr API clients."""
15
-
16
- def __init__(self, url: str = None, api_key: str = None):
14
+ """Base class with shared functionality for Chunkr API clients.
15
+
16
+ Args:
17
+ url: The base URL of the Chunkr API. Defaults to the value of the CHUNKR_URL environment variable, or "https://api.chunkr.ai" if not set.
18
+ api_key: The API key to use for authentication. Defaults to the value of the CHUNKR_API_KEY environment variable, or None if not set.
19
+ raise_on_failure: Whether to raise an exception if the task fails. Defaults to False.
20
+ """
21
+
22
+ def __init__(self, url: str = None, api_key: str = None, raise_on_failure: bool = False):
17
23
  load_dotenv()
18
24
  self.url = url or os.getenv("CHUNKR_URL") or "https://api.chunkr.ai"
19
25
  self._api_key = api_key or os.getenv("CHUNKR_API_KEY")
26
+ self.raise_on_failure = raise_on_failure
27
+
20
28
  if not self._api_key:
21
29
  raise ValueError(
22
30
  "API key must be provided either directly, in .env file, or as CHUNKR_API_KEY environment variable. You can get an api key at: https://www.chunkr.ai"
chunkr_ai/api/protocol.py CHANGED
@@ -5,15 +5,10 @@ from httpx import AsyncClient
5
5
  @runtime_checkable
6
6
  class ChunkrClientProtocol(Protocol):
7
7
  """Protocol defining the interface for Chunkr clients"""
8
-
9
- url: str
10
- _api_key: str
8
+
9
+ raise_on_failure: bool = True
11
10
  _client: Optional[AsyncClient] = None
12
11
 
13
- def get_api_key(self) -> str:
14
- """Get the API key"""
15
- ...
16
-
17
12
  def _headers(self) -> dict:
18
13
  """Return headers required for API requests"""
19
14
  ...
@@ -30,7 +30,9 @@ class TaskResponse(BaseModel, Generic[T]):
30
30
  def _check_status(self) -> Optional[T]:
31
31
  """Helper method to check task status and handle completion/failure"""
32
32
  if self.status == "Failed":
33
- raise ValueError(self.message)
33
+ if getattr(self._client, 'raise_on_failure', True):
34
+ raise ValueError(self.message)
35
+ return self
34
36
  if self.status not in ("Starting", "Processing"):
35
37
  return self
36
38
  return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: chunkr-ai
3
- Version: 0.0.23
3
+ Version: 0.0.24
4
4
  Summary: Python client for Chunkr: open source document intelligence
5
5
  Author-email: Ishaan Kapoor <ishaan@lumina.sh>
6
6
  License: MIT License
@@ -35,6 +35,7 @@ Provides-Extra: test
35
35
  Requires-Dist: pytest>=7.0.0; extra == "test"
36
36
  Requires-Dist: pytest-xdist>=3.0.0; extra == "test"
37
37
  Requires-Dist: pytest-asyncio>=0.21.0; extra == "test"
38
+ Requires-Dist: ruff>=0.9.3; extra == "test"
38
39
 
39
40
  # Chunkr Python Client
40
41
 
@@ -4,14 +4,14 @@ chunkr_ai/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  chunkr_ai/api/api.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  chunkr_ai/api/auth.py,sha256=hlv0GiUmlsbFO1wLL9sslqOnsBSoBqkL_6Mk2SDvxgE,413
6
6
  chunkr_ai/api/chunkr.py,sha256=XTXJFs0xjYY3w3N4fSQcxtJFBtNfzFYYkh6nDlFz4cY,2714
7
- chunkr_ai/api/chunkr_base.py,sha256=OkycHDHkdGX953_ab0XdYBnPDzSXYE30L3j52hBb8D0,5046
7
+ chunkr_ai/api/chunkr_base.py,sha256=4SXA-gdZd1w2zZeeMdy4xog0NKOrKjmo6IMvSl9KSBg,5538
8
8
  chunkr_ai/api/config.py,sha256=NmPTsDvcjkvNx0gNzDTz-oFG5rQC7jm-H70O_crJCw8,4478
9
9
  chunkr_ai/api/decorators.py,sha256=y_Z9z0O2XXiX9z6jWDwdbCPdQyMLnjE0pGkJjHQEv_Q,2652
10
10
  chunkr_ai/api/misc.py,sha256=5Q2K713VPwf3S2519KTzjT9PKhTEBgBMk1d8NNnmpZ0,5717
11
- chunkr_ai/api/protocol.py,sha256=Nt8aWr4ouVwCvoLqVI5vnXJhT2cvxt0sQC-svUk2G5w,458
12
- chunkr_ai/api/task_response.py,sha256=aAx7otuvsp-A0U5EaHRkbnRJMoLI8N4lOMo8bS8emJc,3843
13
- chunkr_ai-0.0.23.dist-info/LICENSE,sha256=w3R12yNDyZpMiy2lxy_hvNbsldC75ww79sF0u11rkho,1069
14
- chunkr_ai-0.0.23.dist-info/METADATA,sha256=QsO__q1V9SJYz2uugyzj_CZpOuPie6AhLfY39hTNaOM,6952
15
- chunkr_ai-0.0.23.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
16
- chunkr_ai-0.0.23.dist-info/top_level.txt,sha256=0IZY7PZIiS8bw5r4NUQRUQ-ATi-L_3vLQVq3ZLouOW8,10
17
- chunkr_ai-0.0.23.dist-info/RECORD,,
11
+ chunkr_ai/api/protocol.py,sha256=LjPrYSq52m1afIlAo0yVGXlGZxPRh8J6g7S4PAit3Zo,388
12
+ chunkr_ai/api/task_response.py,sha256=hcHsBgX-2C5Px5Bu0IKk33K_AkqHSEM1Wu2zkcPh9to,3935
13
+ chunkr_ai-0.0.24.dist-info/LICENSE,sha256=w3R12yNDyZpMiy2lxy_hvNbsldC75ww79sF0u11rkho,1069
14
+ chunkr_ai-0.0.24.dist-info/METADATA,sha256=JyDI8EkFaJQQ7vIo2osHxXmeuNqhQ0UWjgUMHSFIYow,6996
15
+ chunkr_ai-0.0.24.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
16
+ chunkr_ai-0.0.24.dist-info/top_level.txt,sha256=0IZY7PZIiS8bw5r4NUQRUQ-ATi-L_3vLQVq3ZLouOW8,10
17
+ chunkr_ai-0.0.24.dist-info/RECORD,,