unique_toolkit 0.5.20__py3-none-any.whl → 0.5.21__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,14 @@
1
1
  from enum import StrEnum
2
+ from typing import Optional
2
3
 
3
4
  from humps import camelize
4
- from pydantic import BaseModel, ConfigDict, Field, field_validator
5
+ from pydantic import (
6
+ BaseModel,
7
+ ConfigDict,
8
+ Field,
9
+ field_validator,
10
+ model_validator,
11
+ )
5
12
 
6
13
  # set config to convert camelCase to snake_case
7
14
  model_config = ConfigDict(
@@ -12,6 +19,22 @@ model_config = ConfigDict(
12
19
  class ChatMessageRole(StrEnum):
13
20
  USER = "user"
14
21
  ASSISTANT = "assistant"
22
+ TOOL = "tool"
23
+
24
+
25
+ class Function(BaseModel):
26
+ model_config = model_config
27
+
28
+ name: str
29
+ arguments: str
30
+
31
+
32
+ class ToolCall(BaseModel):
33
+ model_config = model_config
34
+
35
+ id: str
36
+ type: str
37
+ function: Function
15
38
 
16
39
 
17
40
  class ChatMessage(BaseModel):
@@ -21,6 +44,8 @@ class ChatMessage(BaseModel):
21
44
  object: str | None = None
22
45
  content: str = Field(alias="text")
23
46
  role: ChatMessageRole
47
+ tool_calls: Optional[list[ToolCall]] = None
48
+ tool_call_id: Optional[str] = None
24
49
  debug_info: dict | None = {}
25
50
 
26
51
  # TODO make sdk return role consistently in lowercase
@@ -28,3 +53,10 @@ class ChatMessage(BaseModel):
28
53
  @field_validator("role", mode="before")
29
54
  def set_role(cls, value: str):
30
55
  return value.lower()
56
+
57
+ # Ensure tool_call_ids is required if role is 'tool'
58
+ @model_validator(mode="after")
59
+ def check_tool_call_ids_for_tool_role(self):
60
+ if self.role == ChatMessageRole.TOOL and not self.tool_call_id:
61
+ raise ValueError("tool_call_ids is required when role is 'tool'")
62
+ return self
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unique_toolkit
3
- Version: 0.5.20
3
+ Version: 0.5.21
4
4
  Summary:
5
5
  License: MIT
6
6
  Author: Martin Fadler
@@ -100,6 +100,9 @@ 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.21] - 2024-09-16
104
+ - Add `tool` as new role `ChatMessage`, as well as `tool_calls` and `tool_call_id` as additional parameters
105
+
103
106
  ## [0.5.20] - 2024-09-16
104
107
  - `LanguageModelService` now supports complete_util_async that can be called without instantiating the class, currently being used in the Hallucination service and evaluation API
105
108
 
@@ -9,7 +9,7 @@ unique_toolkit/app/performance/async_wrapper.py,sha256=yVVcRDkcdyfjsxro-N29SBvi-
9
9
  unique_toolkit/app/schemas.py,sha256=tzrmUFKZUdC1P3LxZ7DrElpkMtekUDoClb7jCRzGqNQ,1521
10
10
  unique_toolkit/app/verification.py,sha256=UZqTHg3PX_QxMjeLH_BVBYoMVqMnMpeMoqvyTBKDqj8,1996
11
11
  unique_toolkit/chat/__init__.py,sha256=1prdTVfLOf6NgU-Aa1VIO-XiR6OYuRm51LaVRfKDCqc,267
12
- unique_toolkit/chat/schemas.py,sha256=ff4M-XMagF0Evn3FcKHHP5xzDEyufZgq9Dmit3i8r_E,802
12
+ unique_toolkit/chat/schemas.py,sha256=IHOnb3pWlRlSPoEUWBTl6LK8YeMdlg2iXi9ghyBeiLw,1495
13
13
  unique_toolkit/chat/service.py,sha256=nVZ8agpEsXI2-5bS61e1Eawd0abioEQPov2xahiJtfk,17848
14
14
  unique_toolkit/chat/state.py,sha256=Cjgwv_2vhDFbV69xxsn7SefhaoIAEqLx3ferdVFCnOg,1445
15
15
  unique_toolkit/chat/utils.py,sha256=ihm-wQykBWhB4liR3LnwPVPt_qGW6ETq21Mw4HY0THE,854
@@ -26,7 +26,7 @@ unique_toolkit/language_model/infos.py,sha256=ETAUV0YTs6BjwuiTdhKz247CtL0W8Jwo3-
26
26
  unique_toolkit/language_model/schemas.py,sha256=DGZL6j63txkq5rdCn1uuVQIyLOyZt9t8J4f8JzhZENg,4607
27
27
  unique_toolkit/language_model/service.py,sha256=CvVo5CBa5Ia_fQD3DtJRsVChybuUfGFV5ml2_78_p1I,13395
28
28
  unique_toolkit/language_model/utils.py,sha256=WBPj1XKkDgxy_-T8HCZvsfkkSzj_1w4UZzNmyvdbBLY,1081
29
- unique_toolkit-0.5.20.dist-info/LICENSE,sha256=bIeCWCYuoUU_MzNdg48-ubJSVm7qxakaRbzTiJ5uxrs,1065
30
- unique_toolkit-0.5.20.dist-info/METADATA,sha256=RlEnbfzQ12Do8nqVzhdWLfIktxKQbzu7ffdacfkWmTw,11108
31
- unique_toolkit-0.5.20.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
32
- unique_toolkit-0.5.20.dist-info/RECORD,,
29
+ unique_toolkit-0.5.21.dist-info/LICENSE,sha256=bIeCWCYuoUU_MzNdg48-ubJSVm7qxakaRbzTiJ5uxrs,1065
30
+ unique_toolkit-0.5.21.dist-info/METADATA,sha256=H0uDtak7X3iObJFeImnvuSuMo7EgX_M09eMNknMOTqw,11242
31
+ unique_toolkit-0.5.21.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
32
+ unique_toolkit-0.5.21.dist-info/RECORD,,