unique_sdk 0.9.20__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/_message_assessment.py +4 -2
- unique_sdk/api_resources/_search_string.py +0 -3
- {unique_sdk-0.9.20.dist-info → unique_sdk-0.9.22.dist-info}/METADATA +11 -3
- {unique_sdk-0.9.20.dist-info → unique_sdk-0.9.22.dist-info}/RECORD +10 -10
- {unique_sdk-0.9.20.dist-info → unique_sdk-0.9.22.dist-info}/LICENSE +0 -0
- {unique_sdk-0.9.20.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
|
]
|
|
@@ -17,15 +17,17 @@ class MessageAssessment(APIResource["MessageAssessment"]):
|
|
|
17
17
|
status: Literal["PENDING", "DONE", "ERROR"]
|
|
18
18
|
type: Literal["HALLUCINATION", "COMPLIANCE"]
|
|
19
19
|
isVisible: bool
|
|
20
|
+
title: str | None
|
|
20
21
|
explanation: str | None
|
|
21
|
-
label: Literal["
|
|
22
|
+
label: Literal["RED", "YELLOW", "GREEN"] | None
|
|
22
23
|
|
|
23
24
|
class ModifyParams(RequestOptions):
|
|
24
25
|
messageId: str
|
|
25
26
|
type: Literal["HALLUCINATION", "COMPLIANCE"]
|
|
26
27
|
status: Literal["PENDING", "DONE", "ERROR"] | None
|
|
28
|
+
title: str | None
|
|
27
29
|
explanation: str | None
|
|
28
|
-
label: Literal["
|
|
30
|
+
label: Literal["RED", "YELLOW", "GREEN"] | None
|
|
29
31
|
|
|
30
32
|
@classmethod
|
|
31
33
|
def create(
|
|
@@ -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
|
|
@@ -631,8 +631,9 @@ assessment = unique_sdk.MessageAssessment.create(
|
|
|
631
631
|
assistant_message_id="msg_...",
|
|
632
632
|
status="DONE",
|
|
633
633
|
explanation="This response contains incorrect information about...",
|
|
634
|
-
label="
|
|
634
|
+
label="RED",
|
|
635
635
|
type="HALLUCINATION",
|
|
636
|
+
title="Hallucination detected",
|
|
636
637
|
isVisible=True
|
|
637
638
|
)
|
|
638
639
|
```
|
|
@@ -648,7 +649,8 @@ assessment = unique_sdk.MessageAssessment.modify(
|
|
|
648
649
|
assistant_message_id="msg_...",
|
|
649
650
|
status="DONE",
|
|
650
651
|
explanation="Updated explanation...",
|
|
651
|
-
label="
|
|
652
|
+
label="RED",
|
|
653
|
+
title="update title"
|
|
652
654
|
type="HALLUCINATION"
|
|
653
655
|
)
|
|
654
656
|
```
|
|
@@ -938,6 +940,12 @@ All notable changes to this project will be documented in this file.
|
|
|
938
940
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
939
941
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
940
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
|
+
|
|
946
|
+
## [0.9.21] - 2025-02-21
|
|
947
|
+
- Add title parameter and change labels in `MessageAssessment`
|
|
948
|
+
|
|
941
949
|
## [0.9.20] - 2025-02-01
|
|
942
950
|
- Add url parameter to `MessageAssessment.create_async` and `MessageAssessment.modify_async`
|
|
943
951
|
|
|
@@ -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
|
-
unique_sdk/api_resources/_message_assessment.py,sha256=
|
|
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
|