unique_toolkit 0.8.8__py3-none-any.whl → 0.8.10__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.
@@ -20,7 +20,11 @@ from unique_toolkit.language_model import (
20
20
  LanguageModelTool,
21
21
  LanguageModelToolDescription,
22
22
  )
23
- from unique_toolkit.language_model.infos import LanguageModelName
23
+ from unique_toolkit.language_model.infos import (
24
+ LanguageModelInfo,
25
+ LanguageModelName,
26
+ TemperatureBounds,
27
+ )
24
28
  from unique_toolkit.language_model.reference import (
25
29
  add_references_to_message,
26
30
  )
@@ -303,6 +307,24 @@ def __camelize_keys(data):
303
307
  return data
304
308
 
305
309
 
310
+ def _clamp_temperature(
311
+ temperature: float, temperature_bounds: TemperatureBounds
312
+ ) -> float:
313
+ temperature = max(temperature_bounds.min_temperature, temperature)
314
+ temperature = min(temperature_bounds.max_temperature, temperature)
315
+ return round(temperature, 2)
316
+
317
+
318
+ def _prepare_other_options(
319
+ other_options: dict | None,
320
+ default_options: dict,
321
+ ) -> dict:
322
+ options = default_options
323
+ if other_options is not None:
324
+ options.update(other_options)
325
+ return options
326
+
327
+
306
328
  def _prepare_all_completions_params_util(
307
329
  messages: LanguageModelMessages | list[ChatCompletionMessageParam],
308
330
  model_name: LanguageModelName | str,
@@ -318,6 +340,13 @@ def _prepare_all_completions_params_util(
318
340
  list[unique_sdk.Integrated.ChatCompletionRequestMessage],
319
341
  dict | None,
320
342
  ]:
343
+ model_info = None
344
+ if isinstance(model_name, LanguageModelName):
345
+ model_info = LanguageModelInfo.from_name(model_name)
346
+ other_options = _prepare_other_options(
347
+ other_options, model_info.default_options
348
+ )
349
+
321
350
  if isinstance(messages, LanguageModelMessages):
322
351
  options, model, messages_dict, search_context = _prepare_completion_params_util(
323
352
  messages=messages,
@@ -341,6 +370,15 @@ def _prepare_all_completions_params_util(
341
370
  )
342
371
  messages_dict = __camelize_keys(messages.copy())
343
372
 
373
+ if (
374
+ model_info is not None
375
+ and model_info.temperature_bounds is not None
376
+ and "temperature" in options
377
+ ):
378
+ options["temperature"] = _clamp_temperature(
379
+ temperature, model_info.temperature_bounds
380
+ )
381
+
344
382
  integrated_messages = cast(
345
383
  "list[unique_sdk.Integrated.ChatCompletionRequestMessage]",
346
384
  messages_dict,
@@ -1,6 +1,6 @@
1
1
  from datetime import date
2
2
  from enum import StrEnum
3
- from typing import ClassVar, Optional, Self
3
+ from typing import Any, ClassVar, Optional, Self
4
4
 
5
5
  from pydantic import BaseModel
6
6
  from pydantic.json_schema import SkipJsonSchema
@@ -96,6 +96,11 @@ class ModelCapabilities(StrEnum):
96
96
  REASONING = "reasoning"
97
97
 
98
98
 
99
+ class TemperatureBounds(BaseModel):
100
+ min_temperature: float
101
+ max_temperature: float
102
+
103
+
99
104
  class LanguageModelInfo(BaseModel):
100
105
  name: LanguageModelName | str
101
106
  version: str
@@ -116,6 +121,10 @@ class LanguageModelInfo(BaseModel):
116
121
  deprecated_at: date | SkipJsonSchema[None] = None
117
122
  retirement_text: str | SkipJsonSchema[None] = None
118
123
 
124
+ temperature_bounds: TemperatureBounds | None = None
125
+
126
+ default_options: dict[str, Any] = {}
127
+
119
128
  @classmethod
120
129
  def from_name(cls, model_name: LanguageModelName) -> Self:
121
130
  match model_name:
@@ -183,11 +192,19 @@ class LanguageModelInfo(BaseModel):
183
192
  ModelCapabilities.STRUCTURED_OUTPUT,
184
193
  ModelCapabilities.PARALLEL_FUNCTION_CALLING,
185
194
  ],
186
- token_limits=LanguageModelTokenLimits(token_limit_input=272000, token_limit_output=128000),
195
+ token_limits=LanguageModelTokenLimits(
196
+ token_limit_input=272000, token_limit_output=128000
197
+ ),
187
198
  info_cutoff_at=date(2024, 10, 24),
188
199
  published_at=date(2025, 8, 7),
189
200
  deprecated_at=date(2026, 8, 7),
190
201
  retirement_at=date(2026, 8, 7),
202
+ temperature_bounds=TemperatureBounds(
203
+ min_temperature=1.0, max_temperature=1.0
204
+ ),
205
+ default_options={
206
+ "reasoning_effort": "minimal",
207
+ },
191
208
  )
192
209
  case LanguageModelName.AZURE_GPT_5_MINI_2025_0807:
193
210
  return cls(
@@ -201,11 +218,19 @@ class LanguageModelInfo(BaseModel):
201
218
  ModelCapabilities.VISION,
202
219
  ModelCapabilities.STRUCTURED_OUTPUT,
203
220
  ],
204
- token_limits=LanguageModelTokenLimits(token_limit_input=272000, token_limit_output=128000),
221
+ token_limits=LanguageModelTokenLimits(
222
+ token_limit_input=272000, token_limit_output=128000
223
+ ),
205
224
  info_cutoff_at=date(2024, 6, 24),
206
225
  published_at=date(2025, 8, 7),
207
226
  deprecated_at=date(2026, 8, 7),
208
227
  retirement_at=date(2026, 8, 7),
228
+ temperature_bounds=TemperatureBounds(
229
+ min_temperature=1.0, max_temperature=1.0
230
+ ),
231
+ default_options={
232
+ "reasoning_effort": "minimal",
233
+ },
209
234
  )
