unique_sdk 0.9.23__py3-none-any.whl → 0.9.26__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.
Potentially problematic release.
This version of unique_sdk might be problematic. Click here for more details.
- unique_sdk/api_resources/_content.py +21 -1
- unique_sdk/api_resources/_search.py +1 -1
- unique_sdk/utils/file_io.py +7 -1
- {unique_sdk-0.9.23.dist-info → unique_sdk-0.9.26.dist-info}/METADATA +35 -18
- {unique_sdk-0.9.23.dist-info → unique_sdk-0.9.26.dist-info}/RECORD +7 -7
- {unique_sdk-0.9.23.dist-info → unique_sdk-0.9.26.dist-info}/LICENSE +0 -0
- {unique_sdk-0.9.23.dist-info → unique_sdk-0.9.26.dist-info}/WHEEL +0 -0
|
@@ -65,8 +65,28 @@ class Content(APIResource["Content"]):
|
|
|
65
65
|
where: "Content.ContentWhereInput"
|
|
66
66
|
chatId: NotRequired[str]
|
|
67
67
|
|
|
68
|
-
class
|
|
68
|
+
class CustomApiOptions(TypedDict):
|
|
69
|
+
apiIdentifier: str
|
|
70
|
+
apiPayload: Optional[str]
|
|
71
|
+
customisationType: str
|
|
72
|
+
|
|
73
|
+
class VttConfig(TypedDict, total=False):
|
|
74
|
+
languageModel: Optional[str]
|
|
75
|
+
|
|
76
|
+
class IngestionConfig(TypedDict, total=False):
|
|
77
|
+
chunkMaxTokens: Optional[int]
|
|
78
|
+
chunkMaxTokensOnePager: Optional[int]
|
|
79
|
+
chunkMinTokens: Optional[int]
|
|
80
|
+
chunkStrategy: Optional[str]
|
|
81
|
+
customApiOptions: Optional[List["Content.CustomApiOptions"]]
|
|
82
|
+
documentMinTokens: Optional[int]
|
|
83
|
+
excelReadMode: Optional[str]
|
|
84
|
+
jpgReadMode: Optional[str]
|
|
85
|
+
pdfReadMode: Optional[str]
|
|
86
|
+
pptReadMode: Optional[str]
|
|
69
87
|
uniqueIngestionMode: str
|
|
88
|
+
vttConfig: Optional["Content.VttConfig"]
|
|
89
|
+
wordReadMode: Optional[str]
|
|
70
90
|
|
|
71
91
|
class Input(TypedDict):
|
|
72
92
|
key: str
|
|
@@ -8,7 +8,7 @@ class Search(APIResource["Search"]):
|
|
|
8
8
|
OBJECT_NAME: ClassVar[Literal["search.search"]] = "search.search"
|
|
9
9
|
|
|
10
10
|
class CreateParams(RequestOptions):
|
|
11
|
-
chatId: str
|
|
11
|
+
chatId: NotRequired[Optional[str]]
|
|
12
12
|
searchString: str
|
|
13
13
|
searchType: Literal["VECTOR", "COMBINED"]
|
|
14
14
|
language: NotRequired[Optional[str]]
|
unique_sdk/utils/file_io.py
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import tempfile
|
|
3
3
|
from pathlib import Path
|
|
4
|
+
from typing import Optional
|
|
4
5
|
|
|
5
6
|
import requests
|
|
6
7
|
|
|
7
8
|
import unique_sdk
|
|
9
|
+
from unique_sdk.api_resources._content import Content
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
# download readUrl a random directory in /tmp
|
|
@@ -38,19 +40,21 @@ def upload_file(
|
|
|
38
40
|
mime_type,
|
|
39
41
|
scope_or_unique_path=None,
|
|
40
42
|
chat_id=None,
|
|
43
|
+
ingestion_config: Optional[Content.IngestionConfig] = None,
|
|
41
44
|
):
|
|
42
45
|
# check that chatid or scope_or_unique_path is provided
|
|
43
46
|
if not chat_id and not scope_or_unique_path:
|
|
44
47
|
raise ValueError("chat_id or scope_or_unique_path must be provided")
|
|
45
48
|
|
|
46
49
|
size = os.path.getsize(path_to_file)
|
|
47
|
-
createdContent =
|
|
50
|
+
createdContent = Content.upsert(
|
|
48
51
|
user_id=userId,
|
|
49
52
|
company_id=companyId,
|
|
50
53
|
input={
|
|
51
54
|
"key": displayed_filename,
|
|
52
55
|
"title": displayed_filename,
|
|
53
56
|
"mimeType": mime_type,
|
|
57
|
+
"ingestionConfig": ingestion_config, # Pass ingestionConfig here
|
|
54
58
|
},
|
|
55
59
|
scopeId=scope_or_unique_path,
|
|
56
60
|
chatId=chat_id,
|
|
@@ -78,6 +82,7 @@ def upload_file(
|
|
|
78
82
|
"title": displayed_filename,
|
|
79
83
|
"mimeType": mime_type,
|
|
80
84
|
"byteSize": size,
|
|
85
|
+
"ingestionConfig": ingestion_config,
|
|
81
86
|
},
|
|
82
87
|
fileUrl=createdContent.readUrl,
|
|
83
88
|
chatId=chat_id,
|
|
@@ -91,6 +96,7 @@ def upload_file(
|
|
|
91
96
|
"title": displayed_filename,
|
|
92
97
|
"mimeType": mime_type,
|
|
93
98
|
"byteSize": size,
|
|
99
|
+
"ingestionConfig": ingestion_config,
|
|
94
100
|
},
|
|
95
101
|
fileUrl=createdContent.readUrl,
|
|
96
102
|
scopeId=scope_or_unique_path,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: unique_sdk
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.26
|
|
4
4
|
Summary:
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Martin Fadler
|
|
@@ -297,6 +297,11 @@ createdContent = upload_file(
|
|
|
297
297
|
"test.pdf",
|
|
298
298
|
"application/pdf",
|
|
299
299
|
"scope_stcj2osgbl722m22jayidx0n",
|
|
300
|
+
ingestionConfig={
|
|
301
|
+
"chunkMaxTokens": 1000,
|
|
302
|
+
"chunkStrategy": "default",
|
|
303
|
+
"uniqueIngestionMode": "standard",
|
|
304
|
+
},
|
|
300
305
|
)
|
|
301
306
|
|
|
302
307
|
def upload_file(
|
|
@@ -306,6 +311,7 @@ def upload_file(
|
|
|
306
311
|
displayed_filename,
|
|
307
312
|
mimeType,
|
|
308
313
|
scope_or_unique_path,
|
|
314
|
+
ingestion_config=None,
|
|
309
315
|
):
|
|
310
316
|
size = os.path.getsize(path_to_file)
|
|
311
317
|
createdContent = unique_sdk.Content.upsert(
|
|
@@ -315,6 +321,7 @@ def upload_file(
|
|
|
315
321
|
"key": displayed_filename,
|
|
316
322
|
"title": displayed_filename,
|
|
317
323
|
"mimeType": mimeType,
|
|
324
|
+
"ingestionConfig": ingestionConfig,
|
|
318
325
|
},
|
|
319
326
|
scopeId=scope_or_unique_path,
|
|
320
327
|
)
|
|
@@ -340,6 +347,7 @@ def upload_file(
|
|
|
340
347
|
"title": displayed_filename,
|
|
341
348
|
"mimeType": mimeType,
|
|
342
349
|
"byteSize": size,
|
|
350
|
+
"ingestionConfig": ingestionConfig,
|
|
343
351
|
},
|
|
344
352
|
scopeId=scope_or_unique_path,
|
|
345
353
|
readUrl=createdContent.readUrl,
|
|
@@ -544,6 +552,7 @@ These are the options are available for `searchType`:
|
|
|
544
552
|
`scopeIds` Specifies a collection of scope IDs to confine the search.
|
|
545
553
|
`language` Optional. The language specification for full text search.
|
|
546
554
|
`reranker` Optional. The reranker service to be used for re-ranking the search results.
|
|
555
|
+
`chatId` Optional, adds the documents uploaded in this chat to the scope of searched documents.
|
|
547
556
|
|
|
548
557
|
```python
|
|
549
558
|
search = unique_sdk.Search.create(
|
|
@@ -715,7 +724,7 @@ A metadata filter such as the one designed above can be used in a `Search.create
|
|
|
715
724
|
|
|
716
725
|
### Chat History
|
|
717
726
|
|
|
718
|
-
#### `unique_sdk.
|
|
727
|
+
#### `unique_sdk.utils.chat_history.load_history`
|
|
719
728
|
|
|
720
729
|
A helper function that makes sure the chat history is fully loaded and cut to the size of the token window that it fits into the next round of chat interactions.
|
|
721
730
|
|
|
@@ -733,7 +742,7 @@ history = unique_sdk.utils.chat_history.load_history(
|
|
|
733
742
|
)
|
|
734
743
|
```
|
|
735
744
|
|
|
736
|
-
#### `unique_sdk.
|
|
745
|
+
#### `unique_sdk.utils.chat_history.convert_chat_history_to_injectable_string`
|
|
737
746
|
|
|
738
747
|
convert history into a string that can be injected into a prompt. it als returns the token length of the converted history.
|
|
739
748
|
|
|
@@ -747,7 +756,7 @@ chat_history-string, chat_context_token_length = unique_sdk.utils.chat_history.c
|
|
|
747
756
|
|
|
748
757
|
Interacting with the knowledge-base.
|
|
749
758
|
|
|
750
|
-
#### `unique_sdk.
|
|
759
|
+
#### `unique_sdk.utils.file_io.download_content`
|
|
751
760
|
|
|
752
761
|
download files and save them into a folder in `/tmp`
|
|
753
762
|
|
|
@@ -763,7 +772,7 @@ pdfFile = download_content(
|
|
|
763
772
|
}
|
|
764
773
|
```
|
|
765
774
|
|
|
766
|
-
#### `unique_sdk.
|
|
775
|
+
#### `unique_sdk.utils.file_io.upload_file`
|
|
767
776
|
|
|
768
777
|
Allows for uploading files that then get ingested in a scope or a chat.
|
|
769
778
|
|
|
@@ -773,15 +782,15 @@ createdContent = upload_file(
|
|
|
773
782
|
userId=userId,
|
|
774
783
|
path_to_file="/tmp/hello.pdf",
|
|
775
784
|
displayed_filename="hello.pdf",
|
|
776
|
-
|
|
777
|
-
|
|
785
|
+
mime_type="application/pdf",
|
|
786
|
+
scope_or_unique_path="scope_stcj2osgbl722m22jayidx0n",
|
|
778
787
|
chat_id=None,
|
|
779
788
|
)
|
|
780
789
|
```
|
|
781
790
|
|
|
782
791
|
### Sources
|
|
783
792
|
|
|
784
|
-
#### `unique_sdk.
|
|
793
|
+
#### `unique_sdk.utils.sources.merge_sources`
|
|
785
794
|
|
|
786
795
|
Merges multiple search results based on their 'id', removing redundant document and info markers.
|
|
787
796
|
|
|
@@ -810,15 +819,15 @@ search = unique_sdk.Search.create(
|
|
|
810
819
|
chatOnly=False,
|
|
811
820
|
)
|
|
812
821
|
|
|
813
|
-
searchContext = unique_sdk.
|
|
822
|
+
searchContext = unique_sdk.utils.token.pick_search_results_for_token_window(
|
|
814
823
|
search["data"], config["maxTokens"] - historyLength
|
|
815
824
|
)
|
|
816
825
|
|
|
817
|
-
searchContext = unique_sdk.
|
|
826
|
+
searchContext = unique_sdk.utils.sources.merge_sources(search)
|
|
818
827
|
|
|
819
828
|
```
|
|
820
829
|
|
|
821
|
-
#### `unique_sdk.
|
|
830
|
+
#### `unique_sdk.utils.sources.sort_sources`
|
|
822
831
|
|
|
823
832
|
Sort sources by order of appearance in documents
|
|
824
833
|
|
|
@@ -835,14 +844,14 @@ search = unique_sdk.Search.create(
|
|
|
835
844
|
chatOnly=False,
|
|
836
845
|
)
|
|
837
846
|
|
|
838
|
-
searchContext = unique_sdk.
|
|
847
|
+
searchContext = unique_sdk.utils.token.pick_search_results_for_token_window(
|
|
839
848
|
search["data"], config["maxTokens"] - historyLength
|
|
840
849
|
)
|
|
841
850
|
|
|
842
|
-
searchContext = unique_sdk.
|
|
851
|
+
searchContext = unique_sdk.utils.sources.sort_sources(search)
|
|
843
852
|
```
|
|
844
853
|
|
|
845
|
-
#### `unique_sdk.
|
|
854
|
+
#### `unique_sdk.utils.sources.post_process_sources`
|
|
846
855
|
|
|
847
856
|
Post-processes the provided text by converting source references into superscript numerals (required
|
|
848
857
|
format by backend to display sources in the chat window)
|
|
@@ -869,7 +878,7 @@ text_with_sup = post_process_sources(text)
|
|
|
869
878
|
|
|
870
879
|
### Token
|
|
871
880
|
|
|
872
|
-
#### unique_sdk.
|
|
881
|
+
#### unique_sdk.utils.token.pick_search_results_for_token_window
|
|
873
882
|
|
|
874
883
|
Selects and returns a list of search results that fit within a specified token limit.
|
|
875
884
|
|
|
@@ -898,12 +907,12 @@ search = unique_sdk.Search.create(
|
|
|
898
907
|
chatOnly=False,
|
|
899
908
|
)
|
|
900
909
|
|
|
901
|
-
searchContext = unique_sdk.
|
|
910
|
+
searchContext = unique_sdk.utils.token.pick_search_results_for_token_window(
|
|
902
911
|
search["data"], config["maxTokens"] - historyLength
|
|
903
912
|
)
|
|
904
913
|
```
|
|
905
914
|
|
|
906
|
-
#### unique_sdk.
|
|
915
|
+
#### unique_sdk.utils.token.count_tokens
|
|
907
916
|
|
|
908
917
|
Counts the number of tokens in the provided text.
|
|
909
918
|
|
|
@@ -920,7 +929,7 @@ Returns:
|
|
|
920
929
|
|
|
921
930
|
```python
|
|
922
931
|
hello = "hello you!"
|
|
923
|
-
searchContext = unique_sdk.
|
|
932
|
+
searchContext = unique_sdk.utils.token.count_tokens(hello)
|
|
924
933
|
```
|
|
925
934
|
|
|
926
935
|
## Error Handling
|
|
@@ -940,6 +949,14 @@ All notable changes to this project will be documented in this file.
|
|
|
940
949
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
941
950
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
942
951
|
|
|
952
|
+
## [0.9.26] - 2025-05-13
|
|
953
|
+
- Add the possibility to specify ingestionConfig when creating or updating a Content.
|
|
954
|
+
|
|
955
|
+
## [0.9.25] - 2025-05-02
|
|
956
|
+
- Fixed typos in `README.md`, including incorrect `sdk.utils` imports and code example errors.
|
|
957
|
+
|
|
958
|
+
## [0.9.24] - 2025-04-23
|
|
959
|
+
- Make `chatId` property in `Search.CreateParams` optional
|
|
943
960
|
|
|
944
961
|
## [0.9.23] - 2025-03-25
|
|
945
962
|
- Define programming language classifier explicitly for python 3.11
|
|
@@ -16,20 +16,20 @@ unique_sdk/_webhook.py,sha256=GYxbUibQN_W4XlNTHaMIksT9FQJk4LJmlKcxOu3jqiU,2855
|
|
|
16
16
|
unique_sdk/api_resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
unique_sdk/api_resources/_acronyms.py,sha256=GIU1XH1flGWQYcpsFqTYwg4ioIGxVmb15tux84nmhEg,891
|
|
18
18
|
unique_sdk/api_resources/_chat_completion.py,sha256=hAPPHxoljcoHeTboxoJkcXgpqA2hNBu6a6vamdxag58,2000
|
|
19
|
-
unique_sdk/api_resources/_content.py,sha256=
|
|
19
|
+
unique_sdk/api_resources/_content.py,sha256=y8LU7H7GNh6R5uowRHP6u1Yq-bQZF-5tNdsz_GLRcIA,5713
|
|
20
20
|
unique_sdk/api_resources/_embedding.py,sha256=C6qak7cCUBMBINfPhgH8taCJZ9n6w1MUElqDJJ8dG10,1281
|
|
21
21
|
unique_sdk/api_resources/_event.py,sha256=bpWF9vstdoAWbUzr-iiGP713ceP0zPk77GJXiImf9zg,374
|
|
22
22
|
unique_sdk/api_resources/_integrated.py,sha256=l1vS8kJiSLie61mqDO3KI2MNmYwFydmCIoJpP_tPhSI,2956
|
|
23
23
|
unique_sdk/api_resources/_message.py,sha256=gEDIzg3METZU2k7m69meAuf0IWmZxnYOjbBKPRMwPYE,7688
|
|
24
24
|
unique_sdk/api_resources/_message_assessment.py,sha256=SSfx6eW7zb_GKe8cFJzCqW-t-_eWEXxKP5cnIb0DhIc,2276
|
|
25
|
-
unique_sdk/api_resources/_search.py,sha256=
|
|
25
|
+
unique_sdk/api_resources/_search.py,sha256=pAVMXL2AdJNP5JG-7LlaU2Uw1152iUaMZ2YO7fHnNWc,1906
|
|
26
26
|
unique_sdk/api_resources/_search_string.py,sha256=4Idw6exgZdA8qksz9WkiA68k1hTU-7yFkgT_OLU_GkE,1662
|
|
27
27
|
unique_sdk/api_resources/_short_term_memory.py,sha256=vPRN-Y0WPx74E6y-A3LocGc0TxJdzT-xGL66WzZwKRg,2820
|
|
28
28
|
unique_sdk/utils/chat_history.py,sha256=5UqL9hF1O9pV7skbNOlEibF5rHdYsmG3m5-YEPUowOs,3037
|
|
29
|
-
unique_sdk/utils/file_io.py,sha256=
|
|
29
|
+
unique_sdk/utils/file_io.py,sha256=28Edm3g1xvW7FWAvAmmG0K63o6XbTY2aCZkIviTQOI4,4176
|
|
30
30
|
unique_sdk/utils/sources.py,sha256=wfboE-neMKa0Wuq9QzfAEFMkNLrIrmm0v-QF33sLo6k,4952
|
|
31
31
|
unique_sdk/utils/token.py,sha256=AzKuAA1AwBtnvSFxGcsHLpxXr_wWE5Mj4jYBbOz2ljA,1740
|
|
32
|
-
unique_sdk-0.9.
|
|
33
|
-
unique_sdk-0.9.
|
|
34
|
-
unique_sdk-0.9.
|
|
35
|
-
unique_sdk-0.9.
|
|
32
|
+
unique_sdk-0.9.26.dist-info/LICENSE,sha256=EJCWoHgrXVBUb47PnjeV4MFIEOR71MAdCOIgv61J-4k,1065
|
|
33
|
+
unique_sdk-0.9.26.dist-info/METADATA,sha256=qm0wVfwhtgQICr-3iOYgpwE0OaJSYQ39ZEXcXqGmru8,30967
|
|
34
|
+
unique_sdk-0.9.26.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
35
|
+
unique_sdk-0.9.26.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|