usecortex-ai 0.2.0__py3-none-any.whl → 0.2.2__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.
- usecortex_ai/__init__.py +20 -3
- usecortex_ai/client.py +7 -78
- usecortex_ai/core/client_wrapper.py +6 -8
- usecortex_ai/document/__init__.py +4 -0
- usecortex_ai/document/client.py +139 -0
- usecortex_ai/document/raw_client.py +312 -0
- usecortex_ai/embeddings/client.py +50 -82
- usecortex_ai/embeddings/raw_client.py +48 -80
- usecortex_ai/fetch/client.py +10 -0
- usecortex_ai/fetch/raw_client.py +10 -0
- usecortex_ai/search/client.py +74 -80
- usecortex_ai/search/raw_client.py +74 -80
- usecortex_ai/sources/client.py +28 -0
- usecortex_ai/sources/raw_client.py +28 -0
- usecortex_ai/tenant/client.py +152 -4
- usecortex_ai/tenant/raw_client.py +502 -4
- usecortex_ai/types/__init__.py +18 -2
- usecortex_ai/types/add_user_memory_response.py +36 -0
- usecortex_ai/types/app_sources_upload_data.py +10 -2
- usecortex_ai/types/attachment_model.py +34 -7
- usecortex_ai/types/batch_upload_data.py +10 -2
- usecortex_ai/types/body_scrape_webpage_upload_scrape_webpage_post.py +0 -2
- usecortex_ai/types/body_update_scrape_job_upload_update_webpage_patch.py +0 -2
- usecortex_ai/types/content_model.py +33 -6
- usecortex_ai/types/delete_memory_request.py +14 -3
- usecortex_ai/types/delete_sources.py +20 -0
- usecortex_ai/types/delete_sub_tenant_data.py +42 -0
- usecortex_ai/types/delete_user_memory_response.py +31 -0
- usecortex_ai/types/embeddings_create_collection_data.py +19 -4
- usecortex_ai/types/embeddings_delete_data.py +19 -4
- usecortex_ai/types/embeddings_get_data.py +19 -4
- usecortex_ai/types/embeddings_search_data.py +19 -4
- usecortex_ai/types/error_response.py +0 -1
- usecortex_ai/types/fetch_content_data.py +19 -5
- usecortex_ai/types/file_upload_result.py +9 -2
- usecortex_ai/types/generate_user_memory_response.py +32 -0
- usecortex_ai/types/list_sources_response.py +14 -3
- usecortex_ai/types/list_user_memories_response.py +32 -0
- usecortex_ai/types/markdown_upload_request.py +18 -3
- usecortex_ai/types/processing_status.py +14 -3
- usecortex_ai/types/relations.py +2 -2
- usecortex_ai/types/retrieve_user_memory_response.py +32 -0
- usecortex_ai/types/search_chunk.py +54 -16
- usecortex_ai/types/single_upload_data.py +10 -2
- usecortex_ai/types/source.py +34 -14
- usecortex_ai/types/source_model.py +63 -12
- usecortex_ai/types/sub_tenant_ids_data.py +42 -0
- usecortex_ai/types/tenant_create_data.py +19 -4
- usecortex_ai/types/tenant_stats.py +24 -5
- usecortex_ai/types/user_memory.py +31 -0
- usecortex_ai/upload/client.py +508 -132
- usecortex_ai/upload/raw_client.py +492 -152
- usecortex_ai/user/client.py +14 -6
- usecortex_ai/user/raw_client.py +14 -6
- usecortex_ai/user_memory/client.py +184 -50
- usecortex_ai/user_memory/raw_client.py +905 -88
- {usecortex_ai-0.2.0.dist-info → usecortex_ai-0.2.2.dist-info}/METADATA +1 -1
- usecortex_ai-0.2.2.dist-info/RECORD +100 -0
- usecortex_ai/raw_client.py +0 -90
- usecortex_ai/types/source_content.py +0 -26
- usecortex_ai-0.2.0.dist-info/RECORD +0 -90
- {usecortex_ai-0.2.0.dist-info → usecortex_ai-0.2.2.dist-info}/WHEEL +0 -0
- {usecortex_ai-0.2.0.dist-info → usecortex_ai-0.2.2.dist-info}/licenses/LICENSE +0 -0
- {usecortex_ai-0.2.0.dist-info → usecortex_ai-0.2.2.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from json.decoder import JSONDecodeError
|
|
5
|
+
|
|
6
|
+
from ..core.api_error import ApiError
|
|
7
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
|
+
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
9
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
10
|
+
from ..core.request_options import RequestOptions
|
|
11
|
+
from ..errors.bad_request_error import BadRequestError
|
|
12
|
+
from ..errors.forbidden_error import ForbiddenError
|
|
13
|
+
from ..errors.internal_server_error import InternalServerError
|
|
14
|
+
from ..errors.not_found_error import NotFoundError
|
|
15
|
+
from ..errors.service_unavailable_error import ServiceUnavailableError
|
|
16
|
+
from ..errors.unauthorized_error import UnauthorizedError
|
|
17
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
18
|
+
from ..types.actual_error_response import ActualErrorResponse
|
|
19
|
+
from ..types.delete_sources import DeleteSources
|
|
20
|
+
|
|
21
|
+
# this is used as the default value for optional parameters
|
|
22
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class RawDocumentClient:
|
|
26
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
27
|
+
self._client_wrapper = client_wrapper
|
|
28
|
+
|
|
29
|
+
def delete(
|
|
30
|
+
self,
|
|
31
|
+
*,
|
|
32
|
+
tenant_id: str,
|
|
33
|
+
source_ids: typing.Sequence[str],
|
|
34
|
+
sub_tenant_id: typing.Optional[str] = OMIT,
|
|
35
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
36
|
+
) -> HttpResponse[DeleteSources]:
|
|
37
|
+
"""
|
|
38
|
+
Remove documents and content from your knowledge base.
|
|
39
|
+
|
|
40
|
+
This endpoint permanently deletes the specified sources from your knowledge base. Once deleted, the content will no longer be available for search or retrieval.
|
|
41
|
+
|
|
42
|
+
Use this carefully as the action cannot be undone. The system will confirm successful deletion of each source ID you specify.
|
|
43
|
+
|
|
44
|
+
Parameters
|
|
45
|
+
----------
|
|
46
|
+
tenant_id : str
|
|
47
|
+
Unique identifier for the tenant/organization
|
|
48
|
+
|
|
49
|
+
source_ids : typing.Sequence[str]
|
|
50
|
+
List of source IDs to delete
|
|
51
|
+
|
|
52
|
+
sub_tenant_id : typing.Optional[str]
|
|
53
|
+
Optional sub-tenant identifier for organizing data within a tenant. If not provided, defaults to tenant_id
|
|
54
|
+
|
|
55
|
+
request_options : typing.Optional[RequestOptions]
|
|
56
|
+
Request-specific configuration.
|
|
57
|
+
|
|
58
|
+
Returns
|
|
59
|
+
-------
|
|
60
|
+
HttpResponse[DeleteSources]
|
|
61
|
+
Successful Response
|
|
62
|
+
"""
|
|
63
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
64
|
+
"document/delete",
|
|
65
|
+
method="DELETE",
|
|
66
|
+
json={
|
|
67
|
+
"tenant_id": tenant_id,
|
|
68
|
+
"source_ids": source_ids,
|
|
69
|
+
"sub_tenant_id": sub_tenant_id,
|
|
70
|
+
},
|
|
71
|
+
headers={
|
|
72
|
+
"content-type": "application/json",
|
|
73
|
+
},
|
|
74
|
+
request_options=request_options,
|
|
75
|
+
omit=OMIT,
|
|
76
|
+
)
|
|
77
|
+
try:
|
|
78
|
+
if 200 <= _response.status_code < 300:
|
|
79
|
+
_data = typing.cast(
|
|
80
|
+
DeleteSources,
|
|
81
|
+
parse_obj_as(
|
|
82
|
+
type_=DeleteSources, # type: ignore
|
|
83
|
+
object_=_response.json(),
|
|
84
|
+
),
|
|
85
|
+
)
|
|
86
|
+
return HttpResponse(response=_response, data=_data)
|
|
87
|
+
if _response.status_code == 400:
|
|
88
|
+
raise BadRequestError(
|
|
89
|
+
headers=dict(_response.headers),
|
|
90
|
+
body=typing.cast(
|
|
91
|
+
ActualErrorResponse,
|
|
92
|
+
parse_obj_as(
|
|
93
|
+
type_=ActualErrorResponse, # type: ignore
|
|
94
|
+
object_=_response.json(),
|
|
95
|
+
),
|
|
96
|
+
),
|
|
97
|
+
)
|
|
98
|
+
if _response.status_code == 401:
|
|
99
|
+
raise UnauthorizedError(
|
|
100
|
+
headers=dict(_response.headers),
|
|
101
|
+
body=typing.cast(
|
|
102
|
+
ActualErrorResponse,
|
|
103
|
+
parse_obj_as(
|
|
104
|
+
type_=ActualErrorResponse, # type: ignore
|
|
105
|
+
object_=_response.json(),
|
|
106
|
+
),
|
|
107
|
+
),
|
|
108
|
+
)
|
|
109
|
+
if _response.status_code == 403:
|
|
110
|
+
raise ForbiddenError(
|
|
111
|
+
headers=dict(_response.headers),
|
|
112
|
+
body=typing.cast(
|
|
113
|
+
ActualErrorResponse,
|
|
114
|
+
parse_obj_as(
|
|
115
|
+
type_=ActualErrorResponse, # type: ignore
|
|
116
|
+
object_=_response.json(),
|
|
117
|
+
),
|
|
118
|
+
),
|
|
119
|
+
)
|
|
120
|
+
if _response.status_code == 404:
|
|
121
|
+
raise NotFoundError(
|
|
122
|
+
headers=dict(_response.headers),
|
|
123
|
+
body=typing.cast(
|
|
124
|
+
ActualErrorResponse,
|
|
125
|
+
parse_obj_as(
|
|
126
|
+
type_=ActualErrorResponse, # type: ignore
|
|
127
|
+
object_=_response.json(),
|
|
128
|
+
),
|
|
129
|
+
),
|
|
130
|
+
)
|
|
131
|
+
if _response.status_code == 422:
|
|
132
|
+
raise UnprocessableEntityError(
|
|
133
|
+
headers=dict(_response.headers),
|
|
134
|
+
body=typing.cast(
|
|
135
|
+
typing.Optional[typing.Any],
|
|
136
|
+
parse_obj_as(
|
|
137
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
138
|
+
object_=_response.json(),
|
|
139
|
+
),
|
|
140
|
+
),
|
|
141
|
+
)
|
|
142
|
+
if _response.status_code == 500:
|
|
143
|
+
raise InternalServerError(
|
|
144
|
+
headers=dict(_response.headers),
|
|
145
|
+
body=typing.cast(
|
|
146
|
+
ActualErrorResponse,
|
|
147
|
+
parse_obj_as(
|
|
148
|
+
type_=ActualErrorResponse, # type: ignore
|
|
149
|
+
object_=_response.json(),
|
|
150
|
+
),
|
|
151
|
+
),
|
|
152
|
+
)
|
|
153
|
+
if _response.status_code == 503:
|
|
154
|
+
raise ServiceUnavailableError(
|
|
155
|
+
headers=dict(_response.headers),
|
|
156
|
+
body=typing.cast(
|
|
157
|
+
ActualErrorResponse,
|
|
158
|
+
parse_obj_as(
|
|
159
|
+
type_=ActualErrorResponse, # type: ignore
|
|
160
|
+
object_=_response.json(),
|
|
161
|
+
),
|
|
162
|
+
),
|
|
163
|
+
)
|
|
164
|
+
_response_json = _response.json()
|
|
165
|
+
except JSONDecodeError:
|
|
166
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
167
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class AsyncRawDocumentClient:
|
|
171
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
172
|
+
self._client_wrapper = client_wrapper
|
|
173
|
+
|
|
174
|
+
async def delete(
|
|
175
|
+
self,
|
|
176
|
+
*,
|
|
177
|
+
tenant_id: str,
|
|
178
|
+
source_ids: typing.Sequence[str],
|
|
179
|
+
sub_tenant_id: typing.Optional[str] = OMIT,
|
|
180
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
181
|
+
) -> AsyncHttpResponse[DeleteSources]:
|
|
182
|
+
"""
|
|
183
|
+
Remove documents and content from your knowledge base.
|
|
184
|
+
|
|
185
|
+
This endpoint permanently deletes the specified sources from your knowledge base. Once deleted, the content will no longer be available for search or retrieval.
|
|
186
|
+
|
|
187
|
+
Use this carefully as the action cannot be undone. The system will confirm successful deletion of each source ID you specify.
|
|
188
|
+
|
|
189
|
+
Parameters
|
|
190
|
+
----------
|
|
191
|
+
tenant_id : str
|
|
192
|
+
Unique identifier for the tenant/organization
|
|
193
|
+
|
|
194
|
+
source_ids : typing.Sequence[str]
|
|
195
|
+
List of source IDs to delete
|
|
196
|
+
|
|
197
|
+
sub_tenant_id : typing.Optional[str]
|
|
198
|
+
Optional sub-tenant identifier for organizing data within a tenant. If not provided, defaults to tenant_id
|
|
199
|
+
|
|
200
|
+
request_options : typing.Optional[RequestOptions]
|
|
201
|
+
Request-specific configuration.
|
|
202
|
+
|
|
203
|
+
Returns
|
|
204
|
+
-------
|
|
205
|
+
AsyncHttpResponse[DeleteSources]
|
|
206
|
+
Successful Response
|
|
207
|
+
"""
|
|
208
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
209
|
+
"document/delete",
|
|
210
|
+
method="DELETE",
|
|
211
|
+
json={
|
|
212
|
+
"tenant_id": tenant_id,
|
|
213
|
+
"source_ids": source_ids,
|
|
214
|
+
"sub_tenant_id": sub_tenant_id,
|
|
215
|
+
},
|
|
216
|
+
headers={
|
|
217
|
+
"content-type": "application/json",
|
|
218
|
+
},
|
|
219
|
+
request_options=request_options,
|
|
220
|
+
omit=OMIT,
|
|
221
|
+
)
|
|
222
|
+
try:
|
|
223
|
+
if 200 <= _response.status_code < 300:
|
|
224
|
+
_data = typing.cast(
|
|
225
|
+
DeleteSources,
|
|
226
|
+
parse_obj_as(
|
|
227
|
+
type_=DeleteSources, # type: ignore
|
|
228
|
+
object_=_response.json(),
|
|
229
|
+
),
|
|
230
|
+
)
|
|
231
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
232
|
+
if _response.status_code == 400:
|
|
233
|
+
raise BadRequestError(
|
|
234
|
+
headers=dict(_response.headers),
|
|
235
|
+
body=typing.cast(
|
|
236
|
+
ActualErrorResponse,
|
|
237
|
+
parse_obj_as(
|
|
238
|
+
type_=ActualErrorResponse, # type: ignore
|
|
239
|
+
object_=_response.json(),
|
|
240
|
+
),
|
|
241
|
+
),
|
|
242
|
+
)
|
|
243
|
+
if _response.status_code == 401:
|
|
244
|
+
raise UnauthorizedError(
|
|
245
|
+
headers=dict(_response.headers),
|
|
246
|
+
body=typing.cast(
|
|
247
|
+
ActualErrorResponse,
|
|
248
|
+
parse_obj_as(
|
|
249
|
+
type_=ActualErrorResponse, # type: ignore
|
|
250
|
+
object_=_response.json(),
|
|
251
|
+
),
|
|
252
|
+
),
|
|
253
|
+
)
|
|
254
|
+
if _response.status_code == 403:
|
|
255
|
+
raise ForbiddenError(
|
|
256
|
+
headers=dict(_response.headers),
|
|
257
|
+
body=typing.cast(
|
|
258
|
+
ActualErrorResponse,
|
|
259
|
+
parse_obj_as(
|
|
260
|
+
type_=ActualErrorResponse, # type: ignore
|
|
261
|
+
object_=_response.json(),
|
|
262
|
+
),
|
|
263
|
+
),
|
|
264
|
+
)
|
|
265
|
+
if _response.status_code == 404:
|
|
266
|
+
raise NotFoundError(
|
|
267
|
+
headers=dict(_response.headers),
|
|
268
|
+
body=typing.cast(
|
|
269
|
+
ActualErrorResponse,
|
|
270
|
+
parse_obj_as(
|
|
271
|
+
type_=ActualErrorResponse, # type: ignore
|
|
272
|
+
object_=_response.json(),
|
|
273
|
+
),
|
|
274
|
+
),
|
|
275
|
+
)
|
|
276
|
+
if _response.status_code == 422:
|
|
277
|
+
raise UnprocessableEntityError(
|
|
278
|
+
headers=dict(_response.headers),
|
|
279
|
+
body=typing.cast(
|
|
280
|
+
typing.Optional[typing.Any],
|
|
281
|
+
parse_obj_as(
|
|
282
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
283
|
+
object_=_response.json(),
|
|
284
|
+
),
|
|
285
|
+
),
|
|
286
|
+
)
|
|
287
|
+
if _response.status_code == 500:
|
|
288
|
+
raise InternalServerError(
|
|
289
|
+
headers=dict(_response.headers),
|
|
290
|
+
body=typing.cast(
|
|
291
|
+
ActualErrorResponse,
|
|
292
|
+
parse_obj_as(
|
|
293
|
+
type_=ActualErrorResponse, # type: ignore
|
|
294
|
+
object_=_response.json(),
|
|
295
|
+
),
|
|
296
|
+
),
|
|
297
|
+
)
|
|
298
|
+
if _response.status_code == 503:
|
|
299
|
+
raise ServiceUnavailableError(
|
|
300
|
+
headers=dict(_response.headers),
|
|
301
|
+
body=typing.cast(
|
|
302
|
+
ActualErrorResponse,
|
|
303
|
+
parse_obj_as(
|
|
304
|
+
type_=ActualErrorResponse, # type: ignore
|
|
305
|
+
object_=_response.json(),
|
|
306
|
+
),
|
|
307
|
+
),
|
|
308
|
+
)
|
|
309
|
+
_response_json = _response.json()
|
|
310
|
+
except JSONDecodeError:
|
|
311
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
312
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
@@ -38,28 +38,20 @@ class EmbeddingsClient:
|
|
|
38
38
|
request_options: typing.Optional[RequestOptions] = None,
|
|
39
39
|
) -> EmbeddingsDeleteData:
|
|
40
40
|
"""
|
|
41
|
-
Delete
|
|
41
|
+
Delete embedding chunks by chunk ID.
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
chunk IDs to the backend delete service.
|
|
45
|
-
|
|
46
|
-
Args:
|
|
47
|
-
request (EmbeddingsDeleteRequest): The delete request containing:
|
|
48
|
-
- chunk_ids (List[str]): List of chunk IDs to delete
|
|
49
|
-
- tenant_id (str): Tenant identifier for multi-tenancy
|
|
50
|
-
- sub_tenant_id (str, optional): Sub-tenant identifier, defaults to tenant_id
|
|
51
|
-
api_details (dict): Authentication details obtained from API key validation
|
|
52
|
-
|
|
53
|
-
Returns:
|
|
54
|
-
EmbeddingsDeleteData: Success response with deletion details
|
|
43
|
+
Use this to remove specific chunks from your embeddings index when they are no longer valid or should not appear in results.
|
|
55
44
|
|
|
56
45
|
Parameters
|
|
57
46
|
----------
|
|
58
47
|
chunk_ids : typing.Sequence[str]
|
|
48
|
+
The chunk IDs of the source you want to delete
|
|
59
49
|
|
|
60
50
|
tenant_id : str
|
|
51
|
+
Unique identifier for the tenant/organization
|
|
61
52
|
|
|
62
53
|
sub_tenant_id : typing.Optional[str]
|
|
54
|
+
Optional sub-tenant identifier for organizing data within a tenant. If not provided, defaults to tenant_id
|
|
63
55
|
|
|
64
56
|
request_options : typing.Optional[RequestOptions]
|
|
65
57
|
Request-specific configuration.
|
|
@@ -84,37 +76,31 @@ class EmbeddingsClient:
|
|
|
84
76
|
def search(
|
|
85
77
|
self,
|
|
86
78
|
*,
|
|
87
|
-
embeddings: typing.Sequence[float],
|
|
88
79
|
tenant_id: str,
|
|
80
|
+
embeddings: typing.Optional[typing.Sequence[float]] = OMIT,
|
|
89
81
|
sub_tenant_id: typing.Optional[str] = OMIT,
|
|
90
82
|
max_chunks: typing.Optional[int] = OMIT,
|
|
91
83
|
request_options: typing.Optional[RequestOptions] = None,
|
|
92
84
|
) -> EmbeddingsSearchData:
|
|
93
85
|
"""
|
|
94
|
-
|
|
86
|
+
Find similar chunks using an embedding vector.
|
|
95
87
|
|
|
96
|
-
|
|
97
|
-
and returns a list of the most similar chunk IDs based on vector similarity.
|
|
88
|
+
Use this to retrieve the most similar chunk IDs to a single query embedding.
|
|
98
89
|
|
|
99
|
-
Args:
|
|
100
|
-
request (EmbeddingsSearchRequest): The search request containing:
|
|
101
|
-
- embeddings (List[float]): Single embedding vector for similarity search
|
|
102
|
-
- tenant_id (str): Tenant identifier for multi-tenancy
|
|
103
|
-
- sub_tenant_id (str, optional): Sub-tenant identifier, defaults to tenant_id
|
|
104
|
-
- max_chunks (int, optional): Maximum number of chunk IDs to return (default: 10)
|
|
105
|
-
api_details (dict): Authentication details obtained from API key validation
|
|
106
90
|
|
|
107
|
-
|
|
108
|
-
|
|
91
|
+
Expected outcome
|
|
92
|
+
- You receive the closest chunk IDs with optional similarity scores.
|
|
109
93
|
|
|
110
94
|
Parameters
|
|
111
95
|
----------
|
|
112
|
-
embeddings : typing.Sequence[float]
|
|
113
|
-
Single embedding vector for search
|
|
114
|
-
|
|
115
96
|
tenant_id : str
|
|
97
|
+
Unique identifier for the tenant/organization
|
|
98
|
+
|
|
99
|
+
embeddings : typing.Optional[typing.Sequence[float]]
|
|
100
|
+
The embedding vector for search
|
|
116
101
|
|
|
117
102
|
sub_tenant_id : typing.Optional[str]
|
|
103
|
+
Optional sub-tenant identifier for organizing data within a tenant. If not provided, defaults to tenant_id
|
|
118
104
|
|
|
119
105
|
max_chunks : typing.Optional[int]
|
|
120
106
|
|
|
@@ -131,11 +117,11 @@ class EmbeddingsClient:
|
|
|
131
117
|
from usecortex-ai import CortexAI
|
|
132
118
|
|
|
133
119
|
client = CortexAI(token="YOUR_TOKEN", )
|
|
134
|
-
client.embeddings.search(
|
|
120
|
+
client.embeddings.search(tenant_id='tenant_id', )
|
|
135
121
|
"""
|
|
136
122
|
_response = self._raw_client.search(
|
|
137
|
-
embeddings=embeddings,
|
|
138
123
|
tenant_id=tenant_id,
|
|
124
|
+
embeddings=embeddings,
|
|
139
125
|
sub_tenant_id=sub_tenant_id,
|
|
140
126
|
max_chunks=max_chunks,
|
|
141
127
|
request_options=request_options,
|
|
@@ -151,20 +137,20 @@ class EmbeddingsClient:
|
|
|
151
137
|
request_options: typing.Optional[RequestOptions] = None,
|
|
152
138
|
) -> EmbeddingsGetData:
|
|
153
139
|
"""
|
|
154
|
-
|
|
140
|
+
Retrieve embeddings for specific chunk IDs.
|
|
155
141
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
Returns:
|
|
159
|
-
EmbeddingsGetData: Embeddings data for the requested chunk IDs
|
|
142
|
+
Use this when you already know the chunk IDs and need their corresponding embeddings.
|
|
160
143
|
|
|
161
144
|
Parameters
|
|
162
145
|
----------
|
|
163
146
|
chunk_ids : typing.Sequence[str]
|
|
147
|
+
The chunk IDs of the source you want to get embeddings for
|
|
164
148
|
|
|
165
149
|
tenant_id : str
|
|
150
|
+
Unique identifier for the tenant/organization
|
|
166
151
|
|
|
167
152
|
sub_tenant_id : typing.Optional[str]
|
|
153
|
+
Optional sub-tenant identifier for organizing data within a tenant. If not provided, defaults to tenant_id
|
|
168
154
|
|
|
169
155
|
request_options : typing.Optional[RequestOptions]
|
|
170
156
|
Request-specific configuration.
|
|
@@ -190,16 +176,14 @@ class EmbeddingsClient:
|
|
|
190
176
|
self, *, tenant_id: str, request_options: typing.Optional[RequestOptions] = None
|
|
191
177
|
) -> EmbeddingsCreateCollectionData:
|
|
192
178
|
"""
|
|
193
|
-
Create an embeddings collection for
|
|
194
|
-
|
|
195
|
-
sub_tenant_id is set to be the same as tenant_id as per requirements.
|
|
179
|
+
Create an embeddings collection for a tenant.
|
|
196
180
|
|
|
197
|
-
|
|
198
|
-
EmbeddingsCreateCollectionData: Success response with collection details
|
|
181
|
+
Use this to initialize storage so you can index and query embeddings for the tenant.
|
|
199
182
|
|
|
200
183
|
Parameters
|
|
201
184
|
----------
|
|
202
185
|
tenant_id : str
|
|
186
|
+
Unique identifier for the tenant/organization
|
|
203
187
|
|
|
204
188
|
request_options : typing.Optional[RequestOptions]
|
|
205
189
|
Request-specific configuration.
|
|
@@ -244,28 +228,20 @@ class AsyncEmbeddingsClient:
|
|
|
244
228
|
request_options: typing.Optional[RequestOptions] = None,
|
|
245
229
|
) -> EmbeddingsDeleteData:
|
|
246
230
|
"""
|
|
247
|
-
Delete
|
|
231
|
+
Delete embedding chunks by chunk ID.
|
|
248
232
|
|
|
249
|
-
|
|
250
|
-
chunk IDs to the backend delete service.
|
|
251
|
-
|
|
252
|
-
Args:
|
|
253
|
-
request (EmbeddingsDeleteRequest): The delete request containing:
|
|
254
|
-
- chunk_ids (List[str]): List of chunk IDs to delete
|
|
255
|
-
- tenant_id (str): Tenant identifier for multi-tenancy
|
|
256
|
-
- sub_tenant_id (str, optional): Sub-tenant identifier, defaults to tenant_id
|
|
257
|
-
api_details (dict): Authentication details obtained from API key validation
|
|
258
|
-
|
|
259
|
-
Returns:
|
|
260
|
-
EmbeddingsDeleteData: Success response with deletion details
|
|
233
|
+
Use this to remove specific chunks from your embeddings index when they are no longer valid or should not appear in results.
|
|
261
234
|
|
|
262
235
|
Parameters
|
|
263
236
|
----------
|
|
264
237
|
chunk_ids : typing.Sequence[str]
|
|
238
|
+
The chunk IDs of the source you want to delete
|
|
265
239
|
|
|
266
240
|
tenant_id : str
|
|
241
|
+
Unique identifier for the tenant/organization
|
|
267
242
|
|
|
268
243
|
sub_tenant_id : typing.Optional[str]
|
|
244
|
+
Optional sub-tenant identifier for organizing data within a tenant. If not provided, defaults to tenant_id
|
|
269
245
|
|
|
270
246
|
request_options : typing.Optional[RequestOptions]
|
|
271
247
|
Request-specific configuration.
|
|
@@ -294,37 +270,31 @@ class AsyncEmbeddingsClient:
|
|
|
294
270
|
async def search(
|
|
295
271
|
self,
|
|
296
272
|
*,
|
|
297
|
-
embeddings: typing.Sequence[float],
|
|
298
273
|
tenant_id: str,
|
|
274
|
+
embeddings: typing.Optional[typing.Sequence[float]] = OMIT,
|
|
299
275
|
sub_tenant_id: typing.Optional[str] = OMIT,
|
|
300
276
|
max_chunks: typing.Optional[int] = OMIT,
|
|
301
277
|
request_options: typing.Optional[RequestOptions] = None,
|
|
302
278
|
) -> EmbeddingsSearchData:
|
|
303
279
|
"""
|
|
304
|
-
|
|
280
|
+
Find similar chunks using an embedding vector.
|
|
305
281
|
|
|
306
|
-
|
|
307
|
-
and returns a list of the most similar chunk IDs based on vector similarity.
|
|
282
|
+
Use this to retrieve the most similar chunk IDs to a single query embedding.
|
|
308
283
|
|
|
309
|
-
Args:
|
|
310
|
-
request (EmbeddingsSearchRequest): The search request containing:
|
|
311
|
-
- embeddings (List[float]): Single embedding vector for similarity search
|
|
312
|
-
- tenant_id (str): Tenant identifier for multi-tenancy
|
|
313
|
-
- sub_tenant_id (str, optional): Sub-tenant identifier, defaults to tenant_id
|
|
314
|
-
- max_chunks (int, optional): Maximum number of chunk IDs to return (default: 10)
|
|
315
|
-
api_details (dict): Authentication details obtained from API key validation
|
|
316
284
|
|
|
317
|
-
|
|
318
|
-
|
|
285
|
+
Expected outcome
|
|
286
|
+
- You receive the closest chunk IDs with optional similarity scores.
|
|
319
287
|
|
|
320
288
|
Parameters
|
|
321
289
|
----------
|
|
322
|
-
embeddings : typing.Sequence[float]
|
|
323
|
-
Single embedding vector for search
|
|
324
|
-
|
|
325
290
|
tenant_id : str
|
|
291
|
+
Unique identifier for the tenant/organization
|
|
292
|
+
|
|
293
|
+
embeddings : typing.Optional[typing.Sequence[float]]
|
|
294
|
+
The embedding vector for search
|
|
326
295
|
|
|
327
296
|
sub_tenant_id : typing.Optional[str]
|
|
297
|
+
Optional sub-tenant identifier for organizing data within a tenant. If not provided, defaults to tenant_id
|
|
328
298
|
|
|
329
299
|
max_chunks : typing.Optional[int]
|
|
330
300
|
|
|
@@ -344,12 +314,12 @@ class AsyncEmbeddingsClient:
|
|
|
344
314
|
|
|
345
315
|
client = AsyncCortexAI(token="YOUR_TOKEN", )
|
|
346
316
|
async def main() -> None:
|
|
347
|
-
await client.embeddings.search(
|
|
317
|
+
await client.embeddings.search(tenant_id='tenant_id', )
|
|
348
318
|
asyncio.run(main())
|
|
349
319
|
"""
|
|
350
320
|
_response = await self._raw_client.search(
|
|
351
|
-
embeddings=embeddings,
|
|
352
321
|
tenant_id=tenant_id,
|
|
322
|
+
embeddings=embeddings,
|
|
353
323
|
sub_tenant_id=sub_tenant_id,
|
|
354
324
|
max_chunks=max_chunks,
|
|
355
325
|
request_options=request_options,
|
|
@@ -365,20 +335,20 @@ class AsyncEmbeddingsClient:
|
|
|
365
335
|
request_options: typing.Optional[RequestOptions] = None,
|
|
366
336
|
) -> EmbeddingsGetData:
|
|
367
337
|
"""
|
|
368
|
-
|
|
338
|
+
Retrieve embeddings for specific chunk IDs.
|
|
369
339
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
Returns:
|
|
373
|
-
EmbeddingsGetData: Embeddings data for the requested chunk IDs
|
|
340
|
+
Use this when you already know the chunk IDs and need their corresponding embeddings.
|
|
374
341
|
|
|
375
342
|
Parameters
|
|
376
343
|
----------
|
|
377
344
|
chunk_ids : typing.Sequence[str]
|
|
345
|
+
The chunk IDs of the source you want to get embeddings for
|
|
378
346
|
|
|
379
347
|
tenant_id : str
|
|
348
|
+
Unique identifier for the tenant/organization
|
|
380
349
|
|
|
381
350
|
sub_tenant_id : typing.Optional[str]
|
|
351
|
+
Optional sub-tenant identifier for organizing data within a tenant. If not provided, defaults to tenant_id
|
|
382
352
|
|
|
383
353
|
request_options : typing.Optional[RequestOptions]
|
|
384
354
|
Request-specific configuration.
|
|
@@ -408,16 +378,14 @@ class AsyncEmbeddingsClient:
|
|
|
408
378
|
self, *, tenant_id: str, request_options: typing.Optional[RequestOptions] = None
|
|
409
379
|
) -> EmbeddingsCreateCollectionData:
|
|
410
380
|
"""
|
|
411
|
-
Create an embeddings collection for
|
|
412
|
-
|
|
413
|
-
sub_tenant_id is set to be the same as tenant_id as per requirements.
|
|
381
|
+
Create an embeddings collection for a tenant.
|
|
414
382
|
|
|
415
|
-
|
|
416
|
-
EmbeddingsCreateCollectionData: Success response with collection details
|
|
383
|
+
Use this to initialize storage so you can index and query embeddings for the tenant.
|
|
417
384
|
|
|
418
385
|
Parameters
|
|
419
386
|
----------
|
|
420
387
|
tenant_id : str
|
|
388
|
+
Unique identifier for the tenant/organization
|
|
421
389
|
|
|
422
390
|
request_options : typing.Optional[RequestOptions]
|
|
423
391
|
Request-specific configuration.
|