unique_toolkit 0.5.44__py3-none-any.whl → 0.5.46__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.
@@ -11,6 +11,7 @@ class LanguageModelName(StrEnum):
11
11
  AZURE_GPT_35_TURBO_0613 = "AZURE_GPT_35_TURBO_0613"
12
12
  AZURE_GPT_35_TURBO = "AZURE_GPT_35_TURBO"
13
13
  AZURE_GPT_35_TURBO_16K = "AZURE_GPT_35_TURBO_16K"
14
+ AZURE_GPT_35_TURBO_0125 = "AZURE_GPT_35_TURBO_0125"
14
15
  AZURE_GPT_4_0613 = "AZURE_GPT_4_0613"
15
16
  AZURE_GPT_4_TURBO_1106 = "AZURE_GPT_4_TURBO_1106"
16
17
  AZURE_GPT_4_VISION_PREVIEW = "AZURE_GPT_4_VISION_PREVIEW"
@@ -33,6 +34,7 @@ def get_encoder_name(model_name: LanguageModelName) -> Optional[EncoderName]:
33
34
  LMN.AZURE_GPT_35_TURBO
34
35
  | LMN.AZURE_GPT_35_TURBO_16K
35
36
  | LMN.AZURE_GPT_35_TURBO_0613
37
+ | LMN.AZURE_GPT_35_TURBO_0125
36
38
  ):
37
39
  return EncoderName.CL100K_BASE
