unique_toolkit 1.3.1__py3-none-any.whl → 1.3.2__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/app/dev_util.py +4 -1
- unique_toolkit/app/unique_settings.py +42 -8
- {unique_toolkit-1.3.1.dist-info → unique_toolkit-1.3.2.dist-info}/METADATA +3 -1
- {unique_toolkit-1.3.1.dist-info → unique_toolkit-1.3.2.dist-info}/RECORD +6 -6
- {unique_toolkit-1.3.1.dist-info → unique_toolkit-1.3.2.dist-info}/LICENSE +0 -0
- {unique_toolkit-1.3.1.dist-info → unique_toolkit-1.3.2.dist-info}/WHEEL +0 -0
unique_toolkit/app/dev_util.py
CHANGED
@@ -46,7 +46,8 @@ def get_event_generator(
|
|
46
46
|
event_type: type[T],
|
47
47
|
) -> Generator[T, None, None]:
|
48
48
|
"""
|
49
|
-
Generator that
|
49
|
+
Generator that updates the unique settings according to the events and
|
50
|
+
yields only events of the specified type from an SSE stream.
|
50
51
|
|
51
52
|
Args:
|
52
53
|
sse_client: The SSE client to read events from
|
@@ -74,6 +75,8 @@ def get_event_generator(
|
|
74
75
|
):
|
75
76
|
continue
|
76
77
|
|
78
|
+
unique_settings.update_from_event(event=parsed_event)
|
79
|
+
|
77
80
|
yield parsed_event
|
78
81
|
|
79
82
|
except Exception as e:
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import os
|
2
2
|
from logging import getLogger
|
3
3
|
from pathlib import Path
|
4
|
-
from typing import Self, TypeVar
|
4
|
+
from typing import TYPE_CHECKING, Self, TypeVar
|
5
5
|
from urllib.parse import ParseResult, urlparse, urlunparse
|
6
6
|
|
7
7
|
import unique_sdk
|
@@ -9,6 +9,10 @@ from platformdirs import user_config_dir
|
|
9
9
|
from pydantic import AliasChoices, Field, SecretStr, model_validator
|
10
10
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
11
11
|
|
12
|
+
if TYPE_CHECKING:
|
13
|
+
from unique_toolkit.app.schemas import BaseEvent
|
14
|
+
|
15
|
+
|
12
16
|
logger = getLogger(__name__)
|
13
17
|
|
14
18
|
T = TypeVar("T", bound=BaseSettings)
|
@@ -159,6 +163,13 @@ class UniqueAuth(BaseSettings):
|
|
159
163
|
def _warn_about_defaults(self) -> Self:
|
160
164
|
return warn_about_defaults(self)
|
161
165
|
|
166
|
+
@classmethod
|
167
|
+
def from_event(cls, event: "BaseEvent") -> Self:
|
168
|
+
return cls(
|
169
|
+
company_id=SecretStr(event.company_id),
|
170
|
+
user_id=SecretStr(event.user_id),
|
171
|
+
)
|
172
|
+
|
162
173
|
|
163
174
|
class UniqueChatEventFilterOptions(BaseSettings):
|
164
175
|
# Empty string evals to False
|
@@ -197,10 +208,10 @@ class UniqueSettings:
|
|
197
208
|
chat_event_filter_options: UniqueChatEventFilterOptions | None = None,
|
198
209
|
env_file: Path | None = None,
|
199
210
|
):
|
200
|
-
self.
|
201
|
-
self.
|
202
|
-
self.
|
203
|
-
self.
|
211
|
+
self._app = app
|
212
|
+
self._auth = auth
|
213
|
+
self._api = api
|
214
|
+
self._chat_event_filter_options = chat_event_filter_options
|
204
215
|
self._env_file: Path | None = (
|
205
216
|
env_file if (env_file and env_file.exists()) else None
|
206
217
|
)
|
@@ -310,9 +321,9 @@ class UniqueSettings:
|
|
310
321
|
This method configures the global unique_sdk module with the API key,
|
311
322
|
app ID, and base URL from these settings.
|
312
323
|
"""
|
313
|
-
unique_sdk.api_key = self.
|
314
|
-
unique_sdk.app_id = self.
|
315
|
-
unique_sdk.api_base = self.
|
324
|
+
unique_sdk.api_key = self._app.key.get_secret_value()
|
325
|
+
unique_sdk.app_id = self._app.id.get_secret_value()
|
326
|
+
unique_sdk.api_base = self._api.sdk_url()
|
316
327
|
|
317
328
|
@classmethod
|
318
329
|
def from_env_auto_with_sdk_init(
|
@@ -331,3 +342,26 @@ class UniqueSettings:
|
|
331
342
|
settings = cls.from_env_auto(filename)
|
332
343
|
settings.init_sdk()
|
333
344
|
return settings
|
345
|
+
|
346
|
+
def update_from_event(self, event: "BaseEvent") -> None:
|
347
|
+
self._auth = UniqueAuth.from_event(event)
|
348
|
+
|
349
|
+
@property
|
350
|
+
def api(self) -> UniqueApi:
|
351
|
+
return self._api
|
352
|
+
|
353
|
+
@property
|
354
|
+
def app(self) -> UniqueApp:
|
355
|
+
return self._app
|
356
|
+
|
357
|
+
@property
|
358
|
+
def auth(self) -> UniqueAuth:
|
359
|
+
return self._auth
|
360
|
+
|
361
|
+
@auth.setter
|
362
|
+
def auth(self, value: UniqueAuth) -> None:
|
363
|
+
self._auth = value
|
364
|
+
|
365
|
+
@property
|
366
|
+
def chat_event_filter_options(self) -> UniqueChatEventFilterOptions | None:
|
367
|
+
return self._chat_event_filter_options
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: unique_toolkit
|
3
|
-
Version: 1.3.
|
3
|
+
Version: 1.3.2
|
4
4
|
Summary:
|
5
5
|
License: Proprietary
|
6
6
|
Author: Cedric Klinkert
|
@@ -118,6 +118,8 @@ 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.3.2] - 2025-09-29
|
122
|
+
- Auto-update unique settings on event arrival in SSE client
|
121
123
|
|
122
124
|
## [1.3.1] - 2025-09-29
|
123
125
|
- More documentation on referencing
|
@@ -81,13 +81,13 @@ unique_toolkit/agentic/tools/utils/source_handling/schema.py,sha256=l4B6kA6grbL-
|
|
81
81
|
unique_toolkit/agentic/tools/utils/source_handling/source_formatting.py,sha256=uZ0QXqrPWgId3ZA67dvjHQ6xrW491LK1xxx_sVJmFHg,9160
|
82
82
|
unique_toolkit/agentic/tools/utils/source_handling/tests/test_source_formatting.py,sha256=EA8iVvb3L91OFk2XMbGcFuhe2etqm3Sx9QCYDGiOSOM,6995
|
83
83
|
unique_toolkit/app/__init__.py,sha256=ETxYDpEizg_PKmi4JPX_P76ySq-us-xypfAIdKQ1QZU,1284
|
84
|
-
unique_toolkit/app/dev_util.py,sha256=
|
84
|
+
unique_toolkit/app/dev_util.py,sha256=5tkGEcjHZ1u4kY0yUOhTWLjhXLvAcEMutY3h8j1bBJE,5312
|
85
85
|
unique_toolkit/app/init_logging.py,sha256=Sh26SRxOj8i8dzobKhYha2lLrkrMTHfB1V4jR3h23gQ,678
|
86
86
|
unique_toolkit/app/init_sdk.py,sha256=5_oDoETr6akwYyBCb0ivTdMNu3SVgPSkrXcDS6ELyY8,2269
|
87
87
|
unique_toolkit/app/performance/async_tasks.py,sha256=H0l3OAcosLwNHZ8d2pd-Di4wHIXfclEvagi5kfqLFPA,1941
|
88
88
|
unique_toolkit/app/performance/async_wrapper.py,sha256=yVVcRDkcdyfjsxro-N29SBvi-7773wnfDplef6-y8xw,1077
|
89
89
|
unique_toolkit/app/schemas.py,sha256=UE1UaL_N2o48O-mLb_rF3Sp9MrVkfdDE6f_dm7WTOO4,9137
|
90
|
-
unique_toolkit/app/unique_settings.py,sha256=
|
90
|
+
unique_toolkit/app/unique_settings.py,sha256=849pbASOu8QbHu9QfCJhYTisjKRet34J-fRs0gNKZ0Q,12369
|
91
91
|
unique_toolkit/app/verification.py,sha256=GxFFwcJMy25fCA_Xe89wKW7bgqOu8PAs5y8QpHF0GSc,3861
|
92
92
|
unique_toolkit/chat/__init__.py,sha256=LRs2G-JTVuci4lbtHTkVUiNcZcSR6uqqfnAyo7af6nY,619
|
93
93
|
unique_toolkit/chat/constants.py,sha256=05kq6zjqUVB2d6_P7s-90nbljpB3ryxwCI-CAz0r2O4,83
|
@@ -133,7 +133,7 @@ unique_toolkit/short_term_memory/schemas.py,sha256=OhfcXyF6ACdwIXW45sKzjtZX_gkcJ
|
|
133
133
|
unique_toolkit/short_term_memory/service.py,sha256=5PeVBu1ZCAfyDb2HLVvlmqSbyzBBuE9sI2o9Aajqjxg,8884
|
134
134
|
unique_toolkit/smart_rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
135
135
|
unique_toolkit/smart_rules/compile.py,sha256=cxWjb2dxEI2HGsakKdVCkSNi7VK9mr08w5sDcFCQyWI,9553
|
136
|
-
unique_toolkit-1.3.
|
137
|
-
unique_toolkit-1.3.
|
138
|
-
unique_toolkit-1.3.
|
139
|
-
unique_toolkit-1.3.
|
136
|
+
unique_toolkit-1.3.2.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
|
137
|
+
unique_toolkit-1.3.2.dist-info/METADATA,sha256=64vZcZcbk6v47satQNAuj1iuDrkR15OyO2GjqoOOX6s,33695
|
138
|
+
unique_toolkit-1.3.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
139
|
+
unique_toolkit-1.3.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|