unique_toolkit 0.5.4__tar.gz → 0.5.6__tar.gz

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.
Files changed (25) hide show
  1. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/CHANGELOG.md +8 -0
  2. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/PKG-INFO +10 -2
  3. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/pyproject.toml +2 -2
  4. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/content/schemas.py +6 -0
  5. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/content/service.py +29 -12
  6. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/language_model/service.py +2 -2
  7. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/LICENSE +0 -0
  8. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/README.md +0 -0
  9. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/__init__.py +0 -0
  10. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/app/init_logging.py +0 -0
  11. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/app/init_sdk.py +0 -0
  12. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/app/performance/async_executor.py +0 -0
  13. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/app/performance/async_wrapper.py +0 -0
  14. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/app/schemas.py +0 -0
  15. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/app/verification.py +0 -0
  16. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/chat/schemas.py +0 -0
  17. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/chat/service.py +0 -0
  18. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/chat/state.py +0 -0
  19. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/chat/utils.py +0 -0
  20. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/content/utils.py +0 -0
  21. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/embedding/schemas.py +0 -0
  22. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/embedding/service.py +0 -0
  23. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/language_model/infos.py +0 -0
  24. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/language_model/schemas.py +0 -0
  25. {unique_toolkit-0.5.4 → unique_toolkit-0.5.6}/unique_toolkit/language_model/utils.py +0 -0
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.5.6] - 2024-07-30
9
+ - Bug fix: `ContentService.search_content_chunks` and it's `async` equivalent now accept `None` as a valid parameter value for `scope_ids`.
10
+
11
+ ## [0.5.5] - 2024-07-30
12
+ - Added parameters to `ContentService.search_content_chunks` and `ContentService.async_search_content_chunks`
13
+ - `reranker_config` to optinally rerank the search results
14
+ - `search_language` to specify a language for full-text-search
15
+
8
16
  ## [0.5.4] - 2024-07-26
9
17
  - correct ChatMessage schema
10
18
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unique_toolkit
3
- Version: 0.5.4
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.8.10,<0.9.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
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "unique_toolkit"
3
- version = "0.5.4"
3
+ version = "0.5.6"
4
4
  description = ""
5
5
  authors = [
6
6
  "Martin Fadler <martin.fadler@unique.ch>",
@@ -16,7 +16,7 @@ python = "^3.11"
16
16
  typing-extensions = "^4.9.0"
17
17
  pydantic = "^2.8.2"
18
18
  pyhumps = "^3.8.0"
19
- unique-sdk = "^0.8.10"
19
+ unique-sdk = "^0.9.2"
20
20
  numpy = "^1.26.4"
21
21
  python-dotenv = "^1.0.1"
22
22
  requests = "^2.32.3"
@@ -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
- scope_ids,
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
- scope_ids: Optional[list[str]],
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
- scope_ids,
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
- scope_ids: Optional[list[str]],
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(
File without changes
File without changes