unique_toolkit 1.38.3__py3-none-any.whl → 1.39.0__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.
- unique_toolkit/agentic/loop_runner/__init__.py +15 -5
- unique_toolkit/agentic/loop_runner/_iteration_handler_utils.py +95 -0
- unique_toolkit/agentic/loop_runner/middleware/__init__.py +0 -8
- unique_toolkit/agentic/loop_runner/runners/__init__.py +14 -1
- unique_toolkit/agentic/loop_runner/runners/basic.py +8 -58
- unique_toolkit/agentic/loop_runner/runners/qwen/__init__.py +15 -0
- unique_toolkit/agentic/loop_runner/{middleware/qwen_forced_tool_call → runners/qwen}/helpers.py +15 -0
- unique_toolkit/agentic/loop_runner/runners/qwen/qwen_runner.py +118 -0
- unique_toolkit/app/schemas.py +15 -7
- unique_toolkit/services/chat_service.py +409 -1
- unique_toolkit/short_term_memory/functions.py +126 -4
- unique_toolkit/short_term_memory/schemas.py +27 -22
- {unique_toolkit-1.38.3.dist-info → unique_toolkit-1.39.0.dist-info}/METADATA +28 -20
- {unique_toolkit-1.38.3.dist-info → unique_toolkit-1.39.0.dist-info}/RECORD +16 -15
- unique_toolkit/agentic/loop_runner/middleware/qwen_forced_tool_call/__init__.py +0 -13
- unique_toolkit/agentic/loop_runner/middleware/qwen_forced_tool_call/qwen_forced_tool_call.py +0 -50
- {unique_toolkit-1.38.3.dist-info → unique_toolkit-1.39.0.dist-info}/LICENSE +0 -0
- {unique_toolkit-1.38.3.dist-info → unique_toolkit-1.39.0.dist-info}/WHEEL +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: unique_toolkit
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.39.0
|
|
4
4
|
Summary:
|
|
5
5
|
License: Proprietary
|
|
6
6
|
Author: Cedric Klinkert
|
|
@@ -41,9 +41,25 @@ The Toolkit is structured along the following domains:
|
|
|
41
41
|
- `unique_toolkit.language_model`
|
|
42
42
|
- `unique_toolkit.short_term_memory`
|
|
43
43
|
|
|
44
|
-
Each domain comprises a set of
|
|
44
|
+
Each domain comprises a set of schemas (in `schemas.py`) are used in functions (in `functions.py`) which encapsulates the basic functionalities to interact with the plattform.
|
|
45
|
+
The above domains represent the internal structure of the Unique platform.
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
For the `developers` we expose interfaces via `services` classes that correspond directly to an frontend or an entity the `user` interacts with.
|
|
48
|
+
|
|
49
|
+
The following services are currently available:
|
|
50
|
+
|
|
51
|
+
| Service | Responsability |
|
|
52
|
+
|--|--|
|
|
53
|
+
| ChatService | All interactions with the chat interface |
|
|
54
|
+
| KnowledgeBaseService | All interaction with the knowledgebase |
|
|
55
|
+
|
|
56
|
+
The services can be directly import as
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
from unique_toolkit import ChatService, KnowledgeBaseService
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
In addition, the `unique_toolkit.app` module provides functions to initialize apps and dev utilities to interact with the Unique platform.
|
|
47
63
|
|
|
48
64
|
## Changelog
|
|
49
65
|
|
|
@@ -65,7 +81,6 @@ The `unique_toolkit.app` module encompasses functions for initializing and secur
|
|
|
65
81
|
The `unique_toolkit.chat` module encompasses all chat related functionality.
|
|
66
82
|
|
|
67
83
|
- `functions.py` comprises the functions to manage and load the chat history and interact with the chat ui, e.g., creating a new assistant message.
|
|
68
|
-
- `service.py` comprises the ChatService and provides an interface to manage and load the chat history and interact with the chat ui, e.g., creating a new assistant message and stream complete.
|
|
69
84
|
- `schemas.py` comprises all relevant schemas, e.g., ChatMessage, used in the ChatService.
|
|
70
85
|
- `utils.py` comprises utility functions to use and convert ChatMessage objects in assistants, e.g., convert_chat_history_to_injectable_string converts the chat history to a string that can be injected into a prompt.
|
|
71
86
|
|
|
@@ -74,11 +89,10 @@ The `unique_toolkit.chat` module encompasses all chat related functionality.
|
|
|
74
89
|
The `unique_toolkit.content` module encompasses all content related functionality. Content can be any type of textual data that is stored in the Knowledgebase on the Unique platform. During the ingestion of the content, the content is parsed, split in chunks, indexed, and stored in the database.
|
|
75
90
|
|
|
76
91
|
- `functions.py` comprises the functions to manage and load the chat history and interact with the chat ui, e.g., creating a new assistant message.
|
|
77
|
-
- `service.py` comprises the ContentService and provides an interface to interact with the content, e.g., search content, search content chunks, upload and download content.
|
|
78
92
|
- `schemas.py` comprises all relevant schemas, e.g., Content and ContentChunk, used in the ContentService.
|
|
79
93
|
- `utils.py` comprise utility functions to manipulate Content and ContentChunk objects, e.g., sort_content_chunks and merge_content_chunks.
|
|
80
94
|
|
|
81
|
-
## Embedding
|
|
95
|
+
## Embedding (To be Deprecated)
|
|
82
96
|
|
|
83
97
|
The `unique_toolkit.embedding` module encompasses all embedding related functionality. Embeddings are used to represent textual data in a high-dimensional space. The embeddings can be used to calculate the similarity between two texts, for instance.
|
|
84
98
|
|
|
@@ -86,34 +100,22 @@ The `unique_toolkit.embedding` module encompasses all embedding related function
|
|
|
86
100
|
- `service.py` encompasses the EmbeddingService and provides an interface to interact with the embeddings, e.g., embed text and calculate the similarity between two texts.
|
|
87
101
|
- `schemas.py` comprises all relevant schemas, e.g., Embeddings, used in the EmbeddingService.
|
|
88
102
|
|
|
89
|
-
## Language Model
|
|
103
|
+
## Language Model
|
|
90
104
|
|
|
91
105
|
The `unique_toolkit.language_model` module encompasses all language model related functionality and information on the different language models deployed through the
|
|
92
106
|
Unique platform.
|
|
93
107
|
|
|
94
108
|
- `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_4o_2024_1120) to get the information on the specific language model like the name, version, token limits or retirement date.
|
|
95
109
|
- `functions.py` comprises the functions to complete and stream complete to chat.
|
|
96
|
-
- `service.py` comprises the LanguageModelService and provides an interface to interact with the language models, e.g., complete.
|
|
97
110
|
- `schemas.py` comprises all relevant schemas, e.g., LanguageModelResponse, used in the LanguageModelService.
|
|
98
111
|
- `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.
|
|
99
112
|
|
|
100
|
-
## Short Term Memory
|
|
113
|
+
## Short Term Memory
|
|
101
114
|
|
|
102
115
|
The `unique_toolkit.short_term_memory` module encompasses all short term memory related functionality.
|
|
103
116
|
|
|
104
117
|
- `functions.py` comprises the functions to manage and load the chat history and interact with the chat ui, e.g., creating a new assistant message.
|
|
105
|
-
- `service.py` comprises the ShortTermMemoryService and provides an interface to interact with the short term memory, e.g., create memory.
|
|
106
118
|
- `schemas.py` comprises all relevant schemas, e.g., ShortTermMemory, used in the ShortTermMemoryService.
|
|
107
|
-
|
|
108
|
-
# Development instructions
|
|
109
|
-
|
|
110
|
-
1. Install poetry on your system (through `brew` or `pipx`).
|
|
111
|
-
|
|
112
|
-
2. Install `pyenv` and install python 3.11. `pyenv` is recommended as otherwise poetry uses the python version used to install itself and not the user preferred python version.
|
|
113
|
-
|
|
114
|
-
3. If you then run `python --version` in your terminal, you should be able to see python version as specified in `.python-version`.
|
|
115
|
-
|
|
116
|
-
4. Then finally run `poetry install` to install the package and all dependencies.
|
|
117
119
|
# Changelog
|
|
118
120
|
|
|
119
121
|
All notable changes to this project will be documented in this file.
|
|
@@ -121,6 +123,12 @@ All notable changes to this project will be documented in this file.
|
|
|
121
123
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
122
124
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
123
125
|
|
|
126
|
+
## [1.39.0] - 2025-12-17
|
|
127
|
+
- Adding simpler shortterm message abilities to chat service
|
|
128
|
+
|
|
129
|
+
## [1.38.4] - 2025-12-17
|
|
130
|
+
- Improving handling of tool calls with Qwen models
|
|
131
|
+
|
|
124
132
|
## [1.38.3] - 2025-12-17
|
|
125
133
|
- Move the failsafe exception to root folder of unique_toolkit from agentic tools
|
|
126
134
|
|
|
@@ -63,18 +63,19 @@ unique_toolkit/agentic/history_manager/history_construction_with_contents.py,sha
|
|
|
63
63
|
unique_toolkit/agentic/history_manager/history_manager.py,sha256=7V7_173XkAjc8otBACF0G3dbqRs34FSlURbBPrE95Wk,9537
|
|
64
64
|
unique_toolkit/agentic/history_manager/loop_token_reducer.py,sha256=3c-uonDovtanEJUpAO4zlA4-n9MS_Ws_V0Yb6G7hPM0,20172
|
|
65
65
|
unique_toolkit/agentic/history_manager/utils.py,sha256=VIn_UmcR3jHtpux0qp5lQQzczgAm8XYSeQiPo87jC3A,3143
|
|
66
|
-
unique_toolkit/agentic/loop_runner/__init__.py,sha256=
|
|
66
|
+
unique_toolkit/agentic/loop_runner/__init__.py,sha256=3Ddm4WXa5KBTwScvmn6INmBBcuFVfJGriOE6VUfGVkM,1037
|
|
67
|
+
unique_toolkit/agentic/loop_runner/_iteration_handler_utils.py,sha256=czwTbMMmikppRjAA2wpx-UZGub8KrpSoWfojklr-5sE,3261
|
|
67
68
|
unique_toolkit/agentic/loop_runner/_stream_handler_utils.py,sha256=FTGc5y8wkDnwnRVSYEdandgKz-FiySOsrTFFMadwP6E,1706
|
|
68
69
|
unique_toolkit/agentic/loop_runner/base.py,sha256=3g4PalzV00o8kcRwHds2c2rtxW4idD7_7vS2Z7GkMvQ,1370
|
|
69
|
-
unique_toolkit/agentic/loop_runner/middleware/__init__.py,sha256=
|
|
70
|
+
unique_toolkit/agentic/loop_runner/middleware/__init__.py,sha256=5yhFZ14_C1qAt-Mb3u3nZ1h6gxuSZ5Ts90-rbk2jjUM,232
|
|
70
71
|
unique_toolkit/agentic/loop_runner/middleware/planning/__init__.py,sha256=Y9MlihNA8suNREixW98RF45bj0EMtD_tQuDrO2MEML4,304
|
|
71
72
|
unique_toolkit/agentic/loop_runner/middleware/planning/planning.py,sha256=s6SAP3BCCExgwnyRj_bZTaWgTOiNVju5qcJA0WFUUoE,3216
|
|
72
73
|
unique_toolkit/agentic/loop_runner/middleware/planning/schema.py,sha256=76C36CWCLfDAYYqtaQlhXsmkWM1fCqf8j-l5afQREKA,2869
|
|
73
|
-
unique_toolkit/agentic/loop_runner/
|
|
74
|
-
unique_toolkit/agentic/loop_runner/
|
|
75
|
-
unique_toolkit/agentic/loop_runner/
|
|
76
|
-
unique_toolkit/agentic/loop_runner/runners/
|
|
77
|
-
unique_toolkit/agentic/loop_runner/runners/
|
|
74
|
+
unique_toolkit/agentic/loop_runner/runners/__init__.py,sha256=9aUSdHgwAfwEmvE_xL7luxmaL2HaU-fG_x-HLbHls9k,536
|
|
75
|
+
unique_toolkit/agentic/loop_runner/runners/basic.py,sha256=PKg7AXp5_2OJpJX8b7_5u0jBKffX5mg8X6DFk98sSwA,1535
|
|
76
|
+
unique_toolkit/agentic/loop_runner/runners/qwen/__init__.py,sha256=b2zAQIjtPy_BBQeDHsdfDLTKigI11w7tXHgUGNnFIiU,419
|
|
77
|
+
unique_toolkit/agentic/loop_runner/runners/qwen/helpers.py,sha256=JBnxeYKu8HiUq3VHjnb8XdHCe1c3cJ3OwagckF4UvnU,1763
|
|
78
|
+
unique_toolkit/agentic/loop_runner/runners/qwen/qwen_runner.py,sha256=7tYfTkNKwxYVn6C1Htya5QEIK2BfWkxCPNkdMoaZGq0,4920
|
|
78
79
|
unique_toolkit/agentic/message_log_manager/__init__.py,sha256=3-KY_sGkPbNoSnrzwPY0FQIJNnsz4NHXvocXgGRUeuE,169
|
|
79
80
|
unique_toolkit/agentic/message_log_manager/service.py,sha256=AiuIq2dKQg9Y8bEYgGcve1X8-WRRdqPZXaZXXLJxfFM,3057
|
|
80
81
|
unique_toolkit/agentic/postprocessor/postprocessor_manager.py,sha256=CoKzVFeLIr1eRP3ZLnmUJ8KNsFLyvK5iuvUilbcGAm0,7662
|
|
@@ -143,7 +144,7 @@ unique_toolkit/app/init_logging.py,sha256=Sh26SRxOj8i8dzobKhYha2lLrkrMTHfB1V4jR3
|
|
|
143
144
|
unique_toolkit/app/init_sdk.py,sha256=5_oDoETr6akwYyBCb0ivTdMNu3SVgPSkrXcDS6ELyY8,2269
|
|
144
145
|
unique_toolkit/app/performance/async_tasks.py,sha256=H0l3OAcosLwNHZ8d2pd-Di4wHIXfclEvagi5kfqLFPA,1941
|
|
145
146
|
unique_toolkit/app/performance/async_wrapper.py,sha256=yVVcRDkcdyfjsxro-N29SBvi-7773wnfDplef6-y8xw,1077
|
|
146
|
-
unique_toolkit/app/schemas.py,sha256=
|
|
147
|
+
unique_toolkit/app/schemas.py,sha256=17Olyqc58LjFaZ6kYtPThWsGmRM0qGzDwRTekDNNw-E,10825
|
|
147
148
|
unique_toolkit/app/unique_settings.py,sha256=NTfa3a8wWzBDx4_4Irqyhy4mpXyPU6Munqs41ozPFnE,12366
|
|
148
149
|
unique_toolkit/app/verification.py,sha256=GxFFwcJMy25fCA_Xe89wKW7bgqOu8PAs5y8QpHF0GSc,3861
|
|
149
150
|
unique_toolkit/app/webhook.py,sha256=k7DP1UTR3p7D4qzuKPKVmGMAkDVHfALrnMIzTZqj_OI,2320
|
|
@@ -201,17 +202,17 @@ unique_toolkit/language_model/service.py,sha256=fI2S5JLawJRRkKg086Ysz2Of4AOBHPN-
|
|
|
201
202
|
unique_toolkit/language_model/utils.py,sha256=bPQ4l6_YO71w-zaIPanUUmtbXC1_hCvLK0tAFc3VCRc,1902
|
|
202
203
|
unique_toolkit/protocols/support.py,sha256=ZEnbQL5w2-T_1AeM8OHycZJ3qbdfVI1nXe0nL9esQEw,5544
|
|
203
204
|
unique_toolkit/services/__init__.py,sha256=90-IT5FjMcnlqxjp5kme9Fqgp_on46rggctIqHMdqsw,195
|
|
204
|
-
unique_toolkit/services/chat_service.py,sha256=
|
|
205
|
+
unique_toolkit/services/chat_service.py,sha256=EdeHseyBXBtXWx2gK5jXoGWBYjG6uyoLusQpGH8I6x0,73065
|
|
205
206
|
unique_toolkit/services/knowledge_base.py,sha256=uc89GL_NZXeFkJKkdHSSh2y1Wx0tmgasWk6uyGi4G_M,36210
|
|
206
207
|
unique_toolkit/short_term_memory/__init__.py,sha256=2mI3AUrffgH7Yt-xS57EGqnHf7jnn6xquoKEhJqk3Wg,185
|
|
207
208
|
unique_toolkit/short_term_memory/constants.py,sha256=698CL6-wjup2MvU19RxSmQk3gX7aqW_OOpZB7sbz_Xg,34
|
|
208
|
-
unique_toolkit/short_term_memory/functions.py,sha256
|
|
209
|
-
unique_toolkit/short_term_memory/schemas.py,sha256=
|
|
209
|
+
unique_toolkit/short_term_memory/functions.py,sha256=-3xEIAnHL4x5cuuWS_yUNB3f2F4HGkTT6nyMjbgtMq4,7555
|
|
210
|
+
unique_toolkit/short_term_memory/schemas.py,sha256=rS8Vvly-FZMiFTn_eGcSQJq_CP5AV-MDNDEmHSReCeI,1637
|
|
210
211
|
unique_toolkit/short_term_memory/service.py,sha256=5PeVBu1ZCAfyDb2HLVvlmqSbyzBBuE9sI2o9Aajqjxg,8884
|
|
211
212
|
unique_toolkit/smart_rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
212
213
|
unique_toolkit/smart_rules/compile.py,sha256=Ozhh70qCn2yOzRWr9d8WmJeTo7AQurwd3tStgBMPFLA,1246
|
|
213
214
|
unique_toolkit/test_utilities/events.py,sha256=_mwV2bs5iLjxS1ynDCjaIq-gjjKhXYCK-iy3dRfvO3g,6410
|
|
214
|
-
unique_toolkit-1.
|
|
215
|
-
unique_toolkit-1.
|
|
216
|
-
unique_toolkit-1.
|
|
217
|
-
unique_toolkit-1.
|
|
215
|
+
unique_toolkit-1.39.0.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
|
|
216
|
+
unique_toolkit-1.39.0.dist-info/METADATA,sha256=DTmUY_QVEo70IW79vzgIZb436Ptf917vl8JtwCqm8r4,45869
|
|
217
|
+
unique_toolkit-1.39.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
218
|
+
unique_toolkit-1.39.0.dist-info/RECORD,,
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
from unique_toolkit.agentic.loop_runner.middleware.qwen_forced_tool_call.helpers import (
|
|
2
|
-
is_qwen_model,
|
|
3
|
-
)
|
|
4
|
-
from unique_toolkit.agentic.loop_runner.middleware.qwen_forced_tool_call.qwen_forced_tool_call import (
|
|
5
|
-
QWEN_FORCED_TOOL_CALL_PROMPT_INSTRUCTION,
|
|
6
|
-
QwenForcedToolCallMiddleware,
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
__all__ = [
|
|
10
|
-
"QwenForcedToolCallMiddleware",
|
|
11
|
-
"QWEN_FORCED_TOOL_CALL_PROMPT_INSTRUCTION",
|
|
12
|
-
"is_qwen_model",
|
|
13
|
-
]
|
unique_toolkit/agentic/loop_runner/middleware/qwen_forced_tool_call/qwen_forced_tool_call.py
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
from typing import Unpack
|
|
3
|
-
|
|
4
|
-
from unique_toolkit.agentic.loop_runner.base import (
|
|
5
|
-
LoopIterationRunner,
|
|
6
|
-
_LoopIterationRunnerKwargs,
|
|
7
|
-
)
|
|
8
|
-
from unique_toolkit.agentic.loop_runner.middleware.qwen_forced_tool_call.helpers import (
|
|
9
|
-
append_qwen_forced_tool_call_instruction,
|
|
10
|
-
)
|
|
11
|
-
from unique_toolkit.chat.service import LanguageModelStreamResponse
|
|
12
|
-
|
|
13
|
-
_LOGGER = logging.getLogger(__name__)
|
|
14
|
-
|
|
15
|
-
QWEN_FORCED_TOOL_CALL_PROMPT_INSTRUCTION = (
|
|
16
|
-
"Tool Call Instruction: \nYou always have to return a tool call. "
|
|
17
|
-
"You must start the response with <tool_call> and end with </tool_call>. "
|
|
18
|
-
"Do NOT provide natural language explanations, summaries, or any text outside the <tool_call> block."
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class QwenForcedToolCallMiddleware(LoopIterationRunner):
|
|
23
|
-
def __init__(
|
|
24
|
-
self,
|
|
25
|
-
*,
|
|
26
|
-
loop_runner: LoopIterationRunner,
|
|
27
|
-
qwen_forced_tool_call_prompt_instruction: str,
|
|
28
|
-
) -> None:
|
|
29
|
-
self._qwen_forced_tool_call_prompt_instruction = (
|
|
30
|
-
qwen_forced_tool_call_prompt_instruction
|
|
31
|
-
)
|
|
32
|
-
self._loop_runner = loop_runner
|
|
33
|
-
|
|
34
|
-
async def __call__(
|
|
35
|
-
self, **kwargs: Unpack[_LoopIterationRunnerKwargs]
|
|
36
|
-
) -> LanguageModelStreamResponse:
|
|
37
|
-
tool_choices = kwargs.get("tool_choices") or []
|
|
38
|
-
iteration_index = kwargs["iteration_index"]
|
|
39
|
-
|
|
40
|
-
# For Qwen models, append tool call instruction to the last user message. These models ignore the parameter tool_choice.
|
|
41
|
-
if len(tool_choices) > 0 and iteration_index == 0 and kwargs.get("messages"):
|
|
42
|
-
_LOGGER.info(
|
|
43
|
-
"Appending tool call instruction to the last user message for Qwen models to force tool calls."
|
|
44
|
-
)
|
|
45
|
-
kwargs["messages"] = append_qwen_forced_tool_call_instruction(
|
|
46
|
-
messages=kwargs["messages"],
|
|
47
|
-
forced_tool_call_instruction=self._qwen_forced_tool_call_prompt_instruction,
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
return await self._loop_runner(**kwargs)
|
|
File without changes
|
|
File without changes
|