unique_sdk 0.9.20__tar.gz → 0.9.22__tar.gz

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.
Files changed (36) hide show
  1. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/CHANGELOG.md +6 -0
  2. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/PKG-INFO +11 -3
  3. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/README.md +4 -2
  4. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/pyproject.toml +1 -1
  5. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/_api_requestor.py +2 -10
  6. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/_util.py +19 -8
  7. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/api_resources/_chat_completion.py +0 -4
  8. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/api_resources/_integrated.py +0 -2
  9. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/api_resources/_message_assessment.py +4 -2
  10. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/api_resources/_search_string.py +0 -3
  11. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/LICENSE +0 -0
  12. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/__init__.py +0 -0
  13. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/_api_resource.py +0 -0
  14. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/_api_version.py +0 -0
  15. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/_error.py +0 -0
  16. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/_http_client.py +0 -0
  17. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/_list_object.py +0 -0
  18. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/_object_classes.py +0 -0
  19. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/_request_options.py +0 -0
  20. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/_unique_object.py +0 -0
  21. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/_unique_ql.py +0 -0
  22. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/_unique_response.py +0 -0
  23. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/_version.py +0 -0
  24. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/_webhook.py +0 -0
  25. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/api_resources/__init__.py +0 -0
  26. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/api_resources/_acronyms.py +0 -0
  27. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/api_resources/_content.py +0 -0
  28. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/api_resources/_embedding.py +0 -0
  29. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/api_resources/_event.py +0 -0
  30. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/api_resources/_message.py +0 -0
  31. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/api_resources/_search.py +0 -0
  32. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/api_resources/_short_term_memory.py +0 -0
  33. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/utils/chat_history.py +0 -0
  34. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/utils/file_io.py +0 -0
  35. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/utils/sources.py +0 -0
  36. {unique_sdk-0.9.20 → unique_sdk-0.9.22}/unique_sdk/utils/token.py +0 -0
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.9.22] - 2025-02-25
9
+ - update the retry_on_error to only `APIError` and `APIConnectionError` update the `resp["error"]` to be `resp.get("error")` to avoid key error
10
+
11
+ ## [0.9.21] - 2025-02-21
12
+ - Add title parameter and change labels in `MessageAssessment`
13
+
8
14
  ## [0.9.20] - 2025-02-01
9
15
  - Add url parameter to `MessageAssessment.create_async` and `MessageAssessment.modify_async`
10
16
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unique_sdk
3
- Version: 0.9.20
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="NEGATIVE",
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="NEGATIVE",
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
 
@@ -616,8 +616,9 @@ assessment = unique_sdk.MessageAssessment.create(
616
616
  assistant_message_id="msg_...",
617
617
  status="DONE",
618
618
  explanation="This response contains incorrect information about...",
619
- label="NEGATIVE",
619
+ label="RED",
620
620
  type="HALLUCINATION",
621
+ title="Hallucination detected",
621
622
  isVisible=True
622
623
  )
623
624
  ```
@@ -633,7 +634,8 @@ assessment = unique_sdk.MessageAssessment.modify(
633
634
  assistant_message_id="msg_...",
634
635
  status="DONE",
635
636
  explanation="Updated explanation...",
636
- label="NEGATIVE",
637
+ label="RED",
638
+ title="update title"
637
639
  type="HALLUCINATION"
638
640
  )
639
641
  ```
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "unique_sdk"
3
- version = "0.9.20"
3
+ version = "0.9.22"
4
4
  description = ""
5
5
  authors = [
6
6
  "Martin Fadler <martin.fadler@unique.ch>",
@@ -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
- try:
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}
@@ -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 Exception as e:
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
- if should_retry_5xx and hasattr(e, "status_code"):
219
- should_retry = should_retry or (500 <= e.status_code < 600)
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 Exception as e:
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
- if should_retry_5xx and hasattr(e, "status_code"):
246
- should_retry = should_retry or (500 <= e.status_code < 600)
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
  ]
@@ -38,8 +38,6 @@ class Integrated(APIResource["Integrated"]):
38
38
  class CreateStream(RequestOptions):
39
39
  model: NotRequired[
40
40
  Literal[
41
- "AZURE_GPT_35_TURBO",
42
- "AZURE_GPT_35_TURBO_16K",
43
41
  "AZURE_GPT_4_0613",
44
42
  "AZURE_GPT_4_32K_0613",
45
43
  ]
@@ -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["POSITIVE", "NEGATIVE", "VERIFIED", "UNVERIFIED"] | None
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["POSITIVE", "NEGATIVE", "VERIFIED", "UNVERIFIED"] | None
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",
File without changes