unique_sdk 0.10.56__py3-none-any.whl → 0.10.58__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.
@@ -1,10 +1,13 @@
1
1
  import asyncio
2
+ import warnings
2
3
  from typing import List, Literal
3
4
 
4
- from unique_sdk.api_resources._content import Content
5
5
  from unique_sdk.api_resources._message import Message
6
6
  from unique_sdk.api_resources._space import Space
7
7
  from unique_sdk.utils.file_io import upload_file
8
+ from unique_sdk.utils.file_io import (
9
+ wait_for_ingestion_completion as _wait_for_ingestion_completion,
10
+ )
8
11
 
9
12
 
10
13
  async def send_message_and_wait_for_completion(
@@ -116,7 +119,7 @@ async def chat_against_file(
116
119
  )
117
120
  content_id = upload_response.get("id")
118
121
 
119
- await wait_for_ingestion_completion(
122
+ await _wait_for_ingestion_completion(
120
123
  user_id=user_id,
121
124
  company_id=company_id,
122
125
  content_id=content_id,
@@ -159,23 +162,21 @@ async def wait_for_ingestion_completion(
159
162
  ):
160
163
  """
161
164
  Polls until the content ingestion is finished or the maximum wait time is reached and throws in case ingestion fails. The function assumes that the content exists.
165
+
166
+ .. deprecated::
167
+ Use :func:`unique_sdk.utils.file_io.wait_for_ingestion_completion` instead.
162
168
  """
163
- max_attempts = int(max_wait // poll_interval)
164
- for _ in range(max_attempts):
165
- searched_content = Content.search(
166
- user_id=user_id,
167
- company_id=company_id,
168
- where={"id": {"equals": content_id}},
169
- chatId=chat_id,
170
- includeFailedContent=True,
171
- )
172
- if searched_content:
173
- ingestion_state = searched_content[0].get("ingestionState")
174
- if ingestion_state == "FINISHED":
175
- return ingestion_state
176
- if isinstance(ingestion_state, str) and ingestion_state.startswith(
177
- "FAILED"
178
- ):
179
- raise RuntimeError(f"Ingestion failed with state: {ingestion_state}")
180
- await asyncio.sleep(poll_interval)
181
- raise TimeoutError("Timed out waiting for file ingestion to finish.")
169
+ warnings.warn(
170
+ "unique_sdk.utils.chat_in_space.wait_for_ingestion_completion is deprecated. "
171
+ "Use unique_sdk.utils.file_io.wait_for_ingestion_completion instead.",
172
+ DeprecationWarning,
173
+ stacklevel=2,
174
+ )
175
+ return await _wait_for_ingestion_completion(
176
+ user_id=user_id,
177
+ company_id=company_id,
178
+ content_id=content_id,
179
+ chat_id=chat_id,
180
+ poll_interval=poll_interval,
181
+ max_wait=max_wait,
182
+ )
@@ -1,3 +1,4 @@
1
+ import asyncio
1
2
  import os
2
3
  import tempfile
3
4
  from pathlib import Path
@@ -151,3 +152,35 @@ def download_content(
151
152
  raise Exception(f"Error downloading file: Status code {response.status_code}")
152
153
 
153
154
  return file_path
155
+
156
+
157
+ async def wait_for_ingestion_completion(
158
+ user_id: str,
159
+ company_id: str,
160
+ content_id: str,
161
+ chat_id: str | None = None,
162
+ poll_interval: float = 1.0,
163
+ max_wait: float = 60.0,
164
+ ):
165
+ """
166
+ Polls until the content ingestion is finished or the maximum wait time is reached and throws in case ingestion fails. The function assumes that the content exists.
167
+ """
168
+ max_attempts = int(max_wait // poll_interval)
169
+ for _ in range(max_attempts):
170
+ searched_content = Content.search(
171
+ user_id=user_id,
172
+ company_id=company_id,
173
+ where={"id": {"equals": content_id}},
174
+ chatId=chat_id,
175
+ includeFailedContent=True,
176
+ )
177
+ if searched_content:
178
+ ingestion_state = searched_content[0].get("ingestionState")
179
+ if ingestion_state == "FINISHED":
180
+ return ingestion_state
181
+ if isinstance(ingestion_state, str) and ingestion_state.startswith(
182
+ "FAILED"
183
+ ):
184
+ raise RuntimeError(f"Ingestion failed with state: {ingestion_state}")
185
+ await asyncio.sleep(poll_interval)
186
+ raise TimeoutError("Timed out waiting for file ingestion to finish.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unique_sdk
3
- Version: 0.10.56
3
+ Version: 0.10.58
4
4
  Summary:
5
5
  License: MIT
6
6
  Author: Martin Fadler
@@ -28,6 +28,12 @@ All notable changes to this project will be documented in this file.
28
28
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
29
29
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
30
30
 
31
+ ## [0.10.58] - 2025-12-16
32
+ - chore(deps): Bump urllib3 from 2.5.0 to 2.6.2
33
+
34
+ ## [0.10.57] - 2025-12-06
35
+ - Add description field on create chat completions params.
36
+
31
37
  ## [0.10.56] - 2025-12-05
32
38
  - Add description field on create chat completions params.
33
39
 
@@ -35,11 +35,11 @@ unique_sdk/api_resources/_short_term_memory.py,sha256=vPRN-Y0WPx74E6y-A3LocGc0Tx
35
35
  unique_sdk/api_resources/_space.py,sha256=YfAywlTl0BUtl3U6Zml9CRyWqhrFeKCoo15mYmynErw,9380
36
36
  unique_sdk/api_resources/_user.py,sha256=CAIT1GOk-knaLLIofl73O3WVGc_zeUv5XjqhuYcgD50,3522
37
37
  unique_sdk/utils/chat_history.py,sha256=5UqL9hF1O9pV7skbNOlEibF5rHdYsmG3m5-YEPUowOs,3037
38
- unique_sdk/utils/chat_in_space.py,sha256=e_Ny03eB7Q8oijdUR_sPlFTIgq2rsCbSR-Sin8jnxM8,6066
39
- unique_sdk/utils/file_io.py,sha256=lskRULIh7qExK26o_1YqRs0f5mqJHTS9m_mdxlsVo4s,4497
38
+ unique_sdk/utils/chat_in_space.py,sha256=mBH4W-Jb8wgGCYV3m12LvoLjTE56xdwUTC-ghMupkSs,5889
39
+ unique_sdk/utils/file_io.py,sha256=z0VdAOtrkU-tMq2v-nogeHtBku3TtnM5eJDHAR6A0-w,5721
40
40
  unique_sdk/utils/sources.py,sha256=DoxxhMLcLhmDfNarjXa41H4JD2GSSDywr71hiC-4pYc,4952
41
41
  unique_sdk/utils/token.py,sha256=AzKuAA1AwBtnvSFxGcsHLpxXr_wWE5Mj4jYBbOz2ljA,1740
42
- unique_sdk-0.10.56.dist-info/LICENSE,sha256=EJCWoHgrXVBUb47PnjeV4MFIEOR71MAdCOIgv61J-4k,1065
43
- unique_sdk-0.10.56.dist-info/METADATA,sha256=TRZBMVYh2i5ZRDBbODnEaJn_WWJOurtgoV25fwgJUBY,10484
44
- unique_sdk-0.10.56.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
45
- unique_sdk-0.10.56.dist-info/RECORD,,
42
+ unique_sdk-0.10.58.dist-info/LICENSE,sha256=EJCWoHgrXVBUb47PnjeV4MFIEOR71MAdCOIgv61J-4k,1065
43
+ unique_sdk-0.10.58.dist-info/METADATA,sha256=DR4DmOnfHEf34V0ao-x93lITG3GK5RwDW_26SNVYePw,10645
44
+ unique_sdk-0.10.58.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
45
+ unique_sdk-0.10.58.dist-info/RECORD,,