unique_toolkit 1.4.4__py3-none-any.whl → 1.5.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.
- unique_toolkit/_common/exception.py +4 -0
- unique_toolkit/agentic/history_manager/history_manager.py +19 -0
- unique_toolkit/agentic/history_manager/loop_token_reducer.py +20 -5
- unique_toolkit/app/dev_util.py +4 -0
- unique_toolkit/app/schemas.py +16 -2
- {unique_toolkit-1.4.4.dist-info → unique_toolkit-1.5.1.dist-info}/METADATA +8 -1
- {unique_toolkit-1.4.4.dist-info → unique_toolkit-1.5.1.dist-info}/RECORD +9 -9
- {unique_toolkit-1.4.4.dist-info → unique_toolkit-1.5.1.dist-info}/LICENSE +0 -0
- {unique_toolkit-1.4.4.dist-info → unique_toolkit-1.5.1.dist-info}/WHEEL +0 -0
@@ -215,3 +215,22 @@ class HistoryManager:
|
|
215
215
|
remove_from_text=remove_from_text,
|
216
216
|
)
|
217
217
|
return messages
|
218
|
+
|
219
|
+
async def get_user_visible_chat_history(
|
220
|
+
self, assistant_message_text: str | None = None
|
221
|
+
) -> LanguageModelMessages:
|
222
|
+
"""Get the user visible chat history.
|
223
|
+
|
224
|
+
Args:
|
225
|
+
assistant_message_text (str | None): The latest assistant message to append to the history, as this is not extracted from the history.
|
226
|
+
If None, the history will be returned without the latest assistant message.
|
227
|
+
|
228
|
+
Returns:
|
229
|
+
LanguageModelMessages: The user visible chat history.
|
230
|
+
"""
|
231
|
+
history = await self._token_reducer._get_history_from_db()
|
232
|
+
if assistant_message_text:
|
233
|
+
history.append(
|
234
|
+
LanguageModelAssistantMessage(content=assistant_message_text)
|
235
|
+
)
|
236
|
+
return LanguageModelMessages(history)
|
@@ -113,6 +113,21 @@ class LoopTokenReducer:
|
|
113
113
|
|
114
114
|
return messages
|
115
115
|
|
116
|
+
async def get_user_visible_chat_history(
|
117
|
+
self, message: LanguageModelAssistantMessage
|
118
|
+
) -> LanguageModelMessages:
|
119
|
+
"""Get the user visible chat history.
|
120
|
+
|
121
|
+
Args:
|
122
|
+
message (LanguageModelAssistantMessage): The latest assistant message to append to the history, as this is not extracted from the history.
|
123
|
+
|
124
|
+
Returns:
|
125
|
+
LanguageModelMessages: The user visible chat history.
|
126
|
+
"""
|
127
|
+
history = await self._get_history_from_db()
|
128
|
+
history.append(message)
|
129
|
+
return LanguageModelMessages(history)
|
130
|
+
|
116
131
|
def _exceeds_token_limit(self, token_count: int) -> bool:
|
117
132
|
"""Check if token count exceeds the maximum allowed limit and if at least one tool call has more than one source."""
|
118
133
|
# At least one tool call should have more than one chunk as answer
|
@@ -223,7 +238,7 @@ class LoopTokenReducer:
|
|
223
238
|
return history
|
224
239
|
|
225
240
|
async def _get_history_from_db(
|
226
|
-
self, remove_from_text: Callable[[str], Awaitable[str]]
|
241
|
+
self, remove_from_text: Callable[[str], Awaitable[str]] | None = None
|
227
242
|
) -> list[LanguageModelMessage]:
|
228
243
|
"""
|
229
244
|
Get the history of the conversation. The function will retrieve a subset of the full history based on the configuration.
|
@@ -242,10 +257,10 @@ class LoopTokenReducer:
|
|
242
257
|
else FileContentSerialization.FILE_NAME
|
243
258
|
),
|
244
259
|
)
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
260
|
+
if remove_from_text is not None:
|
261
|
+
full_history.root = await self._clean_messages(
|
262
|
+
full_history.root, remove_from_text
|
263
|
+
)
|
249
264
|
|
250
265
|
limited_history_messages = self._limit_to_token_window(
|
251
266
|
full_history.root, self._max_history_tokens
|
unique_toolkit/app/dev_util.py
CHANGED
@@ -11,6 +11,7 @@ from typing import (
|
|
11
11
|
|
12
12
|
from sseclient import SSEClient
|
13
13
|
|
14
|
+
from unique_toolkit._common.exception import ConfigurationException
|
14
15
|
from unique_toolkit.app import BaseEvent, ChatEvent, EventName
|
15
16
|
from unique_toolkit.app.init_sdk import init_unique_sdk
|
16
17
|
from unique_toolkit.app.unique_settings import UniqueSettings
|
@@ -79,6 +80,9 @@ def get_event_generator(
|
|
79
80
|
|
80
81
|
yield parsed_event
|
81
82
|
|
83
|
+
except ConfigurationException as e:
|
84
|
+
# Re-raise ConfigurationException from filter_event (configuration errors)
|
85
|
+
raise e
|
82
86
|
except Exception as e:
|
83
87
|
LOGGER.error(f"Could not parse SSE event data as JSON: {e}")
|
84
88
|
continue
|
unique_toolkit/app/schemas.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import json
|
2
2
|
from enum import StrEnum
|
3
|
+
from logging import getLogger
|
3
4
|
from pathlib import Path
|
4
5
|
from typing import Any, Generic, Optional, TypeVar, override
|
5
6
|
|
@@ -8,6 +9,7 @@ from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
8
9
|
from pydantic_settings import BaseSettings
|
9
10
|
from typing_extensions import deprecated
|
10
11
|
|
12
|
+
from unique_toolkit._common.exception import ConfigurationException
|
11
13
|
from unique_toolkit.app.unique_settings import UniqueChatEventFilterOptions
|
12
14
|
from unique_toolkit.smart_rules.compile import UniqueQL, parse_uniqueql
|
13
15
|
|
@@ -19,6 +21,7 @@ model_config = ConfigDict(
|
|
19
21
|
populate_by_name=True,
|
20
22
|
arbitrary_types_allowed=True,
|
21
23
|
)
|
24
|
+
_logger = getLogger(__name__)
|
22
25
|
|
23
26
|
|
24
27
|
class EventName(StrEnum):
|
@@ -255,9 +258,20 @@ class ChatEvent(BaseEvent):
|
|
255
258
|
self, *, filter_options: UniqueChatEventFilterOptions | None = None
|
256
259
|
) -> bool:
|
257
260
|
# Empty string evals to False
|
258
|
-
if filter_options is None:
|
259
|
-
return False
|
260
261
|
|
262
|
+
if filter_options is None:
|
263
|
+
return False # Don't filter when no options provided
|
264
|
+
|
265
|
+
if not filter_options.assistant_ids and not filter_options.references_in_code:
|
266
|
+
raise ConfigurationException(
|
267
|
+
"No filter options provided, all events will be filtered! \n"
|
268
|
+
"Please define: \n"
|
269
|
+
" - 'UNIQUE_CHAT_EVENT_FILTER_OPTIONS_ASSISTANT_IDS' \n"
|
270
|
+
" - 'UNIQUE_CHAT_EVENT_FILTER_OPTIONS_REFERENCES_IN_CODE' \n"
|
271
|
+
"in your environment variables."
|
272
|
+
)
|
273
|
+
|
274
|
+
# Per reference in code there can be multiple assistants
|
261
275
|
if (
|
262
276
|
filter_options.assistant_ids
|
263
277
|
and self.payload.assistant_id not in filter_options.assistant_ids
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: unique_toolkit
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.5.1
|
4
4
|
Summary:
|
5
5
|
License: Proprietary
|
6
6
|
Author: Cedric Klinkert
|
@@ -118,6 +118,13 @@ All notable changes to this project will be documented in this file.
|
|
118
118
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
119
119
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
120
120
|
|
121
|
+
|
122
|
+
## [1.5.1] - 2025-10-01
|
123
|
+
- Fix filtering logic to raise a ConfigurationException if chat event filters are not specified
|
124
|
+
|
125
|
+
## [1.5.0] - 2025-10-01
|
126
|
+
- Allow history manager to fetch only ui visible text
|
127
|
+
|
121
128
|
## [1.4.4] - 2025-09-30
|
122
129
|
- Fix bugs with display of sub-agent answers and evaluations when multiple sub-agent from the same assistant run concurrently.
|
123
130
|
|
@@ -11,7 +11,7 @@ unique_toolkit/_common/chunk_relevancy_sorter/tests/test_service.py,sha256=UhDll
|
|
11
11
|
unique_toolkit/_common/default_language_model.py,sha256=tmHSqg6e8G7RmKqmdE_tmLxkSN0x-aGoyUdy6Pl2oAE,334
|
12
12
|
unique_toolkit/_common/endpoint_builder.py,sha256=WzJrJ7azUQhvQRd-vsFFoyj6omJpHiVYrh1UFxNQvVg,8242
|
13
13
|
unique_toolkit/_common/endpoint_requestor.py,sha256=JbbfJGLxgxLz8a3Yx1FdJvdHGbCYO8MSBd7cLg_Mtp0,5927
|
14
|
-
unique_toolkit/_common/exception.py,sha256=
|
14
|
+
unique_toolkit/_common/exception.py,sha256=hwh60UUawHDyPFNs-Wom-Gc6Yb09gPelftAuW1tXE6o,779
|
15
15
|
unique_toolkit/_common/feature_flags/schema.py,sha256=F1NdVJFNU8PKlS7bYzrIPeDu2LxRqHSM9pyw622a1Kk,547
|
16
16
|
unique_toolkit/_common/pydantic/rjsf_tags.py,sha256=T3AZIF8wny3fFov66s258nEl1GqfKevFouTtG6k9PqU,31219
|
17
17
|
unique_toolkit/_common/pydantic_helpers.py,sha256=1zzg6PlzSkHqPTdX-KoBaDHmBeeG7S5PprBsyMSCEuU,4806
|
@@ -42,8 +42,8 @@ unique_toolkit/agentic/evaluation/schemas.py,sha256=m9JMCUmeqP8KhsJOVEzsz6dRXUe1
|
|
42
42
|
unique_toolkit/agentic/evaluation/tests/test_context_relevancy_service.py,sha256=4tDxHTApbaTMxN1sNS8WCqj2BweRk6YqZ5_zHP45jto,7977
|
43
43
|
unique_toolkit/agentic/evaluation/tests/test_output_parser.py,sha256=RN_HcBbU6qy_e_PoYyUFcjWnp3ymJ6-gLj6TgEOupAI,3107
|
44
44
|
unique_toolkit/agentic/history_manager/history_construction_with_contents.py,sha256=c8Zy3erSbHGT8AdICRRlSK91T_FN6tNpTznvUzpLbWk,9023
|
45
|
-
unique_toolkit/agentic/history_manager/history_manager.py,sha256=
|
46
|
-
unique_toolkit/agentic/history_manager/loop_token_reducer.py,sha256=
|
45
|
+
unique_toolkit/agentic/history_manager/history_manager.py,sha256=klUtDtcddUI7pdZIhIedl7YIOaZJBRp0N5O_Yh-nrqk,9217
|
46
|
+
unique_toolkit/agentic/history_manager/loop_token_reducer.py,sha256=RH97HV2EiShsnw1C5USqAZ3vQxcoRjzxDZf_CibQ7GU,19109
|
47
47
|
unique_toolkit/agentic/history_manager/utils.py,sha256=NDSSz0Jp3oVJU3iKlVScmM1AOe-6hTiVjLr16DUPsV0,5656
|
48
48
|
unique_toolkit/agentic/postprocessor/postprocessor_manager.py,sha256=GDzJhaoOUwxZ37IINkQ7au4CHmAOFS5miP2lqv8ZwZA,4277
|
49
49
|
unique_toolkit/agentic/reference_manager/reference_manager.py,sha256=1GeoFX1-RLdTcns1358GJADDSAcTAM2J0jJJpln08qo,4005
|
@@ -86,12 +86,12 @@ unique_toolkit/agentic/tools/utils/source_handling/schema.py,sha256=l4B6kA6grbL-
|
|
86
86
|
unique_toolkit/agentic/tools/utils/source_handling/source_formatting.py,sha256=uZ0QXqrPWgId3ZA67dvjHQ6xrW491LK1xxx_sVJmFHg,9160
|
87
87
|
unique_toolkit/agentic/tools/utils/source_handling/tests/test_source_formatting.py,sha256=EA8iVvb3L91OFk2XMbGcFuhe2etqm3Sx9QCYDGiOSOM,6995
|
88
88
|
unique_toolkit/app/__init__.py,sha256=ETxYDpEizg_PKmi4JPX_P76ySq-us-xypfAIdKQ1QZU,1284
|
89
|
-
unique_toolkit/app/dev_util.py,sha256=
|
89
|
+
unique_toolkit/app/dev_util.py,sha256=J20peCvrSQKfMGdYPYwCirs3Yq2v_e33GzNBzNKbWN4,5531
|
90
90
|
unique_toolkit/app/init_logging.py,sha256=Sh26SRxOj8i8dzobKhYha2lLrkrMTHfB1V4jR3h23gQ,678
|
91
91
|
unique_toolkit/app/init_sdk.py,sha256=5_oDoETr6akwYyBCb0ivTdMNu3SVgPSkrXcDS6ELyY8,2269
|
92
92
|
unique_toolkit/app/performance/async_tasks.py,sha256=H0l3OAcosLwNHZ8d2pd-Di4wHIXfclEvagi5kfqLFPA,1941
|
93
93
|
unique_toolkit/app/performance/async_wrapper.py,sha256=yVVcRDkcdyfjsxro-N29SBvi-7773wnfDplef6-y8xw,1077
|
94
|
-
unique_toolkit/app/schemas.py,sha256=
|
94
|
+
unique_toolkit/app/schemas.py,sha256=wbfYGl5PjMBG25IEPzeygObBJIxP5CfXpBWS-4NWZJs,9830
|
95
95
|
unique_toolkit/app/unique_settings.py,sha256=849pbASOu8QbHu9QfCJhYTisjKRet34J-fRs0gNKZ0Q,12369
|
96
96
|
unique_toolkit/app/verification.py,sha256=GxFFwcJMy25fCA_Xe89wKW7bgqOu8PAs5y8QpHF0GSc,3861
|
97
97
|
unique_toolkit/chat/__init__.py,sha256=LRs2G-JTVuci4lbtHTkVUiNcZcSR6uqqfnAyo7af6nY,619
|
@@ -138,7 +138,7 @@ unique_toolkit/short_term_memory/schemas.py,sha256=OhfcXyF6ACdwIXW45sKzjtZX_gkcJ
|
|
138
138
|
unique_toolkit/short_term_memory/service.py,sha256=5PeVBu1ZCAfyDb2HLVvlmqSbyzBBuE9sI2o9Aajqjxg,8884
|
139
139
|
unique_toolkit/smart_rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
140
140
|
unique_toolkit/smart_rules/compile.py,sha256=cxWjb2dxEI2HGsakKdVCkSNi7VK9mr08w5sDcFCQyWI,9553
|
141
|
-
unique_toolkit-1.
|
142
|
-
unique_toolkit-1.
|
143
|
-
unique_toolkit-1.
|
144
|
-
unique_toolkit-1.
|
141
|
+
unique_toolkit-1.5.1.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
|
142
|
+
unique_toolkit-1.5.1.dist-info/METADATA,sha256=1jL7EK6jc2i-l7G1fRUBjmFTxsrp_I43P3d6Yx_zF0w,34514
|
143
|
+
unique_toolkit-1.5.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
144
|
+
unique_toolkit-1.5.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|