unique_toolkit 0.5.38__py3-none-any.whl → 0.5.39__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.
@@ -29,6 +29,7 @@ class ContentService(BaseService):
29
29
 
30
30
  def __init__(self, event: Event, logger: Optional[logging.Logger] = None):
31
31
  super().__init__(event, logger)
32
+ self.metadata_filter = event.payload.metadata_filter
32
33
 
33
34
  DEFAULT_SEARCH_LANGUAGE = "english"
34
35
 
@@ -42,6 +43,7 @@ class ContentService(BaseService):
42
43
  scope_ids: Optional[list[str]] = None,
43
44
  chat_only: Optional[bool] = None,
44
45
  metadata_filter: Optional[dict] = None,
46
+ content_ids: Optional[list[str]] = None,
45
47
  ) -> list[ContentChunk]:
46
48
  """
47
49
  Performs a synchronous search for content chunks in the knowledge base.
@@ -54,14 +56,17 @@ class ContentService(BaseService):
54
56
  reranker_config (Optional[ContentRerankerConfig]): The reranker configuration. Defaults to None.
55
57
  scope_ids (Optional[list[str]]): The scope IDs. Defaults to None.
56
58
  chat_only (Optional[bool]): Whether to search only in the current chat. Defaults to None.
57
- metadata_filter (Optional[dict]): UniqueQL metadata filter. Defaults to None.
58
-
59
+ metadata_filter (Optional[dict]): UniqueQL metadata filter. If unspecified/None, it tries to use the metadata filter from the event. Defaults to None.
60
+ content_ids (Optional[list[str]]): The content IDs to search. Defaults to None.
59
61
  Returns:
60
62
  list[ContentChunk]: The search results.
61
63
  """
62
64
  if not scope_ids:
63
65
  self.logger.warning("No scope IDs provided for search.")
64
66
 
67
+ if metadata_filter is None:
68
+ metadata_filter = self.metadata_filter
69
+
65
70
  try:
66
71
  searches = unique_sdk.Search.create(
67
72
  user_id=self.event.user_id,
@@ -79,6 +84,7 @@ class ContentService(BaseService):
79
84
  language=search_language,
80
85
  chatOnly=chat_only,
81
86
  metaDataFilter=metadata_filter,
87
+ contentIds=content_ids,
82
88
  )
83
89
  except Exception as e:
84
90
  self.logger.error(f"Error while searching content chunks: {e}")
@@ -101,6 +107,7 @@ class ContentService(BaseService):
101
107
  scope_ids: Optional[list[str]] = None,
102
108
  chat_only: Optional[bool] = None,
103
109
  metadata_filter: Optional[dict] = None,
110
+ content_ids: Optional[list[str]] = None,
104
111
  ):
105
112
  """
106
113
  Performs an asynchronous search for content chunks in the knowledge base.
@@ -113,14 +120,17 @@ class ContentService(BaseService):
113
120
  reranker_config (Optional[ContentRerankerConfig]): The reranker configuration. Defaults to None.
114
121
  scope_ids (Optional[list[str]]): The scope IDs. Defaults to None.
115
122
  chat_only (Optional[bool]): Whether to search only in the current chat. Defaults to None.
116
- metadata_filter (Optional[dict]): UniqueQL metadata filter. Defaults to None.
117
-
123
+ metadata_filter (Optional[dict]): UniqueQL metadata filter. If unspecified/None, it tries to use the metadata filter from the event. Defaults to None.
124
+ content_ids (Optional[list[str]]): The content IDs to search. Defaults to None.
118
125
  Returns:
119
126
  list[ContentChunk]: The search results.
120
127
  """
121
128
  if not scope_ids:
122
129
  self.logger.warning("No scope IDs provided for search.")
123
130
 
131
+ if metadata_filter is None:
132
+ metadata_filter = self.metadata_filter
133
+
124
134
  try:
125
135
  searches = await unique_sdk.Search.create_async(
126
136
  user_id=self.event.user_id,
@@ -138,6 +148,7 @@ class ContentService(BaseService):
138
148
  language=search_language,
139
149
  chatOnly=chat_only,
140
150
  metaDataFilter=metadata_filter,
151
+ contentIds=content_ids,
141
152
  )
142
153
  except Exception as e:
