unique_toolkit 1.5.0__py3-none-any.whl → 1.6.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.
@@ -31,3 +31,7 @@ class CommonException(Exception):
31
31
 
32
32
  def __str__(self):
33
33
  return self._error_message
34
+
35
+
36
+ class ConfigurationException(Exception):
37
+ pass
@@ -228,7 +228,7 @@ class HistoryManager:
228
228
  Returns:
229
229
  LanguageModelMessages: The user visible chat history.
230
230
  """
231
- history = await self._token_reducer._get_history_from_db()
231
+ history = await self._token_reducer.get_history_from_db()
232
232
  if assistant_message_text:
233
233
  history.append(
234
234
  LanguageModelAssistantMessage(content=assistant_message_text)
@@ -113,21 +113,6 @@ 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
-
131
116
  def _exceeds_token_limit(self, token_count: int) -> bool:
132
117
  """Check if token count exceeds the maximum allowed limit and if at least one tool call has more than one source."""
133
118
  # At least one tool call should have more than one chunk as answer
@@ -165,7 +150,7 @@ class LoopTokenReducer:
165
150
  rendered_system_message_string: str,
166
151
  remove_from_text: Callable[[str], Awaitable[str]],
167
152
  ) -> list[LanguageModelMessage]:
168
- history_from_db = await self._get_history_from_db(remove_from_text)
153
+ history_from_db = await self.get_history_from_db(remove_from_text)
169
154
  history_from_db = self._replace_user_message(
170
155
  history_from_db, original_user_message, rendered_user_message_string
171
156
  )
@@ -237,7 +222,7 @@ class LoopTokenReducer:
237
222
  ]
238
223
  return history
239
224
 
240
- async def _get_history_from_db(
225
+ async def get_history_from_db(
241
226
  self, remove_from_text: Callable[[str], Awaitable[str]] | None = None
242
227
  ) -> list[LanguageModelMessage]:
243
228
  """
@@ -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
@@ -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.5.0
3
+ Version: 1.6.0
4
4
  Summary:
5
5
  License: Proprietary
6
6
  Author: Cedric Klinkert
@@ -118,6 +118,12 @@ 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
+ ## [1.6.0] - 2025-10-01
122
+ - revert and simplify 1.5.0
123
+
124
+ ## [1.5.1] - 2025-10-01
125
+ - Fix filtering logic to raise a ConfigurationException if chat event filters are not specified
126
+
121
127
  ## [1.5.0] - 2025-10-01
122
128
  - Allow history manager to fetch only ui visible text
123
129
 
@@ -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=caQIE1btsQnpKCHqL2cgWUSbHup06enQu_Pt7uGUTTE,727
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=klUtDtcddUI7pdZIhIedl7YIOaZJBRp0N5O_Yh-nrqk,9217
46
- unique_toolkit/agentic/history_manager/loop_token_reducer.py,sha256=RH97HV2EiShsnw1C5USqAZ3vQxcoRjzxDZf_CibQ7GU,19109
45
+ unique_toolkit/agentic/history_manager/history_manager.py,sha256=_pTo30ktqoAFZZqaqeqU5_lCxk2oRD6qMFNtu6MFhTE,9216
46
+ unique_toolkit/agentic/history_manager/loop_token_reducer.py,sha256=3QSDXZ9M12-cDhYr7-UgDYGEMySkXENt1OkfD0CruQ8,18538
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=5tkGEcjHZ1u4kY0yUOhTWLjhXLvAcEMutY3h8j1bBJE,5312
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=UE1UaL_N2o48O-mLb_rF3Sp9MrVkfdDE6f_dm7WTOO4,9137
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.5.0.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
142
- unique_toolkit-1.5.0.dist-info/METADATA,sha256=521VJV6pIIEKtepXsgoCfdRj8QLH62E6tHz4js9cjVA,34392
143
- unique_toolkit-1.5.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
144
- unique_toolkit-1.5.0.dist-info/RECORD,,
141
+ unique_toolkit-1.6.0.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
142
+ unique_toolkit-1.6.0.dist-info/METADATA,sha256=35ET4vLnor1H1jw5K4u19CDHiTtihtW4nCBfcyg7dLA,34567
143
+ unique_toolkit-1.6.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
144
+ unique_toolkit-1.6.0.dist-info/RECORD,,