unique_toolkit 0.7.31__py3-none-any.whl → 0.7.32__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.
@@ -243,6 +243,40 @@ class LanguageModelMessages(RootModel):
243
243
  | LanguageModelUserMessage
244
244
  ]
245
245
 
246
+ @classmethod
247
+ def load_messages_to_root(cls, data: list[dict] | dict) -> Self:
248
+ """Convert list of dictionaries to appropriate message objects based on role."""
249
+ # Handle case where data is already wrapped in root
250
+ if isinstance(data, dict) and "root" in data:
251
+ messages_list = data["root"]
252
+ elif isinstance(data, list):
253
+ messages_list = data
254
+ else:
255
+ raise ValueError("Invalid data type")
256
+
257
+ # Convert the messages list
258
+ converted_messages = []
259
+ for item in messages_list:
260
+ if isinstance(item, dict):
261
+ role = item.get("role", "").lower()
262
+
263
+ # Map dictionary to appropriate message class based on role
264
+ if role == "system":
265
+ converted_messages.append(LanguageModelSystemMessage(**item))
266
+ elif role == "user":
267
+ converted_messages.append(LanguageModelUserMessage(**item))
268
+ elif role == "assistant":
269
+ converted_messages.append(LanguageModelAssistantMessage(**item))
270
+ elif role == "tool":
271
+ converted_messages.append(LanguageModelToolMessage(**item))
272
+ else:
273
+ # Fallback to base LanguageModelMessage
274
+ converted_messages.append(LanguageModelMessage(**item))
275
+ else:
276
+ # If it's already a message object, keep it as is
277
+ converted_messages.append(item)
278
+ return cls(root=converted_messages)
279
+
246
280
  def __str__(self):
247
281
  return "\n\n".join([str(message) for message in self.root])
248
282
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unique_toolkit
3
- Version: 0.7.31
3
+ Version: 0.7.32
4
4
  Summary:
5
5
  License: Proprietary
6
6
  Author: Martin Fadler
@@ -17,7 +17,7 @@ Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
17
17
  Requires-Dist: regex (>=2024.5.15,<2025.0.0)
18
18
  Requires-Dist: tiktoken (>=0.7.0,<0.8.0)
19
19
  Requires-Dist: typing-extensions (>=4.9.0,<5.0.0)
20
- Requires-Dist: unique-sdk (>=0.9.33,<0.10.0)
20
+ Requires-Dist: unique-sdk (>=0.9.36,<0.10.0)
21
21
  Description-Content-Type: text/markdown
22
22
 
23
23
  # Unique Toolkit
@@ -111,6 +111,9 @@ All notable changes to this project will be documented in this file.
111
111
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
112
112
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
113
113
 
114
+ ## [0.7.32] - 2025-06-24
115
+ - Create `classmethod` for `LanguageModelMessages` to load raw messages to root
116
+
114
117
  ## [0.7.31] - 2025-06-19
115
118
  - Add typings to references in payload from `LanguageModelStreamResponseMessage`
116
119
  - Add `original_index` to the base reference to reflect updated api
@@ -51,7 +51,7 @@ unique_toolkit/language_model/functions.py,sha256=WhgHbJgz4Z2aZt9TLdOpI0PGyYWA5R
51
51
  unique_toolkit/language_model/infos.py,sha256=w5__BVG-IiiEYKG1FwM838wzqNbYI3eCCEDocKezc0I,34801
52
52
  unique_toolkit/language_model/prompt.py,sha256=JSawaLjQg3VR-E2fK8engFyJnNdk21zaO8pPIodzN4Q,3991
53
53
  unique_toolkit/language_model/reference.py,sha256=ntoWdJ_hly8FntTgg1qpj0ta55SOCCVsC5L49VqOiAQ,8067
54
- unique_toolkit/language_model/schemas.py,sha256=_fJ9rckKaS082wd2x9DrJ9N6B7iTJ9ytFnq4eIFDNAQ,12781
54
+ unique_toolkit/language_model/schemas.py,sha256=AeuDRJFblGzEYcEMyrlxpOPk12Di3J45I9rT2xZrhEU,14332
55
55
  unique_toolkit/language_model/service.py,sha256=VRkUk2XbijqGlnTTvqU7uCue6qtT7lpLd_Y8f3bWv1I,10486
56
56
  unique_toolkit/language_model/utils.py,sha256=bPQ4l6_YO71w-zaIPanUUmtbXC1_hCvLK0tAFc3VCRc,1902
57
57
  unique_toolkit/protocols/support.py,sha256=V15WEIFKVMyF1QCnR8vIi4GrJy4dfTCB6d6JlqPZ58o,2341
@@ -62,7 +62,7 @@ unique_toolkit/short_term_memory/schemas.py,sha256=OhfcXyF6ACdwIXW45sKzjtZX_gkcJ
62
62
  unique_toolkit/short_term_memory/service.py,sha256=cqpXA0nMbi4PhFweg-Cql3u0RvaTi5c8Xjv0uHMiSGc,8112
63
63
  unique_toolkit/smart_rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
64
  unique_toolkit/smart_rules/compile.py,sha256=cxWjb2dxEI2HGsakKdVCkSNi7VK9mr08w5sDcFCQyWI,9553
65
- unique_toolkit-0.7.31.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
66
- unique_toolkit-0.7.31.dist-info/METADATA,sha256=aNS24gdydQe6icQg_M3EFprEMJ2o8qcR-95-lya8tj8,24607
67
- unique_toolkit-0.7.31.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
68
- unique_toolkit-0.7.31.dist-info/RECORD,,
65
+ unique_toolkit-0.7.32.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
66
+ unique_toolkit-0.7.32.dist-info/METADATA,sha256=qmPxpLockST_2FR2k05nfwgNDtI7C1pBK9fbNwCoKGE,24713
67
+ unique_toolkit-0.7.32.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
68
+ unique_toolkit-0.7.32.dist-info/RECORD,,