38
40
  case (
@@ -278,7 +280,7 @@ AzureGpt35Turbo0613 = create_language_model(
278
280
  token_limit=8192,
279
281
  info_cutoff_at=date(2021, 9, 1),
280
282
  published_at=date(2023, 6, 13),
281
- retirement_at=date(2024, 10, 1),
283
+ retirement_at=date(2025, 2, 13),
282
284
  )
283
285
 
284
286
  AzureGpt35Turbo = create_language_model(
@@ -289,6 +291,7 @@ AzureGpt35Turbo = create_language_model(
289
291
  token_limit=4096,
290
292
  info_cutoff_at=date(2021, 9, 1),
291
293
  published_at=date(2023, 3, 1),
294
+ retirement_at=date(2025, 2, 13),
292
295
  )
293
296
 
294
297
 
@@ -300,7 +303,20 @@ AzureGpt35Turbo16k = create_language_model(
300
303
  token_limit=16382,
301
304
  info_cutoff_at=date(2021, 9, 1),
302
305
  published_at=date(2023, 6, 13),
303
- retirement_at=date(2024, 10, 1),
306
+ retirement_at=date(2025, 2, 13),
307
+ )
308
+
309
+
310
+ AzureGpt35Turbo0125 = create_language_model(
311
+ name=LanguageModelName.AZURE_GPT_35_TURBO_0125,
312
+ provider=LanguageModelProvider.AZURE,
313
+ version="0125",
314
+ encoder_name=get_encoder_name(LanguageModelName.AZURE_GPT_35_TURBO_0125),
315
+ token_limit_input=16385,
316
+ token_limit_output=4096,
317
+ info_cutoff_at=date(2021, 9, 1),
318
+ published_at=date(2023, 1, 25),
319
+ retirement_at=date(5, 3, 31),
304
320
  )
305
321
 
306
322
 
@@ -313,7 +329,7 @@ AzureGpt40613 = create_language_model(
313
329
  info_cutoff_at=date(2021, 9, 1),
314
330
  published_at=date(2023, 6, 13),
315
331
  deprecated_at=date(2024, 10, 1),
316
- retirement_at=date(2025, 6, 1),
332
+ retirement_at=date(2025, 6, 6),
317
333
  )
318
334
 
319
335
 
@@ -349,7 +365,7 @@ AzureGpt432k0613 = create_language_model(
349
365
  info_cutoff_at=date(2021, 9, 1),
350
366
  published_at=date(2023, 6, 13),
351
367
  deprecated_at=date(2024, 10, 1),
352
- retirement_at=date(2025, 6, 1),
368
+ retirement_at=date(2025, 6, 6),
353
369
  )
354
370
 
355
371
  AzureGpt4Turbo20240409 = create_language_model(
@@ -0,0 +1,49 @@
1
+ import json
2
+
3
+ from humps import camelize
4
+ from pydantic import BaseModel, ConfigDict, Field, field_validator
5
+
6
+ model_config = ConfigDict(
7
+ alias_generator=camelize,
8
+ populate_by_name=True,
9
+ arbitrary_types_allowed=True,
10
+ )
11
+
12
+
13
+ class ShortTermMemory(BaseModel):
14
+ model_config = model_config
15
+
16
+ id: str
17
+ key: str = Field(alias="object")
18
+ chat_id: str | None
19
+ message_id: str | None
20
+ data: str | dict | int | float | bool | list | None
21
+
22
+ @field_validator("chat_id", "message_id", mode="before")
23
+ def validate_chat_id_or_message_id(cls, v, info):
24
+ field_name = info.field_name
25
+ data = info.data
26
+
27
+ # Get the other field's value
28
+ other_field = "message_id" if field_name == "chat_id" else "chat_id"
29
+ other_value = data.get(other_field)
30
+
31
+ # Check if both are None
32
+ if v is None and other_value is None:
33
+ camel_name = camelize(field_name)
34
+ raise ValueError(
35
+ f"Either {camel_name} or messageId must be provided"
36
+ if field_name == "chat_id"
37
+ else f"Either chatId or {camel_name} must be provided"
38
+ )
39
+
40
+ return v
41
+
42
+ @field_validator("data", mode="before")
43
+ def validate_data(cls, v):
44
+ if isinstance(v, str):
45
+ try:
46
+ return json.loads(v)
47
+ except json.JSONDecodeError:
48
+ return v
49
+ return v
@@ -0,0 +1,57 @@
1
+ import json
2
+
3
+ from unique_sdk.api_resources._short_term_memory import (
4
+ ShortTermMemory as ShortTermMemoryAPI,
5
+ )
6
+
7
+ from unique_toolkit.app import Event
8
+
9
+ from .schemas import ShortTermMemory
10
+
11
+
12
+ class ShortTermMemoryService:
13
+ def __init__(
14
+ self,
15
+ user_id: str,
16
+ company_id: str,
17
+ chat_id: str | None,
18
+ message_id: str | None = None,
19
+ ):
20
+ assert chat_id or message_id, "Either chat_id or message_id must be provided"
21
+ self.user_id = user_id
22
+ self.company_id = company_id
23
+ self.chat_id = chat_id
24
+ self.message_id = message_id
25
+
26
+ @classmethod
27
+ def from_chat_event(cls, chat_event: Event) -> "ShortTermMemoryService":
28
+ return cls(
29
+ user_id=chat_event.user_id,
30
+ company_id=chat_event.company_id,
31
+ chat_id=chat_event.payload.chat_id,
32
+ message_id=chat_event.payload.user_message.id,
33
+ )
34
+
35
+ async def get(self, key: str) -> ShortTermMemory:
36
+ stm = await ShortTermMemoryAPI.find_latest_async(
37
+ user_id=self.user_id,
38
+ company_id=self.company_id,
39
+ memoryName=key,
40
+ chatId=self.chat_id,
41
+ messageId=self.message_id,
42
+ )
43
+
44
+ return ShortTermMemory(**stm)
45
+
46
+ async def set(self, key: str, value: str | dict):
47
+ if isinstance(value, dict):
48
+ value = json.dumps(value)
49
+ stm = await ShortTermMemoryAPI.create_async(
50
+ user_id=self.user_id,
51
+ company_id=self.company_id,
52
+ memoryName=key,
53
+ chatId=self.chat_id,
54
+ messageId=self.message_id,
55
+ data=value,
56
+ )
57
+ return ShortTermMemory(**stm)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unique_toolkit
3
- Version: 0.5.44
3
+ Version: 0.5.46
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.14,<0.10.0)
20
+ Requires-Dist: unique-sdk (>=0.9.17,<0.10.0)
21
21
  Description-Content-Type: text/markdown
22
22
 
23
23
  # Unique Toolkit
@@ -79,7 +79,7 @@ The `unique_toolkit.embedding` module encompasses all embedding related function
79
79
  The `unique_toolkit.language_model` module encompasses all language model related functionality and information on the different language models deployed through the
80
80
  Unique platform.
81
81
 
82
- - `infos.py` comprises the information on all language models deployed through the Unique platform. We recommend to use the LanguageModel class, initialized with the LanguageModelName, e.g., LanguageModel(LanguageModelName.AZURE_GPT_35_TURBO_16K) to get the information on the specific language model like the name, version, token limits or retirement date.
82
+ - `infos.py` comprises the information on all language models deployed through the Unique platform. We recommend to use the LanguageModel class, initialized with the LanguageModelName, e.g., LanguageModel(LanguageModelName.AZURE_GPT_35_TURBO_0125) to get the information on the specific language model like the name, version, token limits or retirement date.
83
83
  - `service.py` comprises the LanguageModelService and provides an interface to interact with the language models, e.g., complete or stream_complete.
84
84
  - `schemas.py` comprises all relevant schemas, e.g., LanguageModelResponse, used in the LanguageModelService.
85
85
  - `utils.py` comprises utility functions to parse the output of the language model, e.g., convert_string_to_json finds and parses the last json object in a string.
@@ -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.46] - 2025-01-07
104
+ - Added `AZURE_GPT_35_TURBO_0125` as new model into toolkit.
105
+
106
+ ## [0.5.45] - 2025-01-03
107
+ - Added `ShortTermMemoryService` class to handle short term memory.
108
+
103
109
  ## [0.5.44] - 2024-12-18
104
110
  - Add `event_constructor` to `verify_signature_and_construct_event` to allow for custom event construction.
105
111
 
@@ -36,12 +36,14 @@ unique_toolkit/evaluators/hallucination/utils.py,sha256=507BsX1mFTEne1-LdRCNMgBj
36
36
  unique_toolkit/evaluators/output_parser.py,sha256=eI72qkzK1dZyUvnfP2SOAQCGBj_-PwX5wy_aLPMsJMY,883
37
37
  unique_toolkit/evaluators/schemas.py,sha256=Jaue6Uhx75X1CyHKWj8sT3RE1JZXTqoLtfLt2xQNCX8,2507
38
38
  unique_toolkit/language_model/__init__.py,sha256=hgk5yiFF4SpIcE2QSoki9YknFxmcKnq2LCJ1cK9de9I,1830
39
- unique_toolkit/language_model/infos.py,sha256=kQK6F3r8xTN7oT6b39J7rxW-Y4iPXjx_Fr9bCOVQdm0,12509
39
+ unique_toolkit/language_model/infos.py,sha256=NgoV05ausVWMqrYqgH6i3s7tYG7mejupROIF_bwEGZo,13050
40
40
  unique_toolkit/language_model/prompt.py,sha256=JSawaLjQg3VR-E2fK8engFyJnNdk21zaO8pPIodzN4Q,3991
41
41
  unique_toolkit/language_model/schemas.py,sha256=MBwEAFnnCYjSpbZDUYLrqkCc-0bsarsepSQEj1v6YEY,6991
42
42
  unique_toolkit/language_model/service.py,sha256=brNCPRA0XxgqHi2rI5i2lyFCkUiw4MNMe1VaR3UgWmY,15500
43
43
  unique_toolkit/language_model/utils.py,sha256=bPQ4l6_YO71w-zaIPanUUmtbXC1_hCvLK0tAFc3VCRc,1902
44
- unique_toolkit-0.5.44.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
45
- unique_toolkit-0.5.44.dist-info/METADATA,sha256=IXHGnl23ctzUc3Pm2BXVwDoHyScGkgd7dBawlOkEAZ4,15154
46
- unique_toolkit-0.5.44.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
47
- unique_toolkit-0.5.44.dist-info/RECORD,,
44
+ unique_toolkit/short_term_memory/schemas.py,sha256=OhfcXyF6ACdwIXW45sKzjtZX_gkcJs8FEZXcgQTNenw,1406
45
+ unique_toolkit/short_term_memory/service.py,sha256=Jd9P72-VvJy7hnqNrjmrmB5BHmsKuOpTiT0Jr-dBbsQ,1682
46
+ unique_toolkit-0.5.46.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
47
+ unique_toolkit-0.5.46.dist-info/METADATA,sha256=dOAcMwh7VpRNOedFNvGEA_AypsA-LCuuVqQknJxO_Sc,15336
48
+ unique_toolkit-0.5.46.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
49
+ unique_toolkit-0.5.46.dist-info/RECORD,,