unique_toolkit 0.5.3__py3-none-any.whl → 0.5.5__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/chat/schemas.py +1 -1
- unique_toolkit/content/schemas.py +6 -0
- unique_toolkit/content/service.py +29 -12
- {unique_toolkit-0.5.3.dist-info → unique_toolkit-0.5.5.dist-info}/METADATA +10 -2
- {unique_toolkit-0.5.3.dist-info → unique_toolkit-0.5.5.dist-info}/RECORD +7 -7
- {unique_toolkit-0.5.3.dist-info → unique_toolkit-0.5.5.dist-info}/LICENSE +0 -0
- {unique_toolkit-0.5.3.dist-info → unique_toolkit-0.5.5.dist-info}/WHEEL +0 -0
unique_toolkit/chat/schemas.py
CHANGED
@@ -21,7 +21,7 @@ class ChatMessage(BaseModel):
|
|
21
21
|
object: str | None = None
|
22
22
|
content: str = Field(alias="text")
|
23
23
|
role: ChatMessageRole
|
24
|
-
debug_info: dict = {}
|
24
|
+
debug_info: dict | None = {}
|
25
25
|
|
26
26
|
# TODO make sdk return role consistently in lowercase
|
27
27
|
# Currently needed as sdk returns role in uppercase
|
@@ -88,3 +88,9 @@ class ContentUploadInput(BaseModel):
|
|
88
88
|
owner_type: Optional[str] = None
|
89
89
|
owner_id: Optional[str] = None
|
90
90
|
byte_size: Optional[int] = None
|
91
|
+
|
92
|
+
|
93
|
+
class RerankerConfig(BaseModel):
|
94
|
+
model_config = model_config
|
95
|
+
deployment_name: str
|
96
|
+
options: dict | None = None
|
@@ -14,10 +14,13 @@ from unique_toolkit.content.schemas import (
|
|
14
14
|
ContentChunk,
|
15
15
|
ContentSearchType,
|
16
16
|
ContentUploadInput,
|
17
|
+
RerankerConfig,
|
17
18
|
)
|
18
19
|
|
19
20
|
|
20
21
|
class ContentService:
|
22
|
+
DEFAULT_SEARCH_LANGUAGE = "english"
|
23
|
+
|
21
24
|
def __init__(self, state: ChatState, logger: Optional[logging.Logger] = None):
|
22
25
|
self.state = state
|
23
26
|
self.logger = logger or logging.getLogger(__name__)
|
@@ -27,6 +30,8 @@ class ContentService:
|
|
27
30
|
search_string: str,
|
28
31
|
search_type: ContentSearchType,
|
29
32
|
limit: int,
|
33
|
+
reranker_config: Optional[RerankerConfig] = None,
|
34
|
+
search_language: str = DEFAULT_SEARCH_LANGUAGE,
|
30
35
|
scope_ids: Optional[list[str]] = None,
|
31
36
|
) -> list[ContentChunk]:
|
32
37
|
"""
|
@@ -36,16 +41,20 @@ class ContentService:
|
|
36
41
|
search_string (str): The search string.
|
37
42
|
search_type (ContentSearchType): The type of search to perform.
|
38
43
|
limit (int): The maximum number of results to return.
|
44
|
+
reranker_config (Optional[RerankerConfig]): The reranker configuration. Defaults to None.
|
45
|
+
search_language (str): The language for the full-text search. Defaults to "english".
|
39
46
|
scope_ids (Optional[list[str]]): The scope IDs. Defaults to None.
|
40
47
|
|
41
48
|
Returns:
|
42
49
|
list[ContentChunk]: The search results.
|
43
50
|
"""
|
44
51
|
return self._trigger_search_content_chunks(
|
45
|
-
search_string,
|
46
|
-
search_type,
|
47
|
-
limit,
|
48
|
-
|
52
|
+
search_string=search_string,
|
53
|
+
search_type=search_type,
|
54
|
+
limit=limit,
|
55
|
+
reranker_config=reranker_config,
|
56
|
+
search_language=search_language,
|
57
|
+
scope_ids=scope_ids,
|
49
58
|
)
|
50
59
|
|
51
60
|
@to_async
|
@@ -55,7 +64,9 @@ class ContentService:
|
|
55
64
|
search_string: str,
|
56
65
|
search_type: ContentSearchType,
|
57
66
|
limit: int,
|
58
|
-
|
67
|
+
reranker_config: Optional[RerankerConfig] = None,
|
68
|
+
search_language: str = DEFAULT_SEARCH_LANGUAGE,
|
69
|
+
scope_ids: Optional[list[str]] = None,
|
59
70
|
):
|
60
71
|
"""
|
61
72
|
Performs an asynchronous search for content chunks in the knowledge base.
|
@@ -64,16 +75,20 @@ class ContentService:
|
|
64
75
|
search_string (str): The search string.
|
65
76
|
search_type (ContentSearchType): The type of search to perform.
|
66
77
|
limit (int): The maximum number of results to return.
|
78
|
+
reranker_config (Optional[RerankerConfig]): The reranker configuration. Defaults to None.
|
79
|
+
search_language (str): The language for the full-text search. Defaults to "english".
|
67
80
|
scope_ids (Optional[list[str]]): The scope IDs. Defaults to [].
|
68
81
|
|
69
82
|
Returns:
|
70
83
|
list[ContentChunk]: The search results.
|
71
84
|
"""
|
72
85
|
return self._trigger_search_content_chunks(
|
73
|
-
search_string,
|
74
|
-
search_type,
|
75
|
-
limit,
|
76
|
-
|
86
|
+
search_string=search_string,
|
87
|
+
search_type=search_type,
|
88
|
+
limit=limit,
|
89
|
+
reranker_config=reranker_config,
|
90
|
+
search_language=search_language,
|
91
|
+
scope_ids=scope_ids,
|
77
92
|
)
|
78
93
|
|
79
94
|
def _trigger_search_content_chunks(
|
@@ -81,7 +96,9 @@ class ContentService:
|
|
81
96
|
search_string: str,
|
82
97
|
search_type: ContentSearchType,
|
83
98
|
limit: int,
|
84
|
-
|
99
|
+
reranker_config: Optional[RerankerConfig] = None,
|
100
|
+
search_language: str = DEFAULT_SEARCH_LANGUAGE,
|
101
|
+
scope_ids: Optional[list[str]] = None,
|
85
102
|
) -> list[ContentChunk]:
|
86
103
|
scope_ids = scope_ids or self.state.scope_ids or []
|
87
104
|
|
@@ -97,6 +114,8 @@ class ContentService:
|
|
97
114
|
searchType=search_type.name,
|
98
115
|
scopeIds=scope_ids,
|
99
116
|
limit=limit,
|
117
|
+
reranker=reranker_config,
|
118
|
+
language=search_language,
|
100
119
|
chatOnly=self.state.chat_only,
|
101
120
|
)
|
102
121
|
except Exception as e:
|
@@ -323,8 +342,6 @@ class ContentService:
|
|
323
342
|
Exception: If the download fails.
|
324
343
|
"""
|
325
344
|
|
326
|
-
print("download chat id", chat_id)
|
327
|
-
|
328
345
|
url = f"{unique_sdk.api_base}/content/{content_id}/file"
|
329
346
|
if chat_id:
|
330
347
|
url = f"{url}?chatId={chat_id}"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: unique_toolkit
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.5
|
4
4
|
Summary:
|
5
5
|
License: MIT
|
6
6
|
Author: Martin Fadler
|
@@ -18,7 +18,7 @@ Requires-Dist: regex (>=2024.5.15,<2025.0.0)
|
|
18
18
|
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
19
19
|
Requires-Dist: tiktoken (>=0.7.0,<0.8.0)
|
20
20
|
Requires-Dist: typing-extensions (>=4.9.0,<5.0.0)
|
21
|
-
Requires-Dist: unique-sdk (>=0.
|
21
|
+
Requires-Dist: unique-sdk (>=0.9,<0.10)
|
22
22
|
Description-Content-Type: text/markdown
|
23
23
|
|
24
24
|
# Unique Toolkit
|
@@ -102,6 +102,14 @@ All notable changes to this project will be documented in this file.
|
|
102
102
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
103
103
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
104
104
|
|
105
|
+
## [0.5.5] - 2024-07-30
|
106
|
+
- Added parameters to `ContentService.search_content_chunks` and `ContentService.async_search_content_chunks`
|
107
|
+
- `reranker_config` to optinally reranker the search results
|
108
|
+
- `search_language` to specify a language for full-text-search
|
109
|
+
|
110
|
+
## [0.5.4] - 2024-07-26
|
111
|
+
- correct ChatMessage schema
|
112
|
+
|
105
113
|
## [0.5.3] - 2024-07-25
|
106
114
|
- downgrade numpy version to ^1.26.4 to be compatible with langchain libraries (require numpy<2.0)
|
107
115
|
|
@@ -5,12 +5,12 @@ unique_toolkit/app/performance/async_executor.py,sha256=ImekDRWkFeXuIYFnCpSJAqE0
|
|
5
5
|
unique_toolkit/app/performance/async_wrapper.py,sha256=Xli5zH9RFdbBJnlBQS_kP7TGqXhPNou5WKst4FLWzGo,770
|
6
6
|
unique_toolkit/app/schemas.py,sha256=UAbIkrgdqwWEwKqnJwB4TNQWuJgEsFzDxqJbEC8xcOc,1098
|
7
7
|
unique_toolkit/app/verification.py,sha256=UZqTHg3PX_QxMjeLH_BVBYoMVqMnMpeMoqvyTBKDqj8,1996
|
8
|
-
unique_toolkit/chat/schemas.py,sha256=
|
8
|
+
unique_toolkit/chat/schemas.py,sha256=TYqrDy96ynP7XpnT_abOJlq6LkqBTdKwEft4YHeEgR8,801
|
9
9
|
unique_toolkit/chat/service.py,sha256=zxMoOMKlLJNwtRAO8GCpX9tGwVUsbgHWEPWztGe6htw,12300
|
10
10
|
unique_toolkit/chat/state.py,sha256=IljPSqbzQq9TMD9cnbkII8k4eTtkyYOGzRe-DuR-Nic,1831
|
11
11
|
unique_toolkit/chat/utils.py,sha256=ihm-wQykBWhB4liR3LnwPVPt_qGW6ETq21Mw4HY0THE,854
|
12
|
-
unique_toolkit/content/schemas.py,sha256=
|
13
|
-
unique_toolkit/content/service.py,sha256=
|
12
|
+
unique_toolkit/content/schemas.py,sha256=b6QiqZUBdYA14_CfJYeXEGSrPmT98n_Q8knugnP20yA,2093
|
13
|
+
unique_toolkit/content/service.py,sha256=iDQd4dTVrL_NMRJQDMZsZmtFtwTmYfPAqx832waWy3E,12491
|
14
14
|
unique_toolkit/content/utils.py,sha256=x3ABo8ZCRm3YJAQwDtrr82z77DmW4Mei7KCIITjP0fk,6897
|
15
15
|
unique_toolkit/embedding/schemas.py,sha256=1GvKCaSk4jixzVQ2PKq8yDqwGEVY_hWclYtoAr6CC2g,96
|
16
16
|
unique_toolkit/embedding/service.py,sha256=IjBag3koSSeoQTo9836t0K5tkTbu0otvytVWnYQJHw4,2403
|
@@ -18,7 +18,7 @@ unique_toolkit/language_model/infos.py,sha256=NhAkeW7PyusSIHCMvwRikLlzGG4tOXSLf_
|
|
18
18
|
unique_toolkit/language_model/schemas.py,sha256=kTGSGT3ygrH3guQELOWpxN4MTgEPuudi-CTvRu-zCcI,4377
|
19
19
|
unique_toolkit/language_model/service.py,sha256=VHixKmi6-BP-StDQdomS-J-EWKIhHvDjNCi5zrP3mpM,9749
|
20
20
|
unique_toolkit/language_model/utils.py,sha256=WBPj1XKkDgxy_-T8HCZvsfkkSzj_1w4UZzNmyvdbBLY,1081
|
21
|
-
unique_toolkit-0.5.
|
22
|
-
unique_toolkit-0.5.
|
23
|
-
unique_toolkit-0.5.
|
24
|
-
unique_toolkit-0.5.
|
21
|
+
unique_toolkit-0.5.5.dist-info/LICENSE,sha256=bIeCWCYuoUU_MzNdg48-ubJSVm7qxakaRbzTiJ5uxrs,1065
|
22
|
+
unique_toolkit-0.5.5.dist-info/METADATA,sha256=YoLF4NmbLwsUgH839HAXLmfC61kjhzyE5dCx0P3kEek,8548
|
23
|
+
unique_toolkit-0.5.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
24
|
+
unique_toolkit-0.5.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|