210
235
  case LanguageModelName.AZURE_GPT_5_NANO_2025_0807:
211
236
  return cls(
@@ -219,19 +244,29 @@ class LanguageModelInfo(BaseModel):
219
244
  ModelCapabilities.VISION,
220
245
  ModelCapabilities.STRUCTURED_OUTPUT,
221
246
  ],
222
- token_limits=LanguageModelTokenLimits(token_limit_input=272000, token_limit_output=128000),
247
+ token_limits=LanguageModelTokenLimits(
248
+ token_limit_input=272000, token_limit_output=128000
249
+ ),
223
250
  info_cutoff_at=date(2024, 5, 31),
224
251
  published_at=date(2025, 8, 7),
225
252
  deprecated_at=date(2026, 8, 7),
226
253
  retirement_at=date(2026, 8, 7),
254
+ temperature_bounds=TemperatureBounds(
255
+ min_temperature=1.0, max_temperature=1.0
256
+ ),
257
+ default_options={
258
+ "reasoning_effort": "minimal",
259
+ },
227
260
  )
228
261
  case LanguageModelName.AZURE_GPT_5_CHAT_2025_0807:
229
262
  return cls(
230
263
  name=model_name,
231
264
  provider=LanguageModelProvider.AZURE,
232
265
  version="2025-08-07",
233
- encoder_name=EncoderName.O200K_BASE,
234
- token_limits=LanguageModelTokenLimits(token_limit_input=128000, token_limit_output=16384),
266
+ encoder_name=EncoderName.O200K_BASE,
267
+ token_limits=LanguageModelTokenLimits(
268
+ token_limit_input=128000, token_limit_output=16384
269
+ ),
235
270
  info_cutoff_at=date(2024, 10, 24),
236
271
  published_at=date(2025, 8, 7),
237
272
  deprecated_at=date(2026, 8, 7),
@@ -347,6 +382,9 @@ class LanguageModelInfo(BaseModel):
347
382
  ),
348
383
  info_cutoff_at=date(2023, 10, 1),
349
384
  published_at=date(2024, 9, 12),
385
+ temperature_bounds=TemperatureBounds(
386
+ min_temperature=1.0, max_temperature=1.0
387
+ ),
350
388
  )
351
389
  case LanguageModelName.AZURE_o1_2024_1217:
352
390
  return cls(
@@ -366,6 +404,9 @@ class LanguageModelInfo(BaseModel):
366
404
  ),
367
405
  info_cutoff_at=date(2023, 10, 1),
368
406
  published_at=date(2024, 12, 17),
407
+ temperature_bounds=TemperatureBounds(
408
+ min_temperature=1.0, max_temperature=1.0
409
+ ),
369
410
  )
