openaivec 0.13.0__py3-none-any.whl → 0.13.1__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.
- openaivec/embeddings.py +3 -3
- openaivec/responses.py +3 -3
- openaivec/util.py +18 -12
- {openaivec-0.13.0.dist-info → openaivec-0.13.1.dist-info}/METADATA +1 -1
- {openaivec-0.13.0.dist-info → openaivec-0.13.1.dist-info}/RECORD +7 -7
- {openaivec-0.13.0.dist-info → openaivec-0.13.1.dist-info}/WHEEL +0 -0
- {openaivec-0.13.0.dist-info → openaivec-0.13.1.dist-info}/licenses/LICENSE +0 -0
openaivec/embeddings.py
CHANGED
|
@@ -4,7 +4,7 @@ from typing import List
|
|
|
4
4
|
|
|
5
5
|
import numpy as np
|
|
6
6
|
from numpy.typing import NDArray
|
|
7
|
-
from openai import AsyncOpenAI, OpenAI, RateLimitError
|
|
7
|
+
from openai import AsyncOpenAI, InternalServerError, OpenAI, RateLimitError
|
|
8
8
|
|
|
9
9
|
from .log import observe
|
|
10
10
|
from .proxy import AsyncBatchingMapProxy, BatchingMapProxy
|
|
@@ -47,7 +47,7 @@ class BatchEmbeddings:
|
|
|
47
47
|
return cls(client=client, model_name=model_name, cache=BatchingMapProxy(batch_size=batch_size))
|
|
48
48
|
|
|
49
49
|
@observe(_LOGGER)
|
|
50
|
-
@backoff(
|
|
50
|
+
@backoff(exceptions=[RateLimitError, InternalServerError], scale=1, max_retries=12)
|
|
51
51
|
def _embed_chunk(self, inputs: List[str]) -> List[NDArray[np.float32]]:
|
|
52
52
|
"""Embed one minibatch of strings.
|
|
53
53
|
|
|
@@ -155,7 +155,7 @@ class AsyncBatchEmbeddings:
|
|
|
155
155
|
)
|
|
156
156
|
|
|
157
157
|
@observe(_LOGGER)
|
|
158
|
-
@backoff_async(
|
|
158
|
+
@backoff_async(exceptions=[RateLimitError, InternalServerError], scale=1, max_retries=12)
|
|
159
159
|
async def _embed_chunk(self, inputs: List[str]) -> List[NDArray[np.float32]]:
|
|
160
160
|
"""Embed one minibatch of strings asynchronously.
|
|
161
161
|
|
openaivec/responses.py
CHANGED
|
@@ -2,7 +2,7 @@ from dataclasses import dataclass, field
|
|
|
2
2
|
from logging import Logger, getLogger
|
|
3
3
|
from typing import Generic, List, Type, cast
|
|
4
4
|
|
|
5
|
-
from openai import AsyncOpenAI, OpenAI, RateLimitError
|
|
5
|
+
from openai import AsyncOpenAI, InternalServerError, OpenAI, RateLimitError
|
|
6
6
|
from openai.types.responses import ParsedResponse
|
|
7
7
|
from pydantic import BaseModel
|
|
8
8
|
|
|
@@ -206,7 +206,7 @@ class BatchResponses(Generic[ResponseFormat]):
|
|
|
206
206
|
)
|
|
207
207
|
|
|
208
208
|
@observe(_LOGGER)
|
|
209
|
-
@backoff(
|
|
209
|
+
@backoff(exceptions=[RateLimitError, InternalServerError], scale=1, max_retries=12)
|
|
210
210
|
def _request_llm(self, user_messages: List[Message[str]]) -> ParsedResponse[Response[ResponseFormat]]:
|
|
211
211
|
"""Make a single call to the OpenAI JSON‑mode endpoint.
|
|
212
212
|
|
|
@@ -400,7 +400,7 @@ class AsyncBatchResponses(Generic[ResponseFormat]):
|
|
|
400
400
|
)
|
|
401
401
|
|
|
402
402
|
@observe(_LOGGER)
|
|
403
|
-
@backoff_async(
|
|
403
|
+
@backoff_async(exceptions=[RateLimitError, InternalServerError], scale=1, max_retries=12)
|
|
404
404
|
async def _request_llm(self, user_messages: List[Message[str]]) -> ParsedResponse[Response[ResponseFormat]]:
|
|
405
405
|
"""Make a single async call to the OpenAI JSON‑mode endpoint.
|
|
406
406
|
|
openaivec/util.py
CHANGED
|
@@ -3,7 +3,7 @@ import functools
|
|
|
3
3
|
import re
|
|
4
4
|
import time
|
|
5
5
|
from dataclasses import dataclass
|
|
6
|
-
from typing import Awaitable, Callable, List, TypeVar
|
|
6
|
+
from typing import Awaitable, Callable, List, Type, TypeVar
|
|
7
7
|
|
|
8
8
|
import numpy as np
|
|
9
9
|
import tiktoken
|
|
@@ -34,24 +34,28 @@ def get_exponential_with_cutoff(scale: float) -> float:
|
|
|
34
34
|
return v
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def backoff(
|
|
37
|
+
def backoff(
|
|
38
|
+
exceptions: List[Type[Exception]],
|
|
39
|
+
scale: int | None = None,
|
|
40
|
+
max_retries: int | None = None,
|
|
41
|
+
) -> Callable[..., V]:
|
|
38
42
|
"""Decorator implementing exponential back‑off retry logic.
|
|
39
43
|
|
|
40
44
|
Args:
|
|
41
|
-
|
|
45
|
+
exceptions (List[Type[Exception]]): List of exception types that trigger a retry.
|
|
42
46
|
scale (int | None): Initial scale parameter for the exponential jitter.
|
|
43
47
|
This scale is used as the mean for the first delay's exponential
|
|
44
48
|
distribution and doubles with each subsequent retry. If ``None``,
|
|
45
49
|
an initial scale of 1.0 is used.
|
|
46
|
-
max_retries (
|
|
50
|
+
max_retries (int | None): Maximum number of retries. ``None`` means
|
|
47
51
|
retry indefinitely.
|
|
48
52
|
|
|
49
53
|
Returns:
|
|
50
54
|
Callable[..., V]: A decorated function that retries on the specified
|
|
51
|
-
|
|
55
|
+
exceptions with exponential back‑off.
|
|
52
56
|
|
|
53
57
|
Raises:
|
|
54
|
-
|
|
58
|
+
Exception: Re‑raised when the maximum number of retries is exceeded.
|
|
55
59
|
"""
|
|
56
60
|
|
|
57
61
|
def decorator(func: Callable[..., V]) -> Callable[..., V]:
|
|
@@ -65,7 +69,7 @@ def backoff(exception: type[Exception], scale: int | None = None, max_retries: i
|
|
|
65
69
|
while True:
|
|
66
70
|
try:
|
|
67
71
|
return func(*args, **kwargs)
|
|
68
|
-
except
|
|
72
|
+
except tuple(exceptions):
|
|
69
73
|
attempt += 1
|
|
70
74
|
if max_retries is not None and attempt >= max_retries:
|
|
71
75
|
raise
|
|
@@ -83,12 +87,14 @@ def backoff(exception: type[Exception], scale: int | None = None, max_retries: i
|
|
|
83
87
|
|
|
84
88
|
|
|
85
89
|
def backoff_async(
|
|
86
|
-
|
|
90
|
+
exceptions: List[Type[Exception]],
|
|
91
|
+
scale: int | None = None,
|
|
92
|
+
max_retries: int | None = None,
|
|
87
93
|
) -> Callable[..., Awaitable[V]]:
|
|
88
94
|
"""Asynchronous version of the backoff decorator.
|
|
89
95
|
|
|
90
96
|
Args:
|
|
91
|
-
|
|
97
|
+
exceptions (List[Type[Exception]]): List of exception types that trigger a retry.
|
|
92
98
|
scale (int | None): Initial scale parameter for the exponential jitter.
|
|
93
99
|
This scale is used as the mean for the first delay's exponential
|
|
94
100
|
distribution and doubles with each subsequent retry. If ``None``,
|
|
@@ -98,10 +104,10 @@ def backoff_async(
|
|
|
98
104
|
|
|
99
105
|
Returns:
|
|
100
106
|
Callable[..., Awaitable[V]]: A decorated asynchronous function that
|
|
101
|
-
retries on the specified
|
|
107
|
+
retries on the specified exceptions with exponential back‑off.
|
|
102
108
|
|
|
103
109
|
Raises:
|
|
104
|
-
|
|
110
|
+
Exception: Re‑raised when the maximum number of retries is exceeded.
|
|
105
111
|
"""
|
|
106
112
|
|
|
107
113
|
def decorator(func: Callable[..., Awaitable[V]]) -> Callable[..., Awaitable[V]]:
|
|
@@ -115,7 +121,7 @@ def backoff_async(
|
|
|
115
121
|
while True:
|
|
116
122
|
try:
|
|
117
123
|
return await func(*args, **kwargs)
|
|
118
|
-
except
|
|
124
|
+
except tuple(exceptions):
|
|
119
125
|
attempt += 1
|
|
120
126
|
if max_retries is not None and attempt >= max_retries:
|
|
121
127
|
raise
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
openaivec/__init__.py,sha256=CuUAtLtX5RhFUbgF94UmXjurgL2VaerHTFPjMl0rRlE,236
|
|
2
2
|
openaivec/di.py,sha256=RSAiS9PqtoeobX-MZvAN8VIgaQa5EUMysj9aJwGuM9Y,10646
|
|
3
|
-
openaivec/embeddings.py,sha256=
|
|
3
|
+
openaivec/embeddings.py,sha256=aAAzGAPYg5RybY95-ZHQdnxP12L4XPEJ3tHqqOAkcNY,6950
|
|
4
4
|
openaivec/log.py,sha256=GofgzUpv_xDVuGC-gYmit5Oyu06it1SBXRck6COR5go,1439
|
|
5
5
|
openaivec/model.py,sha256=cXgXMceQpTR46xdn9_9ZQKdLcy6X0i7s1x2lxXJOqyU,2434
|
|
6
6
|
openaivec/pandas_ext.py,sha256=g3fpyCupPMOG4OR60uemySlWfIAsoEO5P15tqxpXkd0,51029
|
|
7
7
|
openaivec/prompt.py,sha256=p_AyCLIhlrxp7JXLoywPuDuBiOVmhuAp0XWlKcRlAGY,17715
|
|
8
8
|
openaivec/provider.py,sha256=2MDI9oyOK-abES5bqa_RS4fXX3rdVu6Wph69KHPFIE0,4077
|
|
9
9
|
openaivec/proxy.py,sha256=36d5Rb69HOhENBpS0xzx0eeJZuIfFBzKH6vEyurK-CA,24337
|
|
10
|
-
openaivec/responses.py,sha256=
|
|
10
|
+
openaivec/responses.py,sha256=335OgA4tFp_4jJf4fOIAx6LbyKIzvQ2pO3IuExheifw,17692
|
|
11
11
|
openaivec/serialize.py,sha256=YbYOAxhw67ELcq48wCCelqp7J4vX42liyIWdl9pjJwU,7325
|
|
12
12
|
openaivec/spark.py,sha256=3cwizW0zjbqA7hb8vmT2POzYlNGNoAp2mnEvcHsmLzg,22855
|
|
13
|
-
openaivec/util.py,sha256=
|
|
13
|
+
openaivec/util.py,sha256=cyiATh_IGnkMU0IBPcLpFMUHjjFB6TjLAug5TdC3vS8,6350
|
|
14
14
|
openaivec/task/__init__.py,sha256=26Kd2eRRfUqRJnYH83sRrbuEuRwshypRRSkTWtT50Tw,6177
|
|
15
15
|
openaivec/task/customer_support/__init__.py,sha256=p_OPWdONia_62F5PS-w83-Rngql_4r8Xhn0p2ArzSUk,1067
|
|
16
16
|
openaivec/task/customer_support/customer_sentiment.py,sha256=2DdJHmG5OcLGC-u12F4b2EaFhy5jEjYunCHU2OUrSus,7587
|
|
@@ -28,7 +28,7 @@ openaivec/task/nlp/sentiment_analysis.py,sha256=-P56GL_krrthu2g6oQiQ7MeA9QR8-m76
|
|
|
28
28
|
openaivec/task/nlp/translation.py,sha256=bp_yr4_0_CwrX9Lw3UQMXdmlXBkc6hsAapAEZudCK00,6618
|
|
29
29
|
openaivec/task/table/__init__.py,sha256=qJ-oPcCUZzn2la_NFO1eGRUTNHgTO2jCR4L5xHp6qpM,83
|
|
30
30
|
openaivec/task/table/fillna.py,sha256=ZKYfcweiA6ODGna986pxG9RXYJZthbfp5XXOeT-WUjg,6557
|
|
31
|
-
openaivec-0.13.
|
|
32
|
-
openaivec-0.13.
|
|
33
|
-
openaivec-0.13.
|
|
34
|
-
openaivec-0.13.
|
|
31
|
+
openaivec-0.13.1.dist-info/METADATA,sha256=yr7unxTrWeoKYJX1fgQPfUmbAEDRYMFgQvtvamsJA8Y,26015
|
|
32
|
+
openaivec-0.13.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
33
|
+
openaivec-0.13.1.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
|
|
34
|
+
openaivec-0.13.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|