unique_toolkit 1.44.0__py3-none-any.whl → 1.45.1__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,5 +1,8 @@
1
+ from __future__ import annotations
2
+
1
3
  import mimetypes
2
4
  from enum import StrEnum
5
+ from pathlib import Path
3
6
 
4
7
 
5
8
  class FileMimeType(StrEnum):
@@ -8,11 +11,82 @@ class FileMimeType(StrEnum):
8
11
  DOC = "application/msword"
9
12
  XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
10
13
  XLS = "application/vnd.ms-excel"
14
+ PPT = "application/vnd.ms-powerpoint"
11
15
  PPTX = "application/vnd.openxmlformats-officedocument.presentationml.presentation"
12
16
  CSV = "text/csv"
13
17
  HTML = "text/html"
14
18
  MD = "text/markdown"
15
19
  TXT = "text/plain"
20
+ JSON = "application/json"
21
+
22
+ @classmethod
23
+ def get_mime_from_file_path(cls, filepath: Path) -> "FileMimeType | None":
24
+ mime_type, _ = mimetypes.guess_type(filepath)
25
+ if mime_type is None:
26
+ return None
27
+ try:
28
+ return cls(mime_type)
29
+ except ValueError:
30
+ return None
31
+
32
+ @classmethod
33
+ def is_docx_mime(cls, filepath: Path) -> bool:
34
+ mime_type = cls.get_mime_from_file_path(filepath)
35
+ return mime_type in {cls.DOCX, cls.DOC}
36
+
37
+ @classmethod
38
+ def is_pdf_mime(cls, filepath: Path) -> bool:
39
+ mime_type = cls.get_mime_from_file_path(filepath)
40
+ return mime_type == cls.PDF
41
+
42
+ @classmethod
43
+ def is_xlsx_mime(cls, filepath: Path) -> bool:
44
+ mime_type = cls.get_mime_from_file_path(filepath)
45
+ return mime_type in {cls.XLSX, cls.XLS}
46
+
47
+ @classmethod
48
+ def is_pptx_mime(cls, filepath: Path) -> bool:
49
+ mime_type = cls.get_mime_from_file_path(filepath)
50
+ return mime_type in {cls.PPTX, cls.PPT}
51
+
52
+ @classmethod
53
+ def is_json_mime(cls, filepath: Path) -> bool:
54
+ mime_type = cls.get_mime_from_file_path(filepath)
55
+ return mime_type == cls.JSON
56
+
57
+ @classmethod
58
+ def is_valid_mime(cls, filepath: Path, valid_mimes: list[FileMimeType]) -> bool:
59
+ mime_type = cls.get_mime_from_file_path(filepath)
60
+ return mime_type in valid_mimes
61
+
62
+
63
+ def get_common_name(extension: FileMimeType) -> str:
64
+ match extension:
65
+ case FileMimeType.DOCX | FileMimeType.DOC:
66
+ return "docx"
67
+ case FileMimeType.XLSX | FileMimeType.XLS:
68
+ return "excel"
69
+ case FileMimeType.PPT | FileMimeType.PPTX:
70
+ return "powerpoint"
71
+ case FileMimeType.PDF:
72
+ return "pdf"
73
+ case FileMimeType.JSON:
74
+ return "json"
75
+ case FileMimeType.CSV:
76
+ return "csv"
77
+ case FileMimeType.TXT:
78
+ return "text"
79
+ case FileMimeType.MD:
80
+ return "markdown"
81
+ case FileMimeType.HTML:
82
+ return "html"
83
+ case _:
84
+ return "unknown"
85
+
86
+
87
+ def get_file_extensions(mimes: list[FileMimeType]) -> list[str]:
88
+ types = [mimetypes.guess_extension(mime) for mime in mimes]
89
+ return [t for t in types if t]
16
90
 
17
91
 
18
92
  class ImageMimeType(StrEnum):
@@ -10,6 +10,7 @@ from pydantic import RootModel
10
10
  from unique_toolkit._common.token.token_counting import (
11
11
  num_tokens_per_language_model_message,
12
12
  )
13
+ from unique_toolkit._common.utils import files as FileUtils
13
14
  from unique_toolkit.app import ChatEventUserMessage
14
15
  from unique_toolkit.chat.schemas import ChatMessage
15
16
  from unique_toolkit.chat.schemas import ChatMessageRole as ChatRole
@@ -29,29 +30,6 @@ map_chat_llm_message_role = {
29
30
  }
30
31
 
31
32
 
