unique_toolkit 0.5.47__py3-none-any.whl → 0.5.49__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.
@@ -35,7 +35,7 @@ class LanguageModelMessageRole(StrEnum):
35
35
  class LanguageModelFunction(BaseModel):
36
36
  model_config = model_config
37
37
 
38
- id: Optional[str] = None
38
+ id: str | None = None
39
39
  name: str
40
40
  arguments: Optional[dict[str, Any] | str] = None # type: ignore
41
41
 
@@ -63,8 +63,8 @@ class LanguageModelFunction(BaseModel):
63
63
  class LanguageModelFunctionCall(BaseModel):
64
64
  model_config = model_config
65
65
 
66
- id: Optional[str] = None
67
- type: Optional[str] = None
66
+ id: str | None = None
67
+ type: str | None = None
68
68
  function: LanguageModelFunction
69
69
 
70
70
  @staticmethod
@@ -88,10 +88,17 @@ class LanguageModelFunctionCall(BaseModel):
88
88
  class LanguageModelMessage(BaseModel):
89
89
  model_config = model_config
90
90
  role: LanguageModelMessageRole
91
- content: Optional[str | list[dict]] = None
91
+ content: str | list[dict] | None = None
92
92
 
93
93
  def __str__(self):
94
- return format_message(self.role.capitalize(), message=self.content, num_tabs=1)
94
+ if not self.content:
95
+ message = ""
96
+ if isinstance(self.content, str):
97
+ message = self.content
98
+ elif isinstance(self.content, list):
99
+ message = json.dumps(self.content)
100
+
101
+ return format_message(self.role.capitalize(), message=message, num_tabs=1)
95
102
 
96
103
 
97
104
  class LanguageModelSystemMessage(LanguageModelMessage):
@@ -112,7 +119,9 @@ class LanguageModelUserMessage(LanguageModelMessage):
112
119
 
113
120
  class LanguageModelAssistantMessage(LanguageModelMessage):
114
121
  role: LanguageModelMessageRole = LanguageModelMessageRole.ASSISTANT
115
- tool_calls: Optional[list[LanguageModelFunctionCall]] = None
122
+ parsed: dict | None = None
123
+ refusal: str | None = None
124
+ tool_calls: list[LanguageModelFunctionCall] | None = None
116
125
 
117
126
  @field_validator("role", mode="before")
118
127
  def set_role(cls, value):
@@ -173,10 +182,12 @@ class LanguageModelStreamResponseMessage(BaseModel):
173
182
  model_config = model_config
174
183
 
175
184
  id: str
176
- previous_message_id: str
185
+ previous_message_id: (
186
+ str | None
187
+ ) # Stream response can return a null previous_message_id if an assisstant message is manually added
177
188
  role: LanguageModelMessageRole
178
189
  text: str
179
- original_text: Optional[str] = None
190
+ original_text: str | None = None
180
191
  references: list[dict[str, list | dict | str | int | float | bool]] = [] # type: ignore
181
192
 
182
193
  # TODO make sdk return role in lowercase
@@ -244,7 +255,9 @@ class LanguageModelTool(BaseModel):
244
255
  description="Name must adhere to the pattern ^[a-zA-Z_-]+$",
245
256
  )
246
257
  description: str
247
- parameters: LanguageModelToolParameters
258
+ parameters: (
259
+ LanguageModelToolParameters | dict
260
+ ) # dict represents json schema dumped from pydantic
248
261
  returns: LanguageModelToolParameterProperty | LanguageModelToolParameters | None = (
249
262
  None
250
263
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unique_toolkit
3
- Version: 0.5.47
3
+ Version: 0.5.49
4
4
  Summary:
5
5
  License: Proprietary
6
6
  Author: Martin Fadler
@@ -100,6 +100,12 @@ All notable changes to this project will be documented in this file.
100
100
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
101
101
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
102
102
 
103
+ ## [0.5.49] - 2025-01-24
104
+ - Add `parsed` and `refusal` to `LanguageModelAssistantMessage` to support structured output
105
+
106
+ ## [0.5.48] - 2025-01-19
107
+ - Added the possibility define tool parameters with a json schema (Useful when generating tool parameters from a pydantic object)
108
+
103
109
  ## [0.5.47] - 2025-01-07
104
110
  - Added a message builder to build language model messages conveniently without importing all different messages.
105
111
  - Move tool_calls to assistant message as not needed anywhere else.
@@ -39,12 +39,12 @@ unique_toolkit/language_model/__init__.py,sha256=hgk5yiFF4SpIcE2QSoki9YknFxmcKnq
39
39
  unique_toolkit/language_model/builder.py,sha256=nsRqWO_2dgFehK5CgtqR5aqXgYUU0QL6mR0lALPrQXM,1898
40
40
  unique_toolkit/language_model/infos.py,sha256=NgoV05ausVWMqrYqgH6i3s7tYG7mejupROIF_bwEGZo,13050
41
41
  unique_toolkit/language_model/prompt.py,sha256=JSawaLjQg3VR-E2fK8engFyJnNdk21zaO8pPIodzN4Q,3991
42
- unique_toolkit/language_model/schemas.py,sha256=3en2aV9I3mD6IzugCRsq33vh9-JPNobszwBTw-LsaJQ,7000
42
+ unique_toolkit/language_model/schemas.py,sha256=87511yupvea-U6sfKWfelETevNMVPevhj7mEqX5FszU,7461
43
43
  unique_toolkit/language_model/service.py,sha256=brNCPRA0XxgqHi2rI5i2lyFCkUiw4MNMe1VaR3UgWmY,15500
44
44
  unique_toolkit/language_model/utils.py,sha256=bPQ4l6_YO71w-zaIPanUUmtbXC1_hCvLK0tAFc3VCRc,1902
45
45
  unique_toolkit/short_term_memory/schemas.py,sha256=OhfcXyF6ACdwIXW45sKzjtZX_gkcJs8FEZXcgQTNenw,1406
46
46
  unique_toolkit/short_term_memory/service.py,sha256=Jd9P72-VvJy7hnqNrjmrmB5BHmsKuOpTiT0Jr-dBbsQ,1682
47
- unique_toolkit-0.5.47.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
48
- unique_toolkit-0.5.47.dist-info/METADATA,sha256=idzuuHNWe1HqAkrEbASKasyAlzWwpsm6_3tI5er7b2c,15544
49
- unique_toolkit-0.5.47.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
50
- unique_toolkit-0.5.47.dist-info/RECORD,,
47
+ unique_toolkit-0.5.49.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
48
+ unique_toolkit-0.5.49.dist-info/METADATA,sha256=y2wgnOvbhd2PaXa5wshMxjmQ-hNrkaKhqalKAtr5K4E,15819
49
+ unique_toolkit-0.5.49.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
50
+ unique_toolkit-0.5.49.dist-info/RECORD,,