unique_toolkit 0.6.9__py3-none-any.whl → 0.7.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/content/functions.py +0 -4
- unique_toolkit/content/service.py +39 -26
- unique_toolkit/short_term_memory/service.py +2 -0
- {unique_toolkit-0.6.9.dist-info → unique_toolkit-0.7.1.dist-info}/METADATA +8 -1
- {unique_toolkit-0.6.9.dist-info → unique_toolkit-0.7.1.dist-info}/RECORD +7 -7
- {unique_toolkit-0.6.9.dist-info → unique_toolkit-0.7.1.dist-info}/LICENSE +0 -0
- {unique_toolkit-0.6.9.dist-info → unique_toolkit-0.7.1.dist-info}/WHEEL +0 -0
@@ -130,7 +130,6 @@ async def search_content_chunks_async(
|
|
130
130
|
def search_contents(
|
131
131
|
user_id: str,
|
132
132
|
company_id: str,
|
133
|
-
chat_id: str,
|
134
133
|
where: dict,
|
135
134
|
):
|
136
135
|
"""
|
@@ -152,7 +151,6 @@ def search_contents(
|
|
152
151
|
contents = unique_sdk.Content.search(
|
153
152
|
user_id=user_id,
|
154
153
|
company_id=company_id,
|
155
|
-
chatId=chat_id,
|
156
154
|
# TODO add type parameter in SDK
|
157
155
|
where=where, # type: ignore
|
158
156
|
)
|
@@ -165,7 +163,6 @@ def search_contents(
|
|
165
163
|
async def search_contents_async(
|
166
164
|
user_id: str,
|
167
165
|
company_id: str,
|
168
|
-
chat_id: str,
|
169
166
|
where: dict,
|
170
167
|
):
|
171
168
|
"""Asynchronously searches for content in the knowledge base."""
|
@@ -176,7 +173,6 @@ async def search_contents_async(
|
|
176
173
|
contents = await unique_sdk.Content.search_async(
|
177
174
|
user_id=user_id,
|
178
175
|
company_id=company_id,
|
179
|
-
chatId=chat_id,
|
180
176
|
where=where, # type: ignore
|
181
177
|
)
|
182
178
|
return map_contents(contents)
|
@@ -35,10 +35,10 @@ class ContentService:
|
|
35
35
|
Provides methods for searching, downloading and uploading content in the knowledge base.
|
36
36
|
|
37
37
|
Attributes:
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
event: BaseEvent | Event, this can be None ONLY if company_id and user_id are provided.
|
39
|
+
company_id (str): The company ID.
|
40
|
+
user_id (str): The user ID.
|
41
|
+
metadata_filter (dict | None): is only initialised from an Event(Deprecated) or ChatEvent.
|
42
42
|
"""
|
43
43
|
|
44
44
|
def __init__(
|
@@ -48,17 +48,16 @@ class ContentService:
|
|
48
48
|
user_id: str | None = None,
|
49
49
|
):
|
50
50
|
self._event = event # Changed to protected attribute
|
51
|
+
self.metadata_filter = None
|
51
52
|
if event:
|
52
53
|
self.company_id = event.company_id
|
53
54
|
self.user_id = event.user_id
|
54
55
|
if isinstance(event, (ChatEvent, Event)):
|
55
56
|
self.metadata_filter = event.payload.metadata_filter
|
56
|
-
self.chat_id = event.payload.chat_id
|
57
57
|
else:
|
58
58
|
[company_id, user_id] = validate_required_values([company_id, user_id])
|
59
59
|
self.company_id = company_id
|
60
60
|
self.user_id = user_id
|
61
|
-
self.metadata_filter = None
|
62
61
|
|
63
62
|
@property
|
64
63
|
@deprecated(
|
@@ -79,6 +78,7 @@ class ContentService:
|
|
79
78
|
search_type: ContentSearchType,
|
80
79
|
limit: int,
|
81
80
|
search_language: str = DEFAULT_SEARCH_LANGUAGE,
|
81
|
+
chat_id: str = "",
|
82
82
|
reranker_config: ContentRerankerConfig | None = None,
|
83
83
|
scope_ids: list[str] | None = None,
|
84
84
|
chat_only: bool | None = None,
|
@@ -92,24 +92,32 @@ class ContentService:
|
|
92
92
|
search_string (str): The search string.
|
93
93
|
search_type (ContentSearchType): The type of search to perform.
|
94
94
|
limit (int): The maximum number of results to return.
|
95
|
-
search_language (str): The language for the full-text search. Defaults to "english".
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
95
|
+
search_language (str, optional): The language for the full-text search. Defaults to "english".
|
96
|
+
chat_id (str, optional): The chat ID for context. Defaults to empty string.
|
97
|
+
reranker_config (ContentRerankerConfig | None, optional): The reranker configuration. Defaults to None.
|
98
|
+
scope_ids (list[str] | None, optional): The scope IDs to filter by. Defaults to None.
|
99
|
+
chat_only (bool | None, optional): Whether to search only in the current chat. Defaults to None.
|
100
|
+
metadata_filter (dict | None, optional): UniqueQL metadata filter. If unspecified/None, it tries to use the metadata filter from the event. Defaults to None.
|
101
|
+
content_ids (list[str] | None, optional): The content IDs to search within. Defaults to None.
|
102
|
+
|
101
103
|
Returns:
|
102
104
|
list[ContentChunk]: The search results.
|
105
|
+
|
106
|
+
Raises:
|
107
|
+
Exception: If there's an error during the search operation.
|
103
108
|
"""
|
104
109
|
|
105
110
|
if metadata_filter is None:
|
106
111
|
metadata_filter = self.metadata_filter
|
107
112
|
|
113
|
+
if chat_only and not chat_id:
|
114
|
+
raise ValueError("Please provide chat_id when limiting with chat_only")
|
115
|
+
|
108
116
|
try:
|
109
117
|
searches = search_content_chunks(
|
110
118
|
user_id=self.user_id,
|
111
119
|
company_id=self.company_id,
|
112
|
-
chat_id=
|
120
|
+
chat_id=chat_id,
|
113
121
|
search_string=search_string,
|
114
122
|
search_type=search_type,
|
115
123
|
limit=limit,
|
@@ -131,6 +139,7 @@ class ContentService:
|
|
131
139
|
search_type: ContentSearchType,
|
132
140
|
limit: int,
|
133
141
|
search_language: str = DEFAULT_SEARCH_LANGUAGE,
|
142
|
+
chat_id: str = "",
|
134
143
|
reranker_config: ContentRerankerConfig | None = None,
|
135
144
|
scope_ids: list[str] | None = None,
|
136
145
|
chat_only: bool | None = None,
|
@@ -144,23 +153,31 @@ class ContentService:
|
|
144
153
|
search_string (str): The search string.
|
145
154
|
search_type (ContentSearchType): The type of search to perform.
|
146
155
|
limit (int): The maximum number of results to return.
|
147
|
-
search_language (str): The language for the full-text search. Defaults to "english".
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
156
|
+
search_language (str, optional): The language for the full-text search. Defaults to "english".
|
157
|
+
chat_id (str, optional): The chat ID for context. Defaults to empty string.
|
158
|
+
reranker_config (ContentRerankerConfig | None, optional): The reranker configuration. Defaults to None.
|
159
|
+
scope_ids (list[str] | None, optional): The scope IDs to filter by. Defaults to None.
|
160
|
+
chat_only (bool | None, optional): Whether to search only in the current chat. Defaults to None.
|
161
|
+
metadata_filter (dict | None, optional): UniqueQL metadata filter. If unspecified/None, it tries to use the metadata filter from the event. Defaults to None.
|
162
|
+
content_ids (list[str] | None, optional): The content IDs to search within. Defaults to None.
|
163
|
+
|
153
164
|
Returns:
|
154
165
|
list[ContentChunk]: The search results.
|
166
|
+
|
167
|
+
Raises:
|
168
|
+
Exception: If there's an error during the search operation.
|
155
169
|
"""
|
156
170
|
if metadata_filter is None:
|
157
171
|
metadata_filter = self.metadata_filter
|
158
172
|
|
173
|
+
if chat_only and not chat_id:
|
174
|
+
raise ValueError("Please provide chat_id when limiting with chat_only.")
|
175
|
+
|
159
176
|
try:
|
160
177
|
searches = await search_content_chunks_async(
|
161
178
|
user_id=self.user_id,
|
162
179
|
company_id=self.company_id,
|
163
|
-
chat_id=
|
180
|
+
chat_id=chat_id,
|
164
181
|
search_string=search_string,
|
165
182
|
search_type=search_type,
|
166
183
|
limit=limit,
|
@@ -193,7 +210,6 @@ class ContentService:
|
|
193
210
|
return search_contents(
|
194
211
|
user_id=self.user_id,
|
195
212
|
company_id=self.company_id,
|
196
|
-
chat_id=self.chat_id,
|
197
213
|
where=where,
|
198
214
|
)
|
199
215
|
|
@@ -213,14 +229,11 @@ class ContentService:
|
|
213
229
|
return await search_contents_async(
|
214
230
|
user_id=self.user_id,
|
215
231
|
company_id=self.company_id,
|
216
|
-
chat_id=self.chat_id,
|
217
232
|
where=where,
|
218
233
|
)
|
219
234
|
|
220
|
-
def search_content_on_chat(
|
221
|
-
|
222
|
-
) -> list[Content]:
|
223
|
-
where = {"ownerId": {"equals": self.chat_id}}
|
235
|
+
def search_content_on_chat(self, chat_id: str) -> list[Content]:
|
236
|
+
where = {"ownerId": {"equals": chat_id}}
|
224
237
|
|
225
238
|
return self.search_contents(where)
|
226
239
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: unique_toolkit
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.7.1
|
4
4
|
Summary:
|
5
5
|
License: Proprietary
|
6
6
|
Author: Martin Fadler
|
@@ -111,6 +111,13 @@ All notable changes to this project will be documented in this file.
|
|
111
111
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
112
112
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
113
113
|
|
114
|
+
## [0.7.1] - 2025-03-11
|
115
|
+
- Fix Breaking change: `ContentService.search_content_chunks` `ContentService.search_content_chunks` now accepts`chat_id` for the specific to handle chat_only instances
|
116
|
+
|
117
|
+
## [0.7.0] - 2025-03-11
|
118
|
+
- Fix the issue with `ShortTermMemoryService.create_memory_async` adding `self.chat_id` and `self.message_id` as part of the parameter.
|
119
|
+
- Breaking change: `ContentService.search_content_on_chat` now requires you pass in a `chat_id` for the specific chat instance
|
120
|
+
|
114
121
|
## [0.6.9] - 2025-03-11
|
115
122
|
- Add o1-preview as part of the language model info, make the name consistent across board.
|
116
123
|
|
@@ -20,9 +20,9 @@ unique_toolkit/chat/state.py,sha256=Cjgwv_2vhDFbV69xxsn7SefhaoIAEqLx3ferdVFCnOg,
|
|
20
20
|
unique_toolkit/chat/utils.py,sha256=ihm-wQykBWhB4liR3LnwPVPt_qGW6ETq21Mw4HY0THE,854
|
21
21
|
unique_toolkit/content/__init__.py,sha256=EdJg_A_7loEtCQf4cah3QARQreJx6pdz89Rm96YbMVg,940
|
22
22
|
unique_toolkit/content/constants.py,sha256=1iy4Y67xobl5VTnJB6SxSyuoBWbdLl9244xfVMUZi5o,60
|
23
|
-
unique_toolkit/content/functions.py,sha256=
|
23
|
+
unique_toolkit/content/functions.py,sha256=iuclQjuiupIJPk0-6ldl35EVkQ2h34_dxKxWisMrxWM,17001
|
24
24
|
unique_toolkit/content/schemas.py,sha256=zks_Pkki2VhxICJJgHZyc-LPmRuj5dLbw3pgcUT7SW8,2362
|
25
|
-
unique_toolkit/content/service.py,sha256=
|
25
|
+
unique_toolkit/content/service.py,sha256=jnXUtQ9ax8tS52lrUIOzMypYCJiRZ56XeIz87hIMur4,14988
|
26
26
|
unique_toolkit/content/utils.py,sha256=GUVPrkZfMoAj4MRoBs5BD_7vSuLZTZx69hyWzYFrI50,7747
|
27
27
|
unique_toolkit/embedding/__init__.py,sha256=uUyzjonPvuDCYsvXCIt7ErQXopLggpzX-MEQd3_e2kE,250
|
28
28
|
unique_toolkit/embedding/constants.py,sha256=Lj8-Lcy1FvuC31PM9Exq7vaFuxQV4pEI1huUMFX-J2M,52
|
@@ -57,8 +57,8 @@ unique_toolkit/short_term_memory/__init__.py,sha256=2mI3AUrffgH7Yt-xS57EGqnHf7jn
|
|
57
57
|
unique_toolkit/short_term_memory/constants.py,sha256=698CL6-wjup2MvU19RxSmQk3gX7aqW_OOpZB7sbz_Xg,34
|
58
58
|
unique_toolkit/short_term_memory/functions.py,sha256=3WiK-xatY5nh4Dr5zlDUye1k3E6kr41RiscwtTplw5k,4484
|
59
59
|
unique_toolkit/short_term_memory/schemas.py,sha256=OhfcXyF6ACdwIXW45sKzjtZX_gkcJs8FEZXcgQTNenw,1406
|
60
|
-
unique_toolkit/short_term_memory/service.py,sha256=
|
61
|
-
unique_toolkit-0.
|
62
|
-
unique_toolkit-0.
|
63
|
-
unique_toolkit-0.
|
64
|
-
unique_toolkit-0.
|
60
|
+
unique_toolkit/short_term_memory/service.py,sha256=0wrwuo6K17Edcuiwp5LMCvxFuBSDP82HF0_5qwi0nYc,5307
|
61
|
+
unique_toolkit-0.7.1.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
|
62
|
+
unique_toolkit-0.7.1.dist-info/METADATA,sha256=vEkFTjpS9QGRvfgIHvRt80Fxyi49Fh127CFKlmXjIqs,20756
|
63
|
+
unique_toolkit-0.7.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
64
|
+
unique_toolkit-0.7.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|