370
411
  case LanguageModelName.AZURE_o3_MINI_2025_0131:
371
412
  return cls(
@@ -384,6 +425,9 @@ class LanguageModelInfo(BaseModel):
384
425
  ),
385
426
  info_cutoff_at=date(2023, 10, 1),
386
427
  published_at=date(2025, 1, 31),
428
+ temperature_bounds=TemperatureBounds(
429
+ min_temperature=1.0, max_temperature=1.0
430
+ ),
387
431
  )
388
432
  case LanguageModelName.AZURE_o3_2025_0416:
389
433
  return cls(
@@ -403,6 +447,9 @@ class LanguageModelInfo(BaseModel):
403
447
  ),
404
448
  info_cutoff_at=date(2024, 5, 31),
405
449
  published_at=date(2025, 4, 16),
450
+ temperature_bounds=TemperatureBounds(
451
+ min_temperature=1.0, max_temperature=1.0
452
+ ),
406
453
  )
407
454
  case LanguageModelName.AZURE_o4_MINI_2025_0416:
408
455
  return cls(
@@ -422,6 +469,9 @@ class LanguageModelInfo(BaseModel):
422
469
  ),
423
470
  info_cutoff_at=date(2024, 5, 31),
424
471
  published_at=date(2025, 4, 16),
472
+ temperature_bounds=TemperatureBounds(
473
+ min_temperature=1.0, max_temperature=1.0
474
+ ),
425
475
  )
426
476
  case LanguageModelName.AZURE_GPT_45_PREVIEW_2025_0227:
