chunkr-ai 0.0.31__py3-none-any.whl → 0.0.33__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.
@@ -1,6 +1,7 @@
1
- import functools
2
1
  import asyncio
2
+ import functools
3
3
  import httpx
4
+ import nest_asyncio
4
5
  from typing import Callable, Any, TypeVar, Awaitable, Union, overload
5
6
  try:
6
7
  from typing import ParamSpec
@@ -21,6 +22,12 @@ def anywhere():
21
22
  @functools.wraps(async_func)
22
23
  def wrapper(*args: P.args, **kwargs: P.kwargs) -> Union[Awaitable[T], T]:
23
24
  global _sync_loop
25
+
26
+ try:
27
+ nest_asyncio.apply()
28
+ except ImportError:
29
+ pass
30
+
24
31
  try:
25
32
  asyncio.get_running_loop()
26
33
  return async_func(*args, **kwargs)
@@ -61,11 +68,11 @@ def require_task() -> Callable[[Callable[P, Awaitable[T]]], Callable[P, Awaitabl
61
68
  return wrapper
62
69
  return decorator
63
70
 
64
- def retry_on_429(max_retries: int = 25, initial_delay: float = 0.5) -> Callable[[Callable[P, Awaitable[T]]], Callable[P, Awaitable[T]]]:
71
+ def retry_on_429(max_retries: int = 3, initial_delay: float = 0.5) -> Callable[[Callable[P, Awaitable[T]]], Callable[P, Awaitable[T]]]:
65
72
  """Decorator that retries the request when encountering 429 Too Many Requests errors.
66
73
 
67
74
  Args:
68
- max_retries: Maximum number of retry attempts (default: 25)
75
+ max_retries: Maximum number of retry attempts (default: 3)
69
76
  initial_delay: Initial delay in seconds, will be exponentially increased with jitter (default: 0.5)
70
77
  """
71
78
  def decorator(async_func: Callable[P, Awaitable[T]]) -> Callable[P, Awaitable[T]]:
@@ -78,10 +85,10 @@ def retry_on_429(max_retries: int = 25, initial_delay: float = 0.5) -> Callable[
78
85
  return await async_func(*args, **kwargs)
79
86
  except httpx.HTTPStatusError as e:
80
87
  if e.response.status_code != 429:
81
- raise
88
+ raise e
82
89
  if retries >= max_retries:
83
90
  print("Max retries reached")
84
- raise
91
+ raise e
85
92
  retries += 1
86
93
  delay = initial_delay * (2 ** retries)
87
94
  # Use Retry-After header if available
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: chunkr-ai
3
- Version: 0.0.31
3
+ Version: 0.0.33
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
@@ -5,12 +5,12 @@ chunkr_ai/api/auth.py,sha256=hlv0GiUmlsbFO1wLL9sslqOnsBSoBqkL_6Mk2SDvxgE,413
5
5
  chunkr_ai/api/chunkr.py,sha256=VnbuAPlWLqyf8xCCU_kpdybgjVPTwZLarDQoD3uozY0,3065
6
6
  chunkr_ai/api/chunkr_base.py,sha256=giW56fL7xxJphdOTpIH52dXxpNt7OdP8pNiPSqbNjGM,5835
7
7
  chunkr_ai/api/configuration.py,sha256=m8QL6s2j1_xSo9bERzJ3UG5j8cE6o-cZIiQGxsSf7Ow,3805
8
- chunkr_ai/api/decorators.py,sha256=hu3wdd0s7P6askR3Td8g6OM-RoUCggDGv06HQUsMI6E,4284
8
+ chunkr_ai/api/decorators.py,sha256=VJX4qGBIL00K2zY8bh5KAMWv7SltJ38TvPJH06FnFss,4415
9
9
  chunkr_ai/api/misc.py,sha256=gTL8UG_R6bunQdKSXwm_SpyIyTmLprzdX3re_X-mMto,5730
10
10
  chunkr_ai/api/protocol.py,sha256=LjPrYSq52m1afIlAo0yVGXlGZxPRh8J6g7S4PAit3Zo,388
11
11
  chunkr_ai/api/task_response.py,sha256=uvM5uNIImDnivsgujjOh2kxRYuUoqKDhLE1nOH2dJjo,6091
12
- chunkr_ai-0.0.31.dist-info/LICENSE,sha256=w3R12yNDyZpMiy2lxy_hvNbsldC75ww79sF0u11rkho,1069
13
- chunkr_ai-0.0.31.dist-info/METADATA,sha256=nVqhTSTn_YeGrWUgZ-e-CvLE5MMfgxNt3YGuY6hVt9w,6996
14
- chunkr_ai-0.0.31.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
15
- chunkr_ai-0.0.31.dist-info/top_level.txt,sha256=0IZY7PZIiS8bw5r4NUQRUQ-ATi-L_3vLQVq3ZLouOW8,10
16
- chunkr_ai-0.0.31.dist-info/RECORD,,
12
+ chunkr_ai-0.0.33.dist-info/LICENSE,sha256=w3R12yNDyZpMiy2lxy_hvNbsldC75ww79sF0u11rkho,1069
13
+ chunkr_ai-0.0.33.dist-info/METADATA,sha256=mkTrsyFmPtMmCzRoG-3roUJJ3HdZRCJBK3kFVLdJ-FI,6996
14
+ chunkr_ai-0.0.33.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
15
+ chunkr_ai-0.0.33.dist-info/top_level.txt,sha256=0IZY7PZIiS8bw5r4NUQRUQ-ATi-L_3vLQVq3ZLouOW8,10
16
+ chunkr_ai-0.0.33.dist-info/RECORD,,