32
- class ImageMimeType(StrEnum):
33
- JPEG = "image/jpeg"
34
- PNG = "image/png"
35
- GIF = "image/gif"
36
- BMP = "image/bmp"
37
- WEBP = "image/webp"
38
- TIFF = "image/tiff"
39
- SVG = "image/svg+xml"
40
-
41
-
42
- class FileMimeType(StrEnum):
43
- PDF = "application/pdf"
44
- DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
45
- DOC = "application/msword"
46
- XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
47
- XLS = "application/vnd.ms-excel"
48
- PPTX = "application/vnd.openxmlformats-officedocument.presentationml.presentation"
49
- CSV = "text/csv"
50
- HTML = "text/html"
51
- MD = "text/markdown"
52
- TXT = "text/plain"
53
-
54
-
55
33
  class ChatMessageWithContents(ChatMessage):
56
34
  contents: list[Content] = []
57
35
 
@@ -93,24 +71,6 @@ class ChatHistoryWithContent(RootModel):
93
71
  return self.root[item]
94
72
 
95
73
 
96
- def is_image_content(filename: str) -> bool:
97
- mimetype, _ = mimetypes.guess_type(filename)
98
-
99
- if not mimetype:
100
- return False
101
-
102
- return mimetype in ImageMimeType.__members__.values()
103
-
104
-
105
- def is_file_content(filename: str) -> bool:
106
- mimetype, _ = mimetypes.guess_type(filename)
107
-
108
- if not mimetype:
109
- return False
110
-
111
- return mimetype in FileMimeType.__members__.values()
112
-
113
-
114
74
  def get_chat_history_with_contents(
115
75
  user_message: ChatEventUserMessage,
116
76
  chat_id: str,
@@ -152,7 +112,7 @@ def download_encoded_images(
152
112
  ) -> list[str]:
153
113
  base64_encoded_images = []
154
114
  for im in contents:
155
- if is_image_content(im.key):
115
+ if FileUtils.is_image_content(im.key):
156
116
  try:
157
117
  file_bytes = content_service.download_content_to_bytes(
158
118
  content_id=im.id,
@@ -224,8 +184,12 @@ def get_full_history_with_contents(
224
184
  text = ""
225
185
 
226
186
  if len(c.contents) > 0:
227
- file_contents = [co for co in c.contents if is_file_content(co.key)]
228
- image_contents = [co for co in c.contents if is_image_content(co.key)]
187
+ file_contents = [
188
+ co for co in c.contents if FileUtils.is_file_content(co.key)
189
+ ]
190
+ image_contents = [
191
+ co for co in c.contents if FileUtils.is_image_content(co.key)
192
+ ]
229
193
 
230
194
  content = (
231
195
  text
@@ -7,8 +7,6 @@ from unique_toolkit.agentic.tools.openai_builtin.base import (
7
7
  )
8
8
  from unique_toolkit.agentic.tools.schemas import BaseToolConfig
9
9
 
10
- DEFAULT_TOOL_DESCRIPTION = "Use this tool to run python code, e.g to generate plots, process excel files, perform calculations, etc."
11
-
12
10
  DEFAULT_TOOL_DESCRIPTION_FOR_SYSTEM_PROMPT = """
13
11
  Use this tool to run python code, e.g to generate plots, process excel files, perform calculations, etc.
14
12
 
@@ -48,11 +46,9 @@ Handling User Queries:
48
46
  - After exhausting all possible solutions without success, inform the user of what was tried and request clarification/help.
49
47
  """.strip()
50
48
 
51
- DEFAULT_TOOL_FORMAT_INFORMATION_FOR_SYSTEM_PROMPT = ""
52
-
53
- DEFAULT_TOOL_FORMAT_INFORMATION_FOR_USER_PROMPT = ""
54
49
 
55
50
  DEFAULT_TOOL_DESCRIPTION_FOR_USER_PROMPT = ""
51
+ DEFAULT_TOOL_DESCRIPTION = "Use this tool to run python code, e.g to generate plots, process excel files, perform calculations, etc."
56
52
 
57
53
 
58
54
  class OpenAICodeInterpreterConfig(BaseToolConfig):
@@ -60,33 +56,20 @@ class OpenAICodeInterpreterConfig(BaseToolConfig):
60
56
  default=True,
61
57
  description="If set, the files uploaded to the chat will be uploaded to the container where code is executed.",
62
58
  )
63
-
64
59
  tool_description: str = Field(
65
60
  default=DEFAULT_TOOL_DESCRIPTION,
66
- description="The description of the tool that will be sent to the model.",
61
+ description="The description of the tool that will be included in the system prompt.",
67
62
  )
68
63
  tool_description_for_system_prompt: str = Field(
69
64
  default=DEFAULT_TOOL_DESCRIPTION_FOR_SYSTEM_PROMPT,
70
65
  description="The description of the tool that will be included in the system prompt.",
71
66
  )
72
- tool_format_information_for_system_prompt: SkipJsonSchema[str] = Field(
73
- # Since the tool is executed in Azure, it's not always possible to have dynamic format information
74
- default=DEFAULT_TOOL_FORMAT_INFORMATION_FOR_SYSTEM_PROMPT,
75
- description="The format information of the tool that will be included in the system prompt.",
76
- )
77
67
  tool_description_for_user_prompt: SkipJsonSchema[str] = (
78
68
  Field( # At the moment, this is not appended to the user prompt
79
69
  default=DEFAULT_TOOL_DESCRIPTION_FOR_USER_PROMPT,
80
70
  description="The description of the tool that will be included in the user prompt.",
81
71
  )
82
72
  )
83
- tool_format_information_for_user_prompt: SkipJsonSchema[str] = (
84
- Field( # At the moment, this is not appended to the user prompt
85
- default=DEFAULT_TOOL_FORMAT_INFORMATION_FOR_USER_PROMPT,
86
- description="The format information of the tool that will be included in the user prompt.",
87
- )
88
- )
89
-
90
73
  expires_after_minutes: int = Field(
91
74
  default=20,
92
75
  description="The number of minutes after which the container will be deleted.",
@@ -239,9 +239,9 @@ class OpenAICodeInterpreterTool(OpenAIBuiltInTool[CodeInterpreter]):
239
239
  display_name=self.DISPLAY_NAME,
240
240
  tool_description=self._config.tool_description,
241
241
  tool_system_prompt=self._config.tool_description_for_system_prompt,
242
- tool_format_information_for_system_prompt=self._config.tool_format_information_for_system_prompt,
242
+ tool_format_information_for_system_prompt="",
243
243
  tool_user_prompt=self._config.tool_description_for_user_prompt,
244
- tool_format_information_for_user_prompt=self._config.tool_format_information_for_user_prompt,
244
+ tool_format_information_for_user_prompt="",
245
245
  input_model={},
246
246
  )
247
247
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unique_toolkit
3
- Version: 1.44.0
3
+ Version: 1.45.1
4
4
  Summary:
5
5
  License: Proprietary
6
6
  Author: Cedric Klinkert
@@ -125,6 +125,12 @@ All notable changes to this project will be documented in this file.
125
125
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
126
126
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
127
127
 
128
+ ## [1.45.1] - 2026-01-26
129
+ - Add FileMimeType utility helpers
130
+
131
+ ## [1.45.0] - 2026-01-23
132
+ - Remove unused code execution options from config
133
+
128
134
  ## [1.44.0] - 2026-01-23
129
135
  - Add LoopIterationRunner abstraction for the responses api
130
136
 
@@ -55,7 +55,7 @@ unique_toolkit/_common/tests/test_string_utilities.py,sha256=J2HYZ1fniOfJWI149wl
55
55
  unique_toolkit/_common/token/image_token_counting.py,sha256=VpFfZyY0GIH27q_Wy4YNjk2algqvbCtJyzuuROoFQPw,2189
56
56
  unique_toolkit/_common/token/token_counting.py,sha256=gM4B_aUqKqEPvmStFNcvCWNMNNNNKbVaywBDxlbgIps,7121
57
57
  unique_toolkit/_common/utils/__init__.py,sha256=qHrEy-3zkbFPdGFriRscPbGKuQfOuPi3O7tE5Zw5VHY,37
58
- unique_toolkit/_common/utils/files.py,sha256=97PkhXDUMXFEhje5HzWMMlLvZj49A6jOifqFRIrzu5M,1102
58
+ unique_toolkit/_common/utils/files.py,sha256=cYMWl74atTBQmmGg0BPIHQ0jfMS_R5O7VSTe41fslBE,3460
59
59
  unique_toolkit/_common/utils/image/encode.py,sha256=IJhtTcIT_azhiDsPp15oYs2LPze2l-sGlZrJASHrDVI,658
60
60
  unique_toolkit/_common/utils/jinja/helpers.py,sha256=UQWj0hFMtnuUFYDJ8NKbEblvYE8DrWX1o7fKQU3H9IQ,262
61
61
  unique_toolkit/_common/utils/jinja/render.py,sha256=J5UBIWoljl-Us7SjZIap9wewcLTzpXjQpOgas_YTf3Y,482
@@ -86,7 +86,7 @@ unique_toolkit/agentic/evaluation/tests/test_context_relevancy_service.py,sha256
86
86
  unique_toolkit/agentic/evaluation/tests/test_output_parser.py,sha256=RN_HcBbU6qy_e_PoYyUFcjWnp3ymJ6-gLj6TgEOupAI,3107
87
87
  unique_toolkit/agentic/feature_flags/__init__.py,sha256=LhE2cHoa9AYBOR7TjiIToOn46sttm9paKcrzE7gnDPM,149
88
88
  unique_toolkit/agentic/feature_flags/feature_flags.py,sha256=4jPH0GGGt5-tQ6PJWNpMBIlYzNrQIIqBLx8W02lwxD0,1140
89
- unique_toolkit/agentic/history_manager/history_construction_with_contents.py,sha256=kzxpVzTtQqL8TjdIvOy7gkRVxD4BsOMyimECryg7vdc,9060
89
+ unique_toolkit/agentic/history_manager/history_construction_with_contents.py,sha256=TwamOOnYTYZMQdY1mAzj6_MZOe3T5RsjFDarT1tCtYo,8150
90
90
  unique_toolkit/agentic/history_manager/history_manager.py,sha256=7V7_173XkAjc8otBACF0G3dbqRs34FSlURbBPrE95Wk,9537
91
91
  unique_toolkit/agentic/history_manager/loop_token_reducer.py,sha256=3c-uonDovtanEJUpAO4zlA4-n9MS_Ws_V0Yb6G7hPM0,20172
92
92
  unique_toolkit/agentic/history_manager/utils.py,sha256=VIn_UmcR3jHtpux0qp5lQQzczgAm8XYSeQiPo87jC3A,3143
@@ -152,8 +152,8 @@ unique_toolkit/agentic/tools/mcp/tool_wrapper.py,sha256=JuNP_mild2vx6opIt5432y6m
152
152
  unique_toolkit/agentic/tools/openai_builtin/__init__.py,sha256=NdVjkTa3LbW-JHhzPRjinTmgOCtEv090Zr9jGZXmgqs,345
153
153
  unique_toolkit/agentic/tools/openai_builtin/base.py,sha256=qtUtv-iyid4GpTRKU7IwWuY_OCPHLKEi9x7MCftyLG0,1178
154
154
  unique_toolkit/agentic/tools/openai_builtin/code_interpreter/__init__.py,sha256=w2vONpnC6hKRPoJGwzDuRtNBsQd_o-gMUqArgIl_5KY,305
155
- unique_toolkit/agentic/tools/openai_builtin/code_interpreter/config.py,sha256=GS0WLrAo0lCW7d4ih5wheskNG7AsdXsbwEYEESX4K60,5327
156
- unique_toolkit/agentic/tools/openai_builtin/code_interpreter/service.py,sha256=KvJWpD-Qief_OONMs_WG8Ya2e9AnmT6Lzow-6lmnVcY,7998
155
+ unique_toolkit/agentic/tools/openai_builtin/code_interpreter/config.py,sha256=U5MHglk4wkVd2L4DxSiATZElr2RUUwKAmPrmt6n70PY,4538
156
+ unique_toolkit/agentic/tools/openai_builtin/code_interpreter/service.py,sha256=bzOU8rV-FUkgSpX-kWzd0_WDEP3sOtzPF2Hbodh0oLA,7896
157
157
  unique_toolkit/agentic/tools/openai_builtin/manager.py,sha256=QeDVgLfnCXrSmXI3b9bgQa9oyfQe_L15wa_YfhfNe9E,2633
158
158
  unique_toolkit/agentic/tools/schemas.py,sha256=TXshRvivr2hD-McXHumO0bp-Z0mz_GnAmQRiVjT59rU,5025
159
159
  unique_toolkit/agentic/tools/test/test_mcp_manager.py,sha256=VpB4k4Dh0lQWakilJMQSzO8sBXapuEC26cub_lorl-M,19221
@@ -244,7 +244,7 @@ unique_toolkit/short_term_memory/service.py,sha256=5PeVBu1ZCAfyDb2HLVvlmqSbyzBBu
244
244
  unique_toolkit/smart_rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
245
245
  unique_toolkit/smart_rules/compile.py,sha256=Ozhh70qCn2yOzRWr9d8WmJeTo7AQurwd3tStgBMPFLA,1246
246
246
  unique_toolkit/test_utilities/events.py,sha256=_mwV2bs5iLjxS1ynDCjaIq-gjjKhXYCK-iy3dRfvO3g,6410
247
- unique_toolkit-1.44.0.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
248
- unique_toolkit-1.44.0.dist-info/METADATA,sha256=Fk433fZFvwde68I03RGFFqGWieqXJd_MTQ0dOKfowx0,48674
249
- unique_toolkit-1.44.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
250
- unique_toolkit-1.44.0.dist-info/RECORD,,
247
+ unique_toolkit-1.45.1.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
248
+ unique_toolkit-1.45.1.dist-info/METADATA,sha256=eOnY9Pn3u5dfO_Fgz88Rxmh_7O5DXw1WJjgYBmzCDJ8,48812
249
+ unique_toolkit-1.45.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
250
+ unique_toolkit-1.45.1.dist-info/RECORD,,