427
477
  return cls(
@@ -507,7 +557,9 @@ class LanguageModelInfo(BaseModel):
507
557
  version="claude-3-7-sonnet",
508
558
  encoder_name=EncoderName.O200K_BASE, # TODO: Update encoder with litellm
509
559
  token_limits=LanguageModelTokenLimits(
510
- token_limit_input=200_000, token_limit_output=128_000
560
+ # Input limit is 200_000, we leave 20_000 tokens as buffer due to tokenizer mismatch
561
+ token_limit_input=180_000,
562
+ token_limit_output=128_000,
511
563
  ),
512
564
  info_cutoff_at=date(2024, 10, 31),
513
565
  published_at=date(2025, 2, 24),
@@ -525,7 +577,9 @@ class LanguageModelInfo(BaseModel):
525
577
  version="claude-3-7-sonnet-thinking",
526
578
  encoder_name=EncoderName.O200K_BASE, # TODO: Update encoder with litellm
527
579
  token_limits=LanguageModelTokenLimits(
528
- token_limit_input=200_000, token_limit_output=128_000
580
+ # Input limit is 200_000, we leave 20_000 tokens as buffer due to tokenizer mismatch
581
+ token_limit_input=180_000,
582
+ token_limit_output=128_000,
529
583
  ),
530
584
  info_cutoff_at=date(2024, 10, 31),
531
585
  published_at=date(2025, 2, 24),
@@ -543,7 +597,9 @@ class LanguageModelInfo(BaseModel):
543
597
  version="claude-sonnet-4",
544
598
  encoder_name=EncoderName.O200K_BASE, # TODO: Update encoder with litellm
545
599
  token_limits=LanguageModelTokenLimits(
546
- token_limit_input=200_000, token_limit_output=64_000
600
+ # Input limit is 200_000, we leave 20_000 tokens as buffer due to tokenizer mismatch
601
+ token_limit_input=180_000,
602
+ token_limit_output=64_000,
547
603
  ),
548
604
  info_cutoff_at=date(2025, 3, 1),
549
605
  published_at=date(2025, 5, 1),
@@ -561,7 +617,9 @@ class LanguageModelInfo(BaseModel):
561
617
  version="claude-opus-4",
562
618
  encoder_name=EncoderName.O200K_BASE, # TODO: Update encoder with litellm
563
619
  token_limits=LanguageModelTokenLimits(
564
- token_limit_input=200_000, token_limit_output=32_000
620
+ # Input limit is 200_000, we leave 20_000 tokens as buffer due to tokenizer mismatch
621
+ token_limit_input=180_000,
622
+ token_limit_output=32_000,
565
623
  ),
566
624
  info_cutoff_at=date(2025, 3, 1),
567
625
  published_at=date(2025, 5, 1),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unique_toolkit
3
- Version: 0.8.8
3
+ Version: 0.8.10
4
4
  Summary:
5
5
  License: Proprietary
6
6
  Author: Martin Fadler
@@ -114,6 +114,13 @@ All notable changes to this project will be documented in this file.
114
114
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
115
115
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
116
116
 
117
+ ## [0.8.10] - 2025-08-15
118
+ - Add min and max temperature to `LanguageModelInfo`: temperature will be clamped to the min and max temperature
119
+ - Add default options to `LanguageModelInfo`: These are used by default
120
+
121
+ ## [0.8.9] - 2025-08-15
122
+ - Reduce input token limits for `ANTHROPIC_CLAUDE_3_7_SONNET_THINKING`, `ANTHROPIC_CLAUDE_3_7_SONNET`, `ANTHROPIC_CLAUDE_OPUS_4` and `ANTHROPIC_CLAUDE_SONNET_4` to 180_000 from 200_000
123
+
117
124
  ## [0.8.8] - 2025-08-11
118
125
  - Make chat service openai stream response openai compatible
119
126
  - Make `ChatMessage` openai compatible
@@ -54,8 +54,8 @@ unique_toolkit/framework_utilities/utils.py,sha256=JK7g2yMfEx3eMprug26769xqNpS5W
54
54
  unique_toolkit/language_model/__init__.py,sha256=lRQyLlbwHbNFf4-0foBU13UGb09lwEeodbVsfsSgaCk,1971
55
55
  unique_toolkit/language_model/builder.py,sha256=4OKfwJfj3TrgO1ezc_ewIue6W7BCQ2ZYQXUckWVPPTA,3369
56
56
  unique_toolkit/language_model/constants.py,sha256=B-topqW0r83dkC_25DeQfnPk3n53qzIHUCBS7YJ0-1U,119
57
- unique_toolkit/language_model/functions.py,sha256=qi4KGa4hLUXy0KwkkGmtGBM1IuYfJqmTheSQ95R7pNw,15611
58
- unique_toolkit/language_model/infos.py,sha256=mnUnbjDQNOIuPS2VE1SsgyKOxdRulo-9Z5k7_S1Q8Cw,37631
57
+ unique_toolkit/language_model/functions.py,sha256=-nWgcscaZvEfuf2ftCQj8hyFY2RynPFO8XgX2gsN924,16665
58
+ unique_toolkit/language_model/infos.py,sha256=7huMpiDhGdWyhFBZx9dVLXdSkONSrxHL1Fr7zTBeX0w,40062
59
59
  unique_toolkit/language_model/prompt.py,sha256=JSawaLjQg3VR-E2fK8engFyJnNdk21zaO8pPIodzN4Q,3991
60
60
  unique_toolkit/language_model/reference.py,sha256=nkX2VFz-IrUz8yqyc3G5jUMNwrNpxITBrMEKkbqqYoI,8583
61
61
  unique_toolkit/language_model/schemas.py,sha256=p95cAwrYmEBupI8f7JZY17aJTKEHvtqF88hMIzS5r_k,16259
@@ -82,7 +82,7 @@ unique_toolkit/tools/utils/execution/execution.py,sha256=vjG2Y6awsGNtlvyQAGCTthQ
82
82
  unique_toolkit/tools/utils/source_handling/schema.py,sha256=pvNhtL2daDLpCVIQpfdn6R35GvKmITVLXjZNLAwpgUE,871
83
83
  unique_toolkit/tools/utils/source_handling/source_formatting.py,sha256=C7uayNbdkNVJdEARA5CENnHtNY1SU6etlaqbgHNyxaQ,9152
84
84
  unique_toolkit/tools/utils/source_handling/tests/test_source_formatting.py,sha256=zu3AJnYH9CMqZPrxKEH3IgI-fM3nlvIBuspJG6W6B18,6978
85
- unique_toolkit-0.8.8.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
86
- unique_toolkit-0.8.8.dist-info/METADATA,sha256=AUly1ya9VxSfPCq8ivY1kAq4MrClSRQ-fm8_9BZr0oI,26649
87
- unique_toolkit-0.8.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
88
- unique_toolkit-0.8.8.dist-info/RECORD,,
85
+ unique_toolkit-0.8.10.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
86
+ unique_toolkit-0.8.10.dist-info/METADATA,sha256=GVFDjq3YzjeBV-w8WTtrqLKSuCYuPTc42lgv7Ev9hWk,27071
87
+ unique_toolkit-0.8.10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
88
+ unique_toolkit-0.8.10.dist-info/RECORD,,