143
154
  self.logger.error(f"Error while searching content chunks: {e}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unique_toolkit
3
- Version: 0.5.38
3
+ Version: 0.5.39
4
4
  Summary:
5
5
  License: Proprietary
6
6
  Author: Martin Fadler
@@ -17,7 +17,7 @@ Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
17
17
  Requires-Dist: regex (>=2024.5.15,<2025.0.0)
18
18
  Requires-Dist: tiktoken (>=0.7.0,<0.8.0)
19
19
  Requires-Dist: typing-extensions (>=4.9.0,<5.0.0)
20
- Requires-Dist: unique-sdk (>=0.9.8,<0.10.0)
20
+ Requires-Dist: unique-sdk (>=0.9.14,<0.10.0)
21
21
  Description-Content-Type: text/markdown
22
22
 
23
23
  # Unique Toolkit
@@ -100,6 +100,12 @@ All notable changes to this project will be documented in this file.
100
100
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
101
101
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
102
102
 
103
+
104
+
105
+ ## [0.5.39] - 2024-12-09
106
+ - Add `contentIds` to `Search.create` and `Search.create_async`
107
+ - Use `metadata_filter` from event in `ContentService.search_content_chunks` and `ContentService.async_search_content_chunks` as default.
108
+
103
109
  ## [0.5.38] - 2024-11-26
104
110
  - Added string representation to `LanguageModelMessage` and `LanguageModelMessages` class
105
111
 
@@ -17,7 +17,7 @@ unique_toolkit/chat/state.py,sha256=Cjgwv_2vhDFbV69xxsn7SefhaoIAEqLx3ferdVFCnOg,
17
17
  unique_toolkit/chat/utils.py,sha256=ihm-wQykBWhB4liR3LnwPVPt_qGW6ETq21Mw4HY0THE,854
18
18
  unique_toolkit/content/__init__.py,sha256=MSH2sxjQyKD2Sef92fzE5Dt9SihdzivB6yliSwJfTmQ,890
19
19
  unique_toolkit/content/schemas.py,sha256=zks_Pkki2VhxICJJgHZyc-LPmRuj5dLbw3pgcUT7SW8,2362
20
- unique_toolkit/content/service.py,sha256=e23GX2pzIppHCFPUHng-82pSELT8JKT4TRMCO6M2Lok,16968
20
+ unique_toolkit/content/service.py,sha256=rznSUyOuB4nbo6bFworzFv86kzo6TVT4Nc8GMAeAJB4,17711
21
21
  unique_toolkit/content/utils.py,sha256=Lake671plRsqNvO3pN_rmyVcpwbdED_KQpLcCnc4lv4,6902
22
22
  unique_toolkit/embedding/__init__.py,sha256=dr8M9jvslQTxPpxgaGwzxY0FildiWf-DidN_cahPAWw,191
23
23
  unique_toolkit/embedding/schemas.py,sha256=1GvKCaSk4jixzVQ2PKq8yDqwGEVY_hWclYtoAr6CC2g,96
@@ -40,7 +40,7 @@ unique_toolkit/language_model/infos.py,sha256=kQK6F3r8xTN7oT6b39J7rxW-Y4iPXjx_Fr
40
40
  unique_toolkit/language_model/schemas.py,sha256=wg_ly66UvLOVNdrq8xr-0uN0HPY41UIk5mVPxdG-VGs,6687
41
41
  unique_toolkit/language_model/service.py,sha256=s5X6EStyYumiYqlD9gkW4GANif18d9QZOMysmUSfv8M,13433
42
42
  unique_toolkit/language_model/utils.py,sha256=bPQ4l6_YO71w-zaIPanUUmtbXC1_hCvLK0tAFc3VCRc,1902
43
- unique_toolkit-0.5.38.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
44
- unique_toolkit-0.5.38.dist-info/METADATA,sha256=gjQLXWLmCmcvUCIEAF6k2_LKj8muzzR6r2m9BvOQxqQ,14180
45
- unique_toolkit-0.5.38.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
46
- unique_toolkit-0.5.38.dist-info/RECORD,,
43
+ unique_toolkit-0.5.39.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
44
+ unique_toolkit-0.5.39.dist-info/METADATA,sha256=30jmpa5iHACeXTpmNB0XyY6GSanJvFAi10S8K0qg4Ew,14411
45
+ unique_toolkit-0.5.39.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
46
+ unique_toolkit-0.5.39.dist-info/RECORD,,