unique_sdk 0.9.21__tar.gz → 0.9.23__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.

Potentially problematic release.


This version of unique_sdk might be problematic. Click here for more details.

Files changed (36) hide show
  1. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/CHANGELOG.md +7 -0
  2. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/PKG-INFO +8 -1
  3. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/pyproject.toml +4 -1
  4. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/_api_requestor.py +2 -10
  5. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/_util.py +19 -8
  6. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/api_resources/_chat_completion.py +0 -4
  7. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/api_resources/_integrated.py +0 -2
  8. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/api_resources/_search_string.py +0 -3
  9. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/LICENSE +0 -0
  10. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/README.md +0 -0
  11. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/__init__.py +0 -0
  12. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/_api_resource.py +0 -0
  13. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/_api_version.py +0 -0
  14. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/_error.py +0 -0
  15. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/_http_client.py +0 -0
  16. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/_list_object.py +0 -0
  17. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/_object_classes.py +0 -0
  18. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/_request_options.py +0 -0
  19. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/_unique_object.py +0 -0
  20. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/_unique_ql.py +0 -0
  21. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/_unique_response.py +0 -0
  22. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/_version.py +0 -0
  23. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/_webhook.py +0 -0
  24. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/api_resources/__init__.py +0 -0
  25. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/api_resources/_acronyms.py +0 -0
  26. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/api_resources/_content.py +0 -0
  27. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/api_resources/_embedding.py +0 -0
  28. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/api_resources/_event.py +0 -0
  29. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/api_resources/_message.py +0 -0
  30. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/api_resources/_message_assessment.py +0 -0
  31. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/api_resources/_search.py +0 -0
  32. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/api_resources/_short_term_memory.py +0 -0
  33. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/utils/chat_history.py +0 -0
  34. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/utils/file_io.py +0 -0
  35. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/utils/sources.py +0 -0
  36. {unique_sdk-0.9.21 → unique_sdk-0.9.23}/unique_sdk/utils/token.py +0 -0
@@ -5,6 +5,13 @@ 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
+
9
+ ## [0.9.23] - 2025-03-25
10
+ - Define programming language classifier explicitly for python 3.11
11
+
12
+ ## [0.9.22] - 2025-02-25
13
+ - update the retry_on_error to only `APIError` and `APIConnectionError` update the `resp["error"]` to be `resp.get("error")` to avoid key error
14
+
8
15
  ## [0.9.21] - 2025-02-21
9
16
  - Add title parameter and change labels in `MessageAssessment`
10
17
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unique_sdk
3
- Version: 0.9.21
3
+ Version: 0.9.23
4
4
  Summary:
5
5
  License: MIT
6
6
  Author: Martin Fadler
@@ -940,6 +940,13 @@ 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
+
944
+ ## [0.9.23] - 2025-03-25
945
+ - Define programming language classifier explicitly for python 3.11
946
+
947
+ ## [0.9.22] - 2025-02-25
948
+ - update the retry_on_error to only `APIError` and `APIConnectionError` update the `resp["error"]` to be `resp.get("error")` to avoid key error
949
+
943
950
  ## [0.9.21] - 2025-02-21
944
951
  - Add title parameter and change labels in `MessageAssessment`
945
952
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "unique_sdk"
3
- version = "0.9.21"
3
+ version = "0.9.23"
4
4
  description = ""
5
5
  authors = [
6
6
  "Martin Fadler <martin.fadler@unique.ch>",
@@ -9,6 +9,9 @@ authors = [
9
9
  ]
10
10
  readme = ["README.md", "CHANGELOG.md"]
11
11
  license = "MIT"
12
+ classifiers = [
13
+ "Programming Language :: Python :: 3.11"
14
+ ]
12
15
 
13
16
  [tool.poetry.dependencies]
14
17
  python = "^3.11"
@@ -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
  ]
@@ -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
File without changes