unique_sdk 0.10.18__py3-none-any.whl → 0.10.19__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,7 +1,8 @@
1
1
  import asyncio
2
- from typing import List
2
+ from typing import List, Literal
3
3
 
4
4
  from unique_sdk.api_resources._content import Content
5
+ from unique_sdk.api_resources._message import Message
5
6
  from unique_sdk.api_resources._space import Space
6
7
  from unique_sdk.utils.file_io import upload_file
7
8
 
@@ -16,6 +17,7 @@ async def send_message_and_wait_for_completion(
16
17
  chat_id: str = None,
17
18
  poll_interval: float = 1.0,
18
19
  max_wait: float = 60.0,
20
+ stop_condition: Literal["stoppedStreamingAt", "completedAt"] = "stoppedStreamingAt",
19
21
  ) -> "Space.Message":
20
22
  """
21
23
  Sends a prompt asynchronously and polls for completion. (until stoppedStreamingAt is not None)
@@ -27,6 +29,7 @@ async def send_message_and_wait_for_completion(
27
29
  text: The prompt text.
28
30
  poll_interval: Seconds between polls.
29
31
  max_wait: Maximum seconds to wait for completion.
32
+ stop_condition: Defines when to expect a response back, when the assistant stop streaming or when it completes the message. (default: "stoppedStreamingAt")
30
33
  **kwargs: Additional parameters for the prompt.
31
34
 
32
35
  Returns:
@@ -42,11 +45,21 @@ async def send_message_and_wait_for_completion(
42
45
  scopeRules=scope_rules,
43
46
  )
44
47
  chat_id = response.get("chatId")
48
+ message_id = response.get("id")
45
49
 
46
50
  max_attempts = int(max_wait // poll_interval)
47
51
  for _ in range(max_attempts):
48
52
  answer = Space.get_latest_message(user_id, company_id, chat_id)
49
- if answer.get("stoppedStreamingAt") is not None:
53
+ if answer.get(stop_condition) is not None:
54
+ try:
55
+ user_message = Message.retrieve(
56
+ user_id, company_id, message_id, chatId=chat_id
57
+ )
58
+ debug_info = user_message.get("debugInfo")
59
+ answer["debugInfo"] = debug_info
60
+ except Exception as e:
61
+ print(f"Failed to load debug info from user message: {e}")
62
+
50
63
  return answer
51
64
  await asyncio.sleep(poll_interval)
52
65
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unique_sdk
3
- Version: 0.10.18
3
+ Version: 0.10.19
4
4
  Summary:
5
5
  License: MIT
6
6
  Author: Martin Fadler
@@ -1466,11 +1466,13 @@ The script sends a prompt asynchronously and continuously polls for completion,
1466
1466
  - `chat_id`: The ID of the chat where the message should be sent. If omitted, a new chat will be created.
1467
1467
  - `poll_interval`: The number of seconds to wait between polling attempts (default: `1` second).
1468
1468
  - `max_wait`: The maximum number of seconds to wait for the message to complete (default: `60` seconds).
1469
+ - `stop_condition`: Defines when to expect a response back, when the assistant stop streaming or when it completes the message. (default: "stoppedStreamingAt")
1469
1470
 
1470
1471
  The script ensures you can flexibly interact with spaces in new or ongoing chats, with fine-grained control over tools, context, and polling behavior.
1471
1472
 
1472
1473
  ```python
1473
- latest_message = await unique_sdk.utils.chat_in_space.send_message_and_wait_for_completion(
1474
+ from unique_sdk.utils.chat_in_space import send_message_and_wait_for_completion
1475
+ latest_message = await send_message_and_wait_for_completion(
1474
1476
  user_id=user_id,
1475
1477
  company_id=company_id,
1476
1478
  assistant_id=assistant_id,
@@ -1497,6 +1499,7 @@ latest_message = await unique_sdk.utils.chat_in_space.send_message_and_wait_for_
1497
1499
  }
1498
1500
  ]
1499
1501
  },
1502
+ stop_condition = "completedAt" # If not specified, stoppedStreamingAt will be set by default
1500
1503
  )
1501
1504
  ```
1502
1505
 
@@ -1572,8 +1575,13 @@ All notable changes to this project will be documented in this file.
1572
1575
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1573
1576
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1574
1577
 
1578
+ ## [0.10.19] - 2025-09-02
1579
+ - Improve `send_message_and_wait_for_completion`:
1580
+ - Add option to select stop_condition `["stoppedStreamingAt", "completedAt"]`.
1581
+ - Load `debugInfo` from `last_user_message` for better developer experience.
1582
+
1575
1583
  ## [0.10.18] - 2025-09-02
1576
- - Temporarily remove support for udpate and delete files by filePath.
1584
+ - Temporarily remove support for update and delete files by filePath.
1577
1585
 
1578
1586
  ## [0.10.17] - 2025-09-01
1579
1587
  - Add function to update a file
@@ -32,11 +32,11 @@ unique_sdk/api_resources/_search_string.py,sha256=4Idw6exgZdA8qksz9WkiA68k1hTU-7
32
32
  unique_sdk/api_resources/_short_term_memory.py,sha256=vPRN-Y0WPx74E6y-A3LocGc0TxJdzT-xGL66WzZwKRg,2820
33
33
  unique_sdk/api_resources/_space.py,sha256=6789zLwkoZqrEESiTJIBVaNi8kAKAZnqR0KMmW1AzgI,4905
34
34
  unique_sdk/utils/chat_history.py,sha256=5UqL9hF1O9pV7skbNOlEibF5rHdYsmG3m5-YEPUowOs,3037
35
- unique_sdk/utils/chat_in_space.py,sha256=3NeBjOu7p43V_6PrjwxyaTkgknUS10KE4QRuTlFDU_4,5232
35
+ unique_sdk/utils/chat_in_space.py,sha256=NrH9e2lvXtj_oePG0RWUqFoTanMblF8-VgtnVfszPS8,5949
36
36
  unique_sdk/utils/file_io.py,sha256=YY8B7VJcTLOPmCXByiOfNerXGlAtjCC5EVNmAbQJ3dQ,4306
37
37
  unique_sdk/utils/sources.py,sha256=DoxxhMLcLhmDfNarjXa41H4JD2GSSDywr71hiC-4pYc,4952
38
38
  unique_sdk/utils/token.py,sha256=AzKuAA1AwBtnvSFxGcsHLpxXr_wWE5Mj4jYBbOz2ljA,1740
39
- unique_sdk-0.10.18.dist-info/LICENSE,sha256=EJCWoHgrXVBUb47PnjeV4MFIEOR71MAdCOIgv61J-4k,1065
40
- unique_sdk-0.10.18.dist-info/METADATA,sha256=aduy4luaw6fs5a2fInb5ws8VfGb_glx3CG1RrgFrnmM,53900
41
- unique_sdk-0.10.18.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
42
- unique_sdk-0.10.18.dist-info/RECORD,,
39
+ unique_sdk-0.10.19.dist-info/LICENSE,sha256=EJCWoHgrXVBUb47PnjeV4MFIEOR71MAdCOIgv61J-4k,1065
40
+ unique_sdk-0.10.19.dist-info/METADATA,sha256=xppurAY1RbWZ-Z8BlMws7i_yZZhYY04pqxDj676FTpU,54448
41
+ unique_sdk-0.10.19.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
42
+ unique_sdk-0.10.19.dist-info/RECORD,,