unique_sdk 0.9.21__py3-none-any.whl → 0.9.22__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.
- unique_sdk/_api_requestor.py +2 -10
- unique_sdk/_util.py +19 -8
- unique_sdk/api_resources/_chat_completion.py +0 -4
- unique_sdk/api_resources/_integrated.py +0 -2
- unique_sdk/api_resources/_search_string.py +0 -3
- {unique_sdk-0.9.21.dist-info → unique_sdk-0.9.22.dist-info}/METADATA +4 -1
- {unique_sdk-0.9.21.dist-info → unique_sdk-0.9.22.dist-info}/RECORD +9 -9
- {unique_sdk-0.9.21.dist-info → unique_sdk-0.9.22.dist-info}/LICENSE +0 -0
- {unique_sdk-0.9.21.dist-info → unique_sdk-0.9.22.dist-info}/WHEEL +0 -0
unique_sdk/_api_requestor.py
CHANGED
|
@@ -353,16 +353,7 @@ class APIRequestor(object):
|
|
|
353
353
|
return resp
|
|
354
354
|
|
|
355
355
|
def handle_error_response(self, rbody, rcode, resp, rheaders) -> NoReturn:
|
|
356
|
-
|
|
357
|
-
error_data = resp["error"]
|
|
358
|
-
except (KeyError, TypeError):
|
|
359
|
-
raise _error.APIError(
|
|
360
|
-
"Invalid response object from API: %r (HTTP response code "
|
|
361
|
-
"was %d)" % (rbody, rcode),
|
|
362
|
-
rbody,
|
|
363
|
-
rcode,
|
|
364
|
-
resp,
|
|
365
|
-
)
|
|
356
|
+
error_data = resp.get("error")
|
|
366
357
|
|
|
367
358
|
err = None
|
|
368
359
|
|
|
@@ -375,6 +366,7 @@ class APIRequestor(object):
|
|
|
375
366
|
raise err
|
|
376
367
|
|
|
377
368
|
def specific_api_error(self, rbody, rcode, resp, rheaders, error_data):
|
|
369
|
+
error_data = error_data or resp
|
|
378
370
|
cause = error_data.get("cause", {})
|
|
379
371
|
if isinstance(cause, str):
|
|
380
372
|
cause = {"error": {"message": cause}, "status": rcode}
|
unique_sdk/_util.py
CHANGED
|
@@ -12,7 +12,7 @@ from typing import Any, Callable, Dict, List, Optional, TypeVar, Union, cast, ov
|
|
|
12
12
|
from typing_extensions import TYPE_CHECKING, Type
|
|
13
13
|
|
|
14
14
|
import unique_sdk # noqa: F401
|
|
15
|
-
from unique_sdk._error import APIError
|
|
15
|
+
from unique_sdk._error import APIConnectionError, APIError, UniqueError
|
|
16
16
|
|
|
17
17
|
if TYPE_CHECKING:
|
|
18
18
|
from unique_sdk._unique_object import UniqueObject
|
|
@@ -209,14 +209,20 @@ def retry_on_error(
|
|
|
209
209
|
while attempts < max_retries:
|
|
210
210
|
try:
|
|
211
211
|
return await func(*args, **kwargs)
|
|
212
|
-
except
|
|
212
|
+
except (APIError, APIConnectionError) as e:
|
|
213
|
+
e = cast(UniqueError, e)
|
|
213
214
|
logger.error(f"Retrying because of {e}")
|
|
214
215
|
should_retry = any(
|
|
215
216
|
err_msg.lower() in str(e).lower() for err_msg in error_messages
|
|
216
217
|
)
|
|
217
218
|
# Add 5xx check if `should_retry_5xx` is True
|
|
218
|
-
|
|
219
|
-
|
|
219
|
+
has_valid_status = (
|
|
220
|
+
hasattr(e, "http_status") and e.http_status is not None
|
|
221
|
+
)
|
|
222
|
+
if should_retry_5xx and has_valid_status:
|
|
223
|
+
should_retry = should_retry or (
|
|
224
|
+
500 <= int(cast(int, e.http_status)) < 600
|
|
225
|
+
)
|
|
220
226
|
|
|
221
227
|
if not should_retry:
|
|
222
228
|
raise e # Raise the error if no retry condition is met
|
|
@@ -235,15 +241,20 @@ def retry_on_error(
|
|
|
235
241
|
while attempts < max_retries:
|
|
236
242
|
try:
|
|
237
243
|
return func(*args, **kwargs)
|
|
238
|
-
except
|
|
244
|
+
except (APIError, APIConnectionError) as e:
|
|
245
|
+
e = cast(UniqueError, e)
|
|
239
246
|
logger.error(f"Retrying because of {e}")
|
|
240
|
-
|
|
241
247
|
should_retry = any(
|
|
242
248
|
err_msg.lower() in str(e).lower() for err_msg in error_messages
|
|
243
249
|
)
|
|
244
250
|
# Add 5xx check if `should_retry_5xx` is True
|
|
245
|
-
|
|
246
|
-
|
|
251
|
+
has_valid_status = (
|
|
252
|
+
hasattr(e, "http_status") and e.http_status is not None
|
|
253
|
+
)
|
|
254
|
+
if should_retry_5xx and has_valid_status:
|
|
255
|
+
should_retry = should_retry or (
|
|
256
|
+
500 <= int(cast(int, e.http_status)) < 600
|
|
257
|
+
)
|
|
247
258
|
|
|
248
259
|
if not should_retry:
|
|
249
260
|
raise e # Raise the error if no retry condition is met
|
|
@@ -37,8 +37,6 @@ class ChatCompletion(APIResource["ChatCompletion"]):
|
|
|
37
37
|
class CreateParams(RequestOptions):
|
|
38
38
|
model: NotRequired[
|
|
39
39
|
Literal[
|
|
40
|
-
"AZURE_GPT_35_TURBO",
|
|
41
|
-
"AZURE_GPT_35_TURBO_16K",
|
|
42
40
|
"AZURE_GPT_4_0613",
|
|
43
41
|
"AZURE_GPT_4_32K_0613",
|
|
44
42
|
]
|
|
@@ -47,8 +45,6 @@ class ChatCompletion(APIResource["ChatCompletion"]):
|
|
|
47
45
|
messages: List[ChatCompletionRequestMessage]
|
|
48
46
|
|
|
49
47
|
model: Literal[
|
|
50
|
-
"AZURE_GPT_35_TURBO",
|
|
51
|
-
"AZURE_GPT_35_TURBO_16K",
|
|
52
48
|
"AZURE_GPT_4_0613",
|
|
53
49
|
"AZURE_GPT_4_32K_0613",
|
|
54
50
|
]
|
|
@@ -20,9 +20,6 @@ class SearchString(APIResource["SearchString"]):
|
|
|
20
20
|
messages: NotRequired[List[HistoryMessage]]
|
|
21
21
|
languageModel: NotRequired[
|
|
22
22
|
Literal[
|
|
23
|
-
"AZURE_GPT_35_TURBO",
|
|
24
|
-
"AZURE_GPT_35_TURBO_0613",
|
|
25
|
-
"AZURE_GPT_35_TURBO_16K",
|
|
26
23
|
"AZURE_GPT_4_0613",
|
|
27
24
|
"AZURE_GPT_4_32K_0613",
|
|
28
25
|
"AZURE_GPT_4_TURBO_1106",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: unique_sdk
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.22
|
|
4
4
|
Summary:
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Martin Fadler
|
|
@@ -940,6 +940,9 @@ All notable changes to this project will be documented in this file.
|
|
|
940
940
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
941
941
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
942
942
|
|
|
943
|
+
## [0.9.22] - 2025-02-25
|
|
944
|
+
- update the retry_on_error to only `APIError` and `APIConnectionError` update the `resp["error"]` to be `resp.get("error")` to avoid key error
|
|
945
|
+
|
|
943
946
|
## [0.9.21] - 2025-02-21
|
|
944
947
|
- Add title parameter and change labels in `MessageAssessment`
|
|
945
948
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
unique_sdk/__init__.py,sha256=_bFNx6aDyXx_P8VO3RQISQH0PNIqpY3Zev3tsVNUeps,3177
|
|
2
|
-
unique_sdk/_api_requestor.py,sha256=
|
|
2
|
+
unique_sdk/_api_requestor.py,sha256=i4gCpzx8zP95sv-AhJfpQxKvWR0U-I6lclHyV55RPtg,14397
|
|
3
3
|
unique_sdk/_api_resource.py,sha256=ytjomI-IVJwsbvdPyuZCfF-bl-Abgf66bu1D34YxCu8,6244
|
|
4
4
|
unique_sdk/_api_version.py,sha256=Ku4JPdeyJtnX5eJJvRCEc1_u44UObdVrvrL1T-WwWCs,46
|
|
5
5
|
unique_sdk/_error.py,sha256=j-deT0PJ-exLCwUkqORRaxaLLrGunDag9bKJSmBBKZI,3343
|
|
@@ -10,26 +10,26 @@ unique_sdk/_request_options.py,sha256=oHh2AKka6j9pO53Htur3Wj0VJSusEjq8zkXYY179B_
|
|
|
10
10
|
unique_sdk/_unique_object.py,sha256=PLaIzb6NPYghfMKHqDx_ZyojcDcuQzTrATXrktLqMa0,11442
|
|
11
11
|
unique_sdk/_unique_ql.py,sha256=aUYXhYPA-_kPfImTapilCyDvB_53YpLd51kxILe7fDA,1707
|
|
12
12
|
unique_sdk/_unique_response.py,sha256=q19hIxlsrkLAQylfHA0webp6bsCCHXkDJDwaC69Iev8,576
|
|
13
|
-
unique_sdk/_util.py,sha256=
|
|
13
|
+
unique_sdk/_util.py,sha256=kvJzdmwgmWpQYF2OXyzVv1449mF6ADeyuU45Ma2sIg8,9501
|
|
14
14
|
unique_sdk/_version.py,sha256=j4_tPC6t3enRds7LqiRuWSyfrYHfEo6CXIDARAWW98I,19
|
|
15
15
|
unique_sdk/_webhook.py,sha256=GYxbUibQN_W4XlNTHaMIksT9FQJk4LJmlKcxOu3jqiU,2855
|
|
16
16
|
unique_sdk/api_resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
unique_sdk/api_resources/_acronyms.py,sha256=GIU1XH1flGWQYcpsFqTYwg4ioIGxVmb15tux84nmhEg,891
|
|
18
|
-
unique_sdk/api_resources/_chat_completion.py,sha256=
|
|
18
|
+
unique_sdk/api_resources/_chat_completion.py,sha256=hAPPHxoljcoHeTboxoJkcXgpqA2hNBu6a6vamdxag58,2000
|
|
19
19
|
unique_sdk/api_resources/_content.py,sha256=MrAXhgZS3v2S9OwKh3ROfv5wU8Y947A6gD3wgaYe_aM,4989
|
|
20
20
|
unique_sdk/api_resources/_embedding.py,sha256=C6qak7cCUBMBINfPhgH8taCJZ9n6w1MUElqDJJ8dG10,1281
|
|
21
21
|
unique_sdk/api_resources/_event.py,sha256=bpWF9vstdoAWbUzr-iiGP713ceP0zPk77GJXiImf9zg,374
|
|
22
|
-
unique_sdk/api_resources/_integrated.py,sha256=
|
|
22
|
+
unique_sdk/api_resources/_integrated.py,sha256=l1vS8kJiSLie61mqDO3KI2MNmYwFydmCIoJpP_tPhSI,2956
|
|
23
23
|
unique_sdk/api_resources/_message.py,sha256=gEDIzg3METZU2k7m69meAuf0IWmZxnYOjbBKPRMwPYE,7688
|
|
24
24
|
unique_sdk/api_resources/_message_assessment.py,sha256=SSfx6eW7zb_GKe8cFJzCqW-t-_eWEXxKP5cnIb0DhIc,2276
|
|
25
25
|
unique_sdk/api_resources/_search.py,sha256=m9gL-Cv347r6cM9MwGWgddORGHzPF3jK5dzL3plaeNI,1883
|
|
26
|
-
unique_sdk/api_resources/_search_string.py,sha256=
|
|
26
|
+
unique_sdk/api_resources/_search_string.py,sha256=4Idw6exgZdA8qksz9WkiA68k1hTU-7yFkgT_OLU_GkE,1662
|
|
27
27
|
unique_sdk/api_resources/_short_term_memory.py,sha256=vPRN-Y0WPx74E6y-A3LocGc0TxJdzT-xGL66WzZwKRg,2820
|
|
28
28
|
unique_sdk/utils/chat_history.py,sha256=5UqL9hF1O9pV7skbNOlEibF5rHdYsmG3m5-YEPUowOs,3037
|
|
29
29
|
unique_sdk/utils/file_io.py,sha256=tcS-5NA97AyiJPhKpWs3i0qKNFsZlttToxrvnWRDJrs,3857
|
|
30
30
|
unique_sdk/utils/sources.py,sha256=wfboE-neMKa0Wuq9QzfAEFMkNLrIrmm0v-QF33sLo6k,4952
|
|
31
31
|
unique_sdk/utils/token.py,sha256=AzKuAA1AwBtnvSFxGcsHLpxXr_wWE5Mj4jYBbOz2ljA,1740
|
|
32
|
-
unique_sdk-0.9.
|
|
33
|
-
unique_sdk-0.9.
|
|
34
|
-
unique_sdk-0.9.
|
|
35
|
-
unique_sdk-0.9.
|
|
32
|
+
unique_sdk-0.9.22.dist-info/LICENSE,sha256=EJCWoHgrXVBUb47PnjeV4MFIEOR71MAdCOIgv61J-4k,1065
|
|
33
|
+
unique_sdk-0.9.22.dist-info/METADATA,sha256=WItAhCr9G0OU078z6ihry00uK9brJDBeFtGz_QJUgfE,30171
|
|
34
|
+
unique_sdk-0.9.22.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
35
|
+
unique_sdk-0.9.22.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|