unique_toolkit 0.5.4__py3-none-any.whl → 0.5.6__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/schemas.py +6 -0
- unique_toolkit/content/service.py +29 -12
- unique_toolkit/language_model/service.py +2 -2
- {unique_toolkit-0.5.4.dist-info → unique_toolkit-0.5.6.dist-info}/METADATA +10 -2
- {unique_toolkit-0.5.4.dist-info → unique_toolkit-0.5.6.dist-info}/RECORD +7 -7
- {unique_toolkit-0.5.4.dist-info → unique_toolkit-0.5.6.dist-info}/LICENSE +0 -0
- {unique_toolkit-0.5.4.dist-info → unique_toolkit-0.5.6.dist-info}/WHEEL +0 -0
@@ -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,10 +96,10 @@ 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
|
-
scope_ids = scope_ids or self.state.scope_ids or []
|
87
|
-
|
88
103
|
if not scope_ids:
|
89
104
|
self.logger.warning("No scope IDs provided for search.")
|
90
105
|
|
@@ -97,6 +112,8 @@ class ContentService:
|
|
97
112
|
searchType=search_type.name,
|
98
113
|
scopeIds=scope_ids,
|
99
114
|
limit=limit,
|
115
|
+
reranker=reranker_config.model_dump() if reranker_config else None,
|
116
|
+
language=search_language,
|
100
117
|
chatOnly=self.state.chat_only,
|
101
118
|
)
|
102
119
|
except Exception as e:
|
@@ -92,7 +92,7 @@ class LanguageModelService:
|
|
92
92
|
tools: Optional[list[LanguageModelTool]] = None,
|
93
93
|
) -> LanguageModelResponse:
|
94
94
|
options = self._add_tools_to_options({}, tools)
|
95
|
-
messages = messages.model_dump(exclude_none=True)
|
95
|
+
messages = messages.model_dump(exclude_none=True, exclude={"tool_calls"})
|
96
96
|
try:
|
97
97
|
response = unique_sdk.ChatCompletion.create(
|
98
98
|
company_id=self.state.company_id,
|
@@ -217,7 +217,7 @@ class LanguageModelService:
|
|
217
217
|
for chunk in content_chunks
|
218
218
|
]
|
219
219
|
|
220
|
-
messages = messages.model_dump(exclude_none=True)
|
220
|
+
messages = messages.model_dump(exclude_none=True, exclude={"tool_calls"})
|
221
221
|
|
222
222
|
try:
|
223
223
|
response = unique_sdk.Integrated.chat_stream_completion(
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: unique_toolkit
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.6
|
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.2,<0.10.0)
|
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.6] - 2024-07-30
|
106
|
+
- Bug fix: `ContentService.search_content_chunks` and it's `async` equivalent now accept `None` as a valid parameter value for `scope_ids`.
|
107
|
+
|
108
|
+
## [0.5.5] - 2024-07-30
|
109
|
+
- Added parameters to `ContentService.search_content_chunks` and `ContentService.async_search_content_chunks`
|
110
|
+
- `reranker_config` to optinally rerank the search results
|
111
|
+
- `search_language` to specify a language for full-text-search
|
112
|
+
|
105
113
|
## [0.5.4] - 2024-07-26
|
106
114
|
- correct ChatMessage schema
|
107
115
|
|
@@ -9,16 +9,16 @@ unique_toolkit/chat/schemas.py,sha256=TYqrDy96ynP7XpnT_abOJlq6LkqBTdKwEft4YHeEgR
|
|
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=PQUog5lYYSnKOpSWMVfB1ITTTar09mY4Z1J1EBRjd3k,12472
|
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
|
17
17
|
unique_toolkit/language_model/infos.py,sha256=NhAkeW7PyusSIHCMvwRikLlzGG4tOXSLf_Fnq7V9rNE,8881
|
18
18
|
unique_toolkit/language_model/schemas.py,sha256=kTGSGT3ygrH3guQELOWpxN4MTgEPuudi-CTvRu-zCcI,4377
|
19
|
-
unique_toolkit/language_model/service.py,sha256=
|
19
|
+
unique_toolkit/language_model/service.py,sha256=OX3VCvco7K2me-2q0LgzHAdpCfPd4mHlwb1F3aZgYSk,9797
|
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.6.dist-info/LICENSE,sha256=bIeCWCYuoUU_MzNdg48-ubJSVm7qxakaRbzTiJ5uxrs,1065
|
22
|
+
unique_toolkit-0.5.6.dist-info/METADATA,sha256=jwWhgPrtTNiTsC_Xk8KaTGYiVc1tZ9uvkkC7ePfL_XI,8715
|
23
|
+
unique_toolkit-0.5.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
24
|
+
unique_toolkit-0.5.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|