hydra-db-python 0.1.0__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.
- hydra_db/__init__.py +160 -0
- hydra_db/client.py +245 -0
- hydra_db/core/__init__.py +52 -0
- hydra_db/core/api_error.py +23 -0
- hydra_db/core/client_wrapper.py +84 -0
- hydra_db/core/datetime_utils.py +28 -0
- hydra_db/core/file.py +67 -0
- hydra_db/core/force_multipart.py +18 -0
- hydra_db/core/http_client.py +543 -0
- hydra_db/core/http_response.py +55 -0
- hydra_db/core/jsonable_encoder.py +100 -0
- hydra_db/core/pydantic_utilities.py +258 -0
- hydra_db/core/query_encoder.py +58 -0
- hydra_db/core/remove_none_from_dict.py +11 -0
- hydra_db/core/request_options.py +35 -0
- hydra_db/core/serialization.py +276 -0
- hydra_db/data/__init__.py +4 -0
- hydra_db/data/client.py +123 -0
- hydra_db/data/raw_client.py +295 -0
- hydra_db/embeddings/__init__.py +4 -0
- hydra_db/embeddings/client.py +486 -0
- hydra_db/embeddings/raw_client.py +1183 -0
- hydra_db/environment.py +7 -0
- hydra_db/errors/__init__.py +23 -0
- hydra_db/errors/bad_request_error.py +10 -0
- hydra_db/errors/forbidden_error.py +10 -0
- hydra_db/errors/internal_server_error.py +10 -0
- hydra_db/errors/not_found_error.py +10 -0
- hydra_db/errors/service_unavailable_error.py +10 -0
- hydra_db/errors/too_many_requests_error.py +11 -0
- hydra_db/errors/unauthorized_error.py +10 -0
- hydra_db/errors/unprocessable_entity_error.py +10 -0
- hydra_db/fetch/__init__.py +7 -0
- hydra_db/fetch/client.py +408 -0
- hydra_db/fetch/raw_client.py +927 -0
- hydra_db/fetch/types/__init__.py +7 -0
- hydra_db/fetch/types/fetch_list_data_response.py +8 -0
- hydra_db/key/__init__.py +4 -0
- hydra_db/key/client.py +135 -0
- hydra_db/key/raw_client.py +309 -0
- hydra_db/raw_client.py +92 -0
- hydra_db/recall/__init__.py +4 -0
- hydra_db/recall/client.py +699 -0
- hydra_db/recall/raw_client.py +1490 -0
- hydra_db/tenant/__init__.py +4 -0
- hydra_db/tenant/client.py +380 -0
- hydra_db/tenant/raw_client.py +1259 -0
- hydra_db/types/__init__.py +125 -0
- hydra_db/types/actual_error_response.py +20 -0
- hydra_db/types/add_memory_response.py +39 -0
- hydra_db/types/alpha.py +5 -0
- hydra_db/types/api_key_create_response.py +48 -0
- hydra_db/types/attachment_model.py +53 -0
- hydra_db/types/batch_processing_status.py +23 -0
- hydra_db/types/bm_25_operator_type.py +5 -0
- hydra_db/types/collection_stats.py +27 -0
- hydra_db/types/content_filter.py +49 -0
- hydra_db/types/content_model.py +53 -0
- hydra_db/types/custom_property_definition.py +75 -0
- hydra_db/types/delete_result.py +36 -0
- hydra_db/types/delete_user_memory_response.py +31 -0
- hydra_db/types/entity.py +42 -0
- hydra_db/types/error_response.py +21 -0
- hydra_db/types/fetch_mode.py +5 -0
- hydra_db/types/forceful_relations_payload.py +27 -0
- hydra_db/types/graph_context.py +26 -0
- hydra_db/types/infra.py +21 -0
- hydra_db/types/infra_status_response.py +42 -0
- hydra_db/types/insert_result.py +41 -0
- hydra_db/types/list_content_kind.py +5 -0
- hydra_db/types/list_user_memories_response.py +43 -0
- hydra_db/types/memory_item.py +88 -0
- hydra_db/types/memory_result_item.py +47 -0
- hydra_db/types/milvus_data_type.py +21 -0
- hydra_db/types/pagination_meta.py +51 -0
- hydra_db/types/path_triplet.py +23 -0
- hydra_db/types/processing_status.py +43 -0
- hydra_db/types/processing_status_indexing_status.py +7 -0
- hydra_db/types/qn_a_search_response.py +49 -0
- hydra_db/types/raw_embedding_document.py +47 -0
- hydra_db/types/raw_embedding_search_result.py +47 -0
- hydra_db/types/raw_embedding_vector.py +31 -0
- hydra_db/types/recall_search_request.py +78 -0
- hydra_db/types/relation_evidence.py +72 -0
- hydra_db/types/retrieval_result.py +36 -0
- hydra_db/types/retrieve_mode.py +5 -0
- hydra_db/types/scored_path_response.py +31 -0
- hydra_db/types/search_mode.py +5 -0
- hydra_db/types/source_delete_response.py +30 -0
- hydra_db/types/source_delete_result_item.py +36 -0
- hydra_db/types/source_fetch_response.py +70 -0
- hydra_db/types/source_graph_relations_response.py +33 -0
- hydra_db/types/source_info.py +57 -0
- hydra_db/types/source_list_response.py +32 -0
- hydra_db/types/source_model.py +99 -0
- hydra_db/types/source_status.py +5 -0
- hydra_db/types/source_upload_response.py +35 -0
- hydra_db/types/source_upload_result_item.py +38 -0
- hydra_db/types/sub_tenant_ids_response.py +31 -0
- hydra_db/types/supported_llm_providers.py +5 -0
- hydra_db/types/tenant_create_accepted_response.py +36 -0
- hydra_db/types/tenant_delete_response.py +25 -0
- hydra_db/types/tenant_stats_response.py +38 -0
- hydra_db/types/triplet_with_evidence.py +35 -0
- hydra_db/types/user_assistant_pair.py +31 -0
- hydra_db/types/user_memory.py +31 -0
- hydra_db/types/vector_store_chunk.py +77 -0
- hydra_db/upload/__init__.py +4 -0
- hydra_db/upload/client.py +452 -0
- hydra_db/upload/raw_client.py +1147 -0
- hydra_db_python-0.1.0.dist-info/METADATA +229 -0
- hydra_db_python-0.1.0.dist-info/RECORD +115 -0
- hydra_db_python-0.1.0.dist-info/WHEEL +5 -0
- hydra_db_python-0.1.0.dist-info/licenses/LICENSE +22 -0
- hydra_db_python-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1183 @@
|
|
|
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 ..core.serialization import convert_and_respect_annotation_metadata
|
|
12
|
+
from ..errors.bad_request_error import BadRequestError
|
|
13
|
+
from ..errors.forbidden_error import ForbiddenError
|
|
14
|
+
from ..errors.internal_server_error import InternalServerError
|
|
15
|
+
from ..errors.not_found_error import NotFoundError
|
|
16
|
+
from ..errors.service_unavailable_error import ServiceUnavailableError
|
|
17
|
+
from ..errors.unauthorized_error import UnauthorizedError
|
|
18
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
19
|
+
from ..types.delete_result import DeleteResult
|
|
20
|
+
from ..types.insert_result import InsertResult
|
|
21
|
+
from ..types.raw_embedding_document import RawEmbeddingDocument
|
|
22
|
+
from ..types.raw_embedding_search_result import RawEmbeddingSearchResult
|
|
23
|
+
|
|
24
|
+
# this is used as the default value for optional parameters
|
|
25
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class RawEmbeddingsClient:
|
|
29
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
30
|
+
self._client_wrapper = client_wrapper
|
|
31
|
+
|
|
32
|
+
def insert(
|
|
33
|
+
self,
|
|
34
|
+
*,
|
|
35
|
+
tenant_id: str,
|
|
36
|
+
embeddings: typing.Sequence[RawEmbeddingDocument],
|
|
37
|
+
sub_tenant_id: typing.Optional[str] = OMIT,
|
|
38
|
+
upsert: typing.Optional[bool] = OMIT,
|
|
39
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
40
|
+
) -> HttpResponse[InsertResult]:
|
|
41
|
+
"""
|
|
42
|
+
Parameters
|
|
43
|
+
----------
|
|
44
|
+
tenant_id : str
|
|
45
|
+
Unique identifier for the tenant/organization
|
|
46
|
+
|
|
47
|
+
embeddings : typing.Sequence[RawEmbeddingDocument]
|
|
48
|
+
List of raw embedding documents to insert
|
|
49
|
+
|
|
50
|
+
sub_tenant_id : typing.Optional[str]
|
|
51
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
52
|
+
|
|
53
|
+
upsert : typing.Optional[bool]
|
|
54
|
+
If True, update existing embeddings; if False, insert only
|
|
55
|
+
|
|
56
|
+
request_options : typing.Optional[RequestOptions]
|
|
57
|
+
Request-specific configuration.
|
|
58
|
+
|
|
59
|
+
Returns
|
|
60
|
+
-------
|
|
61
|
+
HttpResponse[InsertResult]
|
|
62
|
+
Successful Response
|
|
63
|
+
"""
|
|
64
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
65
|
+
"embeddings/insert_raw_embeddings",
|
|
66
|
+
method="POST",
|
|
67
|
+
json={
|
|
68
|
+
"tenant_id": tenant_id,
|
|
69
|
+
"sub_tenant_id": sub_tenant_id,
|
|
70
|
+
"embeddings": convert_and_respect_annotation_metadata(
|
|
71
|
+
object_=embeddings, annotation=typing.Sequence[RawEmbeddingDocument], direction="write"
|
|
72
|
+
),
|
|
73
|
+
"upsert": upsert,
|
|
74
|
+
},
|
|
75
|
+
headers={
|
|
76
|
+
"content-type": "application/json",
|
|
77
|
+
},
|
|
78
|
+
request_options=request_options,
|
|
79
|
+
omit=OMIT,
|
|
80
|
+
)
|
|
81
|
+
try:
|
|
82
|
+
if 200 <= _response.status_code < 300:
|
|
83
|
+
_data = typing.cast(
|
|
84
|
+
InsertResult,
|
|
85
|
+
parse_obj_as(
|
|
86
|
+
type_=InsertResult, # type: ignore
|
|
87
|
+
object_=_response.json(),
|
|
88
|
+
),
|
|
89
|
+
)
|
|
90
|
+
return HttpResponse(response=_response, data=_data)
|
|
91
|
+
if _response.status_code == 400:
|
|
92
|
+
raise BadRequestError(
|
|
93
|
+
headers=dict(_response.headers),
|
|
94
|
+
body=typing.cast(
|
|
95
|
+
typing.Optional[typing.Any],
|
|
96
|
+
parse_obj_as(
|
|
97
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
98
|
+
object_=_response.json(),
|
|
99
|
+
),
|
|
100
|
+
),
|
|
101
|
+
)
|
|
102
|
+
if _response.status_code == 401:
|
|
103
|
+
raise UnauthorizedError(
|
|
104
|
+
headers=dict(_response.headers),
|
|
105
|
+
body=typing.cast(
|
|
106
|
+
typing.Optional[typing.Any],
|
|
107
|
+
parse_obj_as(
|
|
108
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
109
|
+
object_=_response.json(),
|
|
110
|
+
),
|
|
111
|
+
),
|
|
112
|
+
)
|
|
113
|
+
if _response.status_code == 403:
|
|
114
|
+
raise ForbiddenError(
|
|
115
|
+
headers=dict(_response.headers),
|
|
116
|
+
body=typing.cast(
|
|
117
|
+
typing.Optional[typing.Any],
|
|
118
|
+
parse_obj_as(
|
|
119
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
120
|
+
object_=_response.json(),
|
|
121
|
+
),
|
|
122
|
+
),
|
|
123
|
+
)
|
|
124
|
+
if _response.status_code == 404:
|
|
125
|
+
raise NotFoundError(
|
|
126
|
+
headers=dict(_response.headers),
|
|
127
|
+
body=typing.cast(
|
|
128
|
+
typing.Optional[typing.Any],
|
|
129
|
+
parse_obj_as(
|
|
130
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
131
|
+
object_=_response.json(),
|
|
132
|
+
),
|
|
133
|
+
),
|
|
134
|
+
)
|
|
135
|
+
if _response.status_code == 422:
|
|
136
|
+
raise UnprocessableEntityError(
|
|
137
|
+
headers=dict(_response.headers),
|
|
138
|
+
body=typing.cast(
|
|
139
|
+
typing.Optional[typing.Any],
|
|
140
|
+
parse_obj_as(
|
|
141
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
142
|
+
object_=_response.json(),
|
|
143
|
+
),
|
|
144
|
+
),
|
|
145
|
+
)
|
|
146
|
+
if _response.status_code == 500:
|
|
147
|
+
raise InternalServerError(
|
|
148
|
+
headers=dict(_response.headers),
|
|
149
|
+
body=typing.cast(
|
|
150
|
+
typing.Optional[typing.Any],
|
|
151
|
+
parse_obj_as(
|
|
152
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
153
|
+
object_=_response.json(),
|
|
154
|
+
),
|
|
155
|
+
),
|
|
156
|
+
)
|
|
157
|
+
if _response.status_code == 503:
|
|
158
|
+
raise ServiceUnavailableError(
|
|
159
|
+
headers=dict(_response.headers),
|
|
160
|
+
body=typing.cast(
|
|
161
|
+
typing.Optional[typing.Any],
|
|
162
|
+
parse_obj_as(
|
|
163
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
164
|
+
object_=_response.json(),
|
|
165
|
+
),
|
|
166
|
+
),
|
|
167
|
+
)
|
|
168
|
+
_response_json = _response.json()
|
|
169
|
+
except JSONDecodeError:
|
|
170
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
171
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
172
|
+
|
|
173
|
+
def search(
|
|
174
|
+
self,
|
|
175
|
+
*,
|
|
176
|
+
tenant_id: str,
|
|
177
|
+
sub_tenant_id: str,
|
|
178
|
+
query_embedding: typing.Sequence[float],
|
|
179
|
+
limit: typing.Optional[int] = OMIT,
|
|
180
|
+
filter_expr: typing.Optional[str] = OMIT,
|
|
181
|
+
output_fields: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
182
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
183
|
+
) -> HttpResponse[typing.List[RawEmbeddingSearchResult]]:
|
|
184
|
+
"""
|
|
185
|
+
Parameters
|
|
186
|
+
----------
|
|
187
|
+
tenant_id : str
|
|
188
|
+
Unique identifier for the tenant/organization
|
|
189
|
+
|
|
190
|
+
sub_tenant_id : str
|
|
191
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
192
|
+
|
|
193
|
+
query_embedding : typing.Sequence[float]
|
|
194
|
+
Query embedding vector to search for
|
|
195
|
+
|
|
196
|
+
limit : typing.Optional[int]
|
|
197
|
+
Maximum number of results to return
|
|
198
|
+
|
|
199
|
+
filter_expr : typing.Optional[str]
|
|
200
|
+
Optional Milvus filter expression for additional filtering
|
|
201
|
+
|
|
202
|
+
output_fields : typing.Optional[typing.Sequence[str]]
|
|
203
|
+
Optional list of fields to return in results (default: chunk_id, source_id, metadata)
|
|
204
|
+
|
|
205
|
+
request_options : typing.Optional[RequestOptions]
|
|
206
|
+
Request-specific configuration.
|
|
207
|
+
|
|
208
|
+
Returns
|
|
209
|
+
-------
|
|
210
|
+
HttpResponse[typing.List[RawEmbeddingSearchResult]]
|
|
211
|
+
Successful Response
|
|
212
|
+
"""
|
|
213
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
214
|
+
"embeddings/search_raw_embeddings",
|
|
215
|
+
method="POST",
|
|
216
|
+
json={
|
|
217
|
+
"tenant_id": tenant_id,
|
|
218
|
+
"sub_tenant_id": sub_tenant_id,
|
|
219
|
+
"query_embedding": query_embedding,
|
|
220
|
+
"limit": limit,
|
|
221
|
+
"filter_expr": filter_expr,
|
|
222
|
+
"output_fields": output_fields,
|
|
223
|
+
},
|
|
224
|
+
headers={
|
|
225
|
+
"content-type": "application/json",
|
|
226
|
+
},
|
|
227
|
+
request_options=request_options,
|
|
228
|
+
omit=OMIT,
|
|
229
|
+
)
|
|
230
|
+
try:
|
|
231
|
+
if 200 <= _response.status_code < 300:
|
|
232
|
+
_data = typing.cast(
|
|
233
|
+
typing.List[RawEmbeddingSearchResult],
|
|
234
|
+
parse_obj_as(
|
|
235
|
+
type_=typing.List[RawEmbeddingSearchResult], # type: ignore
|
|
236
|
+
object_=_response.json(),
|
|
237
|
+
),
|
|
238
|
+
)
|
|
239
|
+
return HttpResponse(response=_response, data=_data)
|
|
240
|
+
if _response.status_code == 400:
|
|
241
|
+
raise BadRequestError(
|
|
242
|
+
headers=dict(_response.headers),
|
|
243
|
+
body=typing.cast(
|
|
244
|
+
typing.Optional[typing.Any],
|
|
245
|
+
parse_obj_as(
|
|
246
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
247
|
+
object_=_response.json(),
|
|
248
|
+
),
|
|
249
|
+
),
|
|
250
|
+
)
|
|
251
|
+
if _response.status_code == 401:
|
|
252
|
+
raise UnauthorizedError(
|
|
253
|
+
headers=dict(_response.headers),
|
|
254
|
+
body=typing.cast(
|
|
255
|
+
typing.Optional[typing.Any],
|
|
256
|
+
parse_obj_as(
|
|
257
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
258
|
+
object_=_response.json(),
|
|
259
|
+
),
|
|
260
|
+
),
|
|
261
|
+
)
|
|
262
|
+
if _response.status_code == 403:
|
|
263
|
+
raise ForbiddenError(
|
|
264
|
+
headers=dict(_response.headers),
|
|
265
|
+
body=typing.cast(
|
|
266
|
+
typing.Optional[typing.Any],
|
|
267
|
+
parse_obj_as(
|
|
268
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
269
|
+
object_=_response.json(),
|
|
270
|
+
),
|
|
271
|
+
),
|
|
272
|
+
)
|
|
273
|
+
if _response.status_code == 404:
|
|
274
|
+
raise NotFoundError(
|
|
275
|
+
headers=dict(_response.headers),
|
|
276
|
+
body=typing.cast(
|
|
277
|
+
typing.Optional[typing.Any],
|
|
278
|
+
parse_obj_as(
|
|
279
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
280
|
+
object_=_response.json(),
|
|
281
|
+
),
|
|
282
|
+
),
|
|
283
|
+
)
|
|
284
|
+
if _response.status_code == 422:
|
|
285
|
+
raise UnprocessableEntityError(
|
|
286
|
+
headers=dict(_response.headers),
|
|
287
|
+
body=typing.cast(
|
|
288
|
+
typing.Optional[typing.Any],
|
|
289
|
+
parse_obj_as(
|
|
290
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
291
|
+
object_=_response.json(),
|
|
292
|
+
),
|
|
293
|
+
),
|
|
294
|
+
)
|
|
295
|
+
if _response.status_code == 500:
|
|
296
|
+
raise InternalServerError(
|
|
297
|
+
headers=dict(_response.headers),
|
|
298
|
+
body=typing.cast(
|
|
299
|
+
typing.Optional[typing.Any],
|
|
300
|
+
parse_obj_as(
|
|
301
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
302
|
+
object_=_response.json(),
|
|
303
|
+
),
|
|
304
|
+
),
|
|
305
|
+
)
|
|
306
|
+
if _response.status_code == 503:
|
|
307
|
+
raise ServiceUnavailableError(
|
|
308
|
+
headers=dict(_response.headers),
|
|
309
|
+
body=typing.cast(
|
|
310
|
+
typing.Optional[typing.Any],
|
|
311
|
+
parse_obj_as(
|
|
312
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
313
|
+
object_=_response.json(),
|
|
314
|
+
),
|
|
315
|
+
),
|
|
316
|
+
)
|
|
317
|
+
_response_json = _response.json()
|
|
318
|
+
except JSONDecodeError:
|
|
319
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
320
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
321
|
+
|
|
322
|
+
def filter(
|
|
323
|
+
self,
|
|
324
|
+
*,
|
|
325
|
+
tenant_id: str,
|
|
326
|
+
sub_tenant_id: str,
|
|
327
|
+
source_id: typing.Optional[str] = OMIT,
|
|
328
|
+
chunk_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
329
|
+
output_fields: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
330
|
+
limit: typing.Optional[int] = OMIT,
|
|
331
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
332
|
+
) -> HttpResponse[typing.List[RawEmbeddingSearchResult]]:
|
|
333
|
+
"""
|
|
334
|
+
Parameters
|
|
335
|
+
----------
|
|
336
|
+
tenant_id : str
|
|
337
|
+
Unique identifier for the tenant/organization
|
|
338
|
+
|
|
339
|
+
sub_tenant_id : str
|
|
340
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
341
|
+
|
|
342
|
+
source_id : typing.Optional[str]
|
|
343
|
+
Optional source ID to filter by (mutually exclusive with chunk_ids)
|
|
344
|
+
|
|
345
|
+
chunk_ids : typing.Optional[typing.Sequence[str]]
|
|
346
|
+
Optional list of chunk IDs to filter by (mutually exclusive with source_id)
|
|
347
|
+
|
|
348
|
+
output_fields : typing.Optional[typing.Sequence[str]]
|
|
349
|
+
Optional list of fields to return in results (default: chunk_id, source_id, metadata)
|
|
350
|
+
|
|
351
|
+
limit : typing.Optional[int]
|
|
352
|
+
Maximum number of results to return
|
|
353
|
+
|
|
354
|
+
request_options : typing.Optional[RequestOptions]
|
|
355
|
+
Request-specific configuration.
|
|
356
|
+
|
|
357
|
+
Returns
|
|
358
|
+
-------
|
|
359
|
+
HttpResponse[typing.List[RawEmbeddingSearchResult]]
|
|
360
|
+
Successful Response
|
|
361
|
+
"""
|
|
362
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
363
|
+
"embeddings/filter_raw_embeddings",
|
|
364
|
+
method="POST",
|
|
365
|
+
json={
|
|
366
|
+
"tenant_id": tenant_id,
|
|
367
|
+
"sub_tenant_id": sub_tenant_id,
|
|
368
|
+
"source_id": source_id,
|
|
369
|
+
"chunk_ids": chunk_ids,
|
|
370
|
+
"output_fields": output_fields,
|
|
371
|
+
"limit": limit,
|
|
372
|
+
},
|
|
373
|
+
headers={
|
|
374
|
+
"content-type": "application/json",
|
|
375
|
+
},
|
|
376
|
+
request_options=request_options,
|
|
377
|
+
omit=OMIT,
|
|
378
|
+
)
|
|
379
|
+
try:
|
|
380
|
+
if 200 <= _response.status_code < 300:
|
|
381
|
+
_data = typing.cast(
|
|
382
|
+
typing.List[RawEmbeddingSearchResult],
|
|
383
|
+
parse_obj_as(
|
|
384
|
+
type_=typing.List[RawEmbeddingSearchResult], # type: ignore
|
|
385
|
+
object_=_response.json(),
|
|
386
|
+
),
|
|
387
|
+
)
|
|
388
|
+
return HttpResponse(response=_response, data=_data)
|
|
389
|
+
if _response.status_code == 400:
|
|
390
|
+
raise BadRequestError(
|
|
391
|
+
headers=dict(_response.headers),
|
|
392
|
+
body=typing.cast(
|
|
393
|
+
typing.Optional[typing.Any],
|
|
394
|
+
parse_obj_as(
|
|
395
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
396
|
+
object_=_response.json(),
|
|
397
|
+
),
|
|
398
|
+
),
|
|
399
|
+
)
|
|
400
|
+
if _response.status_code == 401:
|
|
401
|
+
raise UnauthorizedError(
|
|
402
|
+
headers=dict(_response.headers),
|
|
403
|
+
body=typing.cast(
|
|
404
|
+
typing.Optional[typing.Any],
|
|
405
|
+
parse_obj_as(
|
|
406
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
407
|
+
object_=_response.json(),
|
|
408
|
+
),
|
|
409
|
+
),
|
|
410
|
+
)
|
|
411
|
+
if _response.status_code == 403:
|
|
412
|
+
raise ForbiddenError(
|
|
413
|
+
headers=dict(_response.headers),
|
|
414
|
+
body=typing.cast(
|
|
415
|
+
typing.Optional[typing.Any],
|
|
416
|
+
parse_obj_as(
|
|
417
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
418
|
+
object_=_response.json(),
|
|
419
|
+
),
|
|
420
|
+
),
|
|
421
|
+
)
|
|
422
|
+
if _response.status_code == 404:
|
|
423
|
+
raise NotFoundError(
|
|
424
|
+
headers=dict(_response.headers),
|
|
425
|
+
body=typing.cast(
|
|
426
|
+
typing.Optional[typing.Any],
|
|
427
|
+
parse_obj_as(
|
|
428
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
429
|
+
object_=_response.json(),
|
|
430
|
+
),
|
|
431
|
+
),
|
|
432
|
+
)
|
|
433
|
+
if _response.status_code == 422:
|
|
434
|
+
raise UnprocessableEntityError(
|
|
435
|
+
headers=dict(_response.headers),
|
|
436
|
+
body=typing.cast(
|
|
437
|
+
typing.Optional[typing.Any],
|
|
438
|
+
parse_obj_as(
|
|
439
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
440
|
+
object_=_response.json(),
|
|
441
|
+
),
|
|
442
|
+
),
|
|
443
|
+
)
|
|
444
|
+
if _response.status_code == 500:
|
|
445
|
+
raise InternalServerError(
|
|
446
|
+
headers=dict(_response.headers),
|
|
447
|
+
body=typing.cast(
|
|
448
|
+
typing.Optional[typing.Any],
|
|
449
|
+
parse_obj_as(
|
|
450
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
451
|
+
object_=_response.json(),
|
|
452
|
+
),
|
|
453
|
+
),
|
|
454
|
+
)
|
|
455
|
+
if _response.status_code == 503:
|
|
456
|
+
raise ServiceUnavailableError(
|
|
457
|
+
headers=dict(_response.headers),
|
|
458
|
+
body=typing.cast(
|
|
459
|
+
typing.Optional[typing.Any],
|
|
460
|
+
parse_obj_as(
|
|
461
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
462
|
+
object_=_response.json(),
|
|
463
|
+
),
|
|
464
|
+
),
|
|
465
|
+
)
|
|
466
|
+
_response_json = _response.json()
|
|
467
|
+
except JSONDecodeError:
|
|
468
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
469
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
470
|
+
|
|
471
|
+
def delete(
|
|
472
|
+
self,
|
|
473
|
+
*,
|
|
474
|
+
tenant_id: str,
|
|
475
|
+
sub_tenant_id: typing.Optional[str] = None,
|
|
476
|
+
source_id: typing.Optional[str] = None,
|
|
477
|
+
chunk_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
478
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
479
|
+
) -> HttpResponse[DeleteResult]:
|
|
480
|
+
"""
|
|
481
|
+
Parameters
|
|
482
|
+
----------
|
|
483
|
+
tenant_id : str
|
|
484
|
+
Unique identifier for the tenant/organization
|
|
485
|
+
|
|
486
|
+
sub_tenant_id : typing.Optional[str]
|
|
487
|
+
Optional sub-tenant ID for scoping deletion
|
|
488
|
+
|
|
489
|
+
source_id : typing.Optional[str]
|
|
490
|
+
Optional source ID to delete by (mutually exclusive with chunk_ids)
|
|
491
|
+
|
|
492
|
+
chunk_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
493
|
+
Optional list of chunk IDs to delete (mutually exclusive with source_id)
|
|
494
|
+
|
|
495
|
+
request_options : typing.Optional[RequestOptions]
|
|
496
|
+
Request-specific configuration.
|
|
497
|
+
|
|
498
|
+
Returns
|
|
499
|
+
-------
|
|
500
|
+
HttpResponse[DeleteResult]
|
|
501
|
+
Successful Response
|
|
502
|
+
"""
|
|
503
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
504
|
+
"embeddings/delete_raw_embeddings",
|
|
505
|
+
method="DELETE",
|
|
506
|
+
params={
|
|
507
|
+
"tenant_id": tenant_id,
|
|
508
|
+
"sub_tenant_id": sub_tenant_id,
|
|
509
|
+
"source_id": source_id,
|
|
510
|
+
"chunk_ids": chunk_ids,
|
|
511
|
+
},
|
|
512
|
+
request_options=request_options,
|
|
513
|
+
)
|
|
514
|
+
try:
|
|
515
|
+
if 200 <= _response.status_code < 300:
|
|
516
|
+
_data = typing.cast(
|
|
517
|
+
DeleteResult,
|
|
518
|
+
parse_obj_as(
|
|
519
|
+
type_=DeleteResult, # type: ignore
|
|
520
|
+
object_=_response.json(),
|
|
521
|
+
),
|
|
522
|
+
)
|
|
523
|
+
return HttpResponse(response=_response, data=_data)
|
|
524
|
+
if _response.status_code == 400:
|
|
525
|
+
raise BadRequestError(
|
|
526
|
+
headers=dict(_response.headers),
|
|
527
|
+
body=typing.cast(
|
|
528
|
+
typing.Optional[typing.Any],
|
|
529
|
+
parse_obj_as(
|
|
530
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
531
|
+
object_=_response.json(),
|
|
532
|
+
),
|
|
533
|
+
),
|
|
534
|
+
)
|
|
535
|
+
if _response.status_code == 401:
|
|
536
|
+
raise UnauthorizedError(
|
|
537
|
+
headers=dict(_response.headers),
|
|
538
|
+
body=typing.cast(
|
|
539
|
+
typing.Optional[typing.Any],
|
|
540
|
+
parse_obj_as(
|
|
541
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
542
|
+
object_=_response.json(),
|
|
543
|
+
),
|
|
544
|
+
),
|
|
545
|
+
)
|
|
546
|
+
if _response.status_code == 403:
|
|
547
|
+
raise ForbiddenError(
|
|
548
|
+
headers=dict(_response.headers),
|
|
549
|
+
body=typing.cast(
|
|
550
|
+
typing.Optional[typing.Any],
|
|
551
|
+
parse_obj_as(
|
|
552
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
553
|
+
object_=_response.json(),
|
|
554
|
+
),
|
|
555
|
+
),
|
|
556
|
+
)
|
|
557
|
+
if _response.status_code == 404:
|
|
558
|
+
raise NotFoundError(
|
|
559
|
+
headers=dict(_response.headers),
|
|
560
|
+
body=typing.cast(
|
|
561
|
+
typing.Optional[typing.Any],
|
|
562
|
+
parse_obj_as(
|
|
563
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
564
|
+
object_=_response.json(),
|
|
565
|
+
),
|
|
566
|
+
),
|
|
567
|
+
)
|
|
568
|
+
if _response.status_code == 422:
|
|
569
|
+
raise UnprocessableEntityError(
|
|
570
|
+
headers=dict(_response.headers),
|
|
571
|
+
body=typing.cast(
|
|
572
|
+
typing.Optional[typing.Any],
|
|
573
|
+
parse_obj_as(
|
|
574
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
575
|
+
object_=_response.json(),
|
|
576
|
+
),
|
|
577
|
+
),
|
|
578
|
+
)
|
|
579
|
+
if _response.status_code == 500:
|
|
580
|
+
raise InternalServerError(
|
|
581
|
+
headers=dict(_response.headers),
|
|
582
|
+
body=typing.cast(
|
|
583
|
+
typing.Optional[typing.Any],
|
|
584
|
+
parse_obj_as(
|
|
585
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
586
|
+
object_=_response.json(),
|
|
587
|
+
),
|
|
588
|
+
),
|
|
589
|
+
)
|
|
590
|
+
if _response.status_code == 503:
|
|
591
|
+
raise ServiceUnavailableError(
|
|
592
|
+
headers=dict(_response.headers),
|
|
593
|
+
body=typing.cast(
|
|
594
|
+
typing.Optional[typing.Any],
|
|
595
|
+
parse_obj_as(
|
|
596
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
597
|
+
object_=_response.json(),
|
|
598
|
+
),
|
|
599
|
+
),
|
|
600
|
+
)
|
|
601
|
+
_response_json = _response.json()
|
|
602
|
+
except JSONDecodeError:
|
|
603
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
604
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
class AsyncRawEmbeddingsClient:
|
|
608
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
609
|
+
self._client_wrapper = client_wrapper
|
|
610
|
+
|
|
611
|
+
async def insert(
|
|
612
|
+
self,
|
|
613
|
+
*,
|
|
614
|
+
tenant_id: str,
|
|
615
|
+
embeddings: typing.Sequence[RawEmbeddingDocument],
|
|
616
|
+
sub_tenant_id: typing.Optional[str] = OMIT,
|
|
617
|
+
upsert: typing.Optional[bool] = OMIT,
|
|
618
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
619
|
+
) -> AsyncHttpResponse[InsertResult]:
|
|
620
|
+
"""
|
|
621
|
+
Parameters
|
|
622
|
+
----------
|
|
623
|
+
tenant_id : str
|
|
624
|
+
Unique identifier for the tenant/organization
|
|
625
|
+
|
|
626
|
+
embeddings : typing.Sequence[RawEmbeddingDocument]
|
|
627
|
+
List of raw embedding documents to insert
|
|
628
|
+
|
|
629
|
+
sub_tenant_id : typing.Optional[str]
|
|
630
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
631
|
+
|
|
632
|
+
upsert : typing.Optional[bool]
|
|
633
|
+
If True, update existing embeddings; if False, insert only
|
|
634
|
+
|
|
635
|
+
request_options : typing.Optional[RequestOptions]
|
|
636
|
+
Request-specific configuration.
|
|
637
|
+
|
|
638
|
+
Returns
|
|
639
|
+
-------
|
|
640
|
+
AsyncHttpResponse[InsertResult]
|
|
641
|
+
Successful Response
|
|
642
|
+
"""
|
|
643
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
644
|
+
"embeddings/insert_raw_embeddings",
|
|
645
|
+
method="POST",
|
|
646
|
+
json={
|
|
647
|
+
"tenant_id": tenant_id,
|
|
648
|
+
"sub_tenant_id": sub_tenant_id,
|
|
649
|
+
"embeddings": convert_and_respect_annotation_metadata(
|
|
650
|
+
object_=embeddings, annotation=typing.Sequence[RawEmbeddingDocument], direction="write"
|
|
651
|
+
),
|
|
652
|
+
"upsert": upsert,
|
|
653
|
+
},
|
|
654
|
+
headers={
|
|
655
|
+
"content-type": "application/json",
|
|
656
|
+
},
|
|
657
|
+
request_options=request_options,
|
|
658
|
+
omit=OMIT,
|
|
659
|
+
)
|
|
660
|
+
try:
|
|
661
|
+
if 200 <= _response.status_code < 300:
|
|
662
|
+
_data = typing.cast(
|
|
663
|
+
InsertResult,
|
|
664
|
+
parse_obj_as(
|
|
665
|
+
type_=InsertResult, # type: ignore
|
|
666
|
+
object_=_response.json(),
|
|
667
|
+
),
|
|
668
|
+
)
|
|
669
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
670
|
+
if _response.status_code == 400:
|
|
671
|
+
raise BadRequestError(
|
|
672
|
+
headers=dict(_response.headers),
|
|
673
|
+
body=typing.cast(
|
|
674
|
+
typing.Optional[typing.Any],
|
|
675
|
+
parse_obj_as(
|
|
676
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
677
|
+
object_=_response.json(),
|
|
678
|
+
),
|
|
679
|
+
),
|
|
680
|
+
)
|
|
681
|
+
if _response.status_code == 401:
|
|
682
|
+
raise UnauthorizedError(
|
|
683
|
+
headers=dict(_response.headers),
|
|
684
|
+
body=typing.cast(
|
|
685
|
+
typing.Optional[typing.Any],
|
|
686
|
+
parse_obj_as(
|
|
687
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
688
|
+
object_=_response.json(),
|
|
689
|
+
),
|
|
690
|
+
),
|
|
691
|
+
)
|
|
692
|
+
if _response.status_code == 403:
|
|
693
|
+
raise ForbiddenError(
|
|
694
|
+
headers=dict(_response.headers),
|
|
695
|
+
body=typing.cast(
|
|
696
|
+
typing.Optional[typing.Any],
|
|
697
|
+
parse_obj_as(
|
|
698
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
699
|
+
object_=_response.json(),
|
|
700
|
+
),
|
|
701
|
+
),
|
|
702
|
+
)
|
|
703
|
+
if _response.status_code == 404:
|
|
704
|
+
raise NotFoundError(
|
|
705
|
+
headers=dict(_response.headers),
|
|
706
|
+
body=typing.cast(
|
|
707
|
+
typing.Optional[typing.Any],
|
|
708
|
+
parse_obj_as(
|
|
709
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
710
|
+
object_=_response.json(),
|
|
711
|
+
),
|
|
712
|
+
),
|
|
713
|
+
)
|
|
714
|
+
if _response.status_code == 422:
|
|
715
|
+
raise UnprocessableEntityError(
|
|
716
|
+
headers=dict(_response.headers),
|
|
717
|
+
body=typing.cast(
|
|
718
|
+
typing.Optional[typing.Any],
|
|
719
|
+
parse_obj_as(
|
|
720
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
721
|
+
object_=_response.json(),
|
|
722
|
+
),
|
|
723
|
+
),
|
|
724
|
+
)
|
|
725
|
+
if _response.status_code == 500:
|
|
726
|
+
raise InternalServerError(
|
|
727
|
+
headers=dict(_response.headers),
|
|
728
|
+
body=typing.cast(
|
|
729
|
+
typing.Optional[typing.Any],
|
|
730
|
+
parse_obj_as(
|
|
731
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
732
|
+
object_=_response.json(),
|
|
733
|
+
),
|
|
734
|
+
),
|
|
735
|
+
)
|
|
736
|
+
if _response.status_code == 503:
|
|
737
|
+
raise ServiceUnavailableError(
|
|
738
|
+
headers=dict(_response.headers),
|
|
739
|
+
body=typing.cast(
|
|
740
|
+
typing.Optional[typing.Any],
|
|
741
|
+
parse_obj_as(
|
|
742
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
743
|
+
object_=_response.json(),
|
|
744
|
+
),
|
|
745
|
+
),
|
|
746
|
+
)
|
|
747
|
+
_response_json = _response.json()
|
|
748
|
+
except JSONDecodeError:
|
|
749
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
750
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
751
|
+
|
|
752
|
+
async def search(
|
|
753
|
+
self,
|
|
754
|
+
*,
|
|
755
|
+
tenant_id: str,
|
|
756
|
+
sub_tenant_id: str,
|
|
757
|
+
query_embedding: typing.Sequence[float],
|
|
758
|
+
limit: typing.Optional[int] = OMIT,
|
|
759
|
+
filter_expr: typing.Optional[str] = OMIT,
|
|
760
|
+
output_fields: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
761
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
762
|
+
) -> AsyncHttpResponse[typing.List[RawEmbeddingSearchResult]]:
|
|
763
|
+
"""
|
|
764
|
+
Parameters
|
|
765
|
+
----------
|
|
766
|
+
tenant_id : str
|
|
767
|
+
Unique identifier for the tenant/organization
|
|
768
|
+
|
|
769
|
+
sub_tenant_id : str
|
|
770
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
771
|
+
|
|
772
|
+
query_embedding : typing.Sequence[float]
|
|
773
|
+
Query embedding vector to search for
|
|
774
|
+
|
|
775
|
+
limit : typing.Optional[int]
|
|
776
|
+
Maximum number of results to return
|
|
777
|
+
|
|
778
|
+
filter_expr : typing.Optional[str]
|
|
779
|
+
Optional Milvus filter expression for additional filtering
|
|
780
|
+
|
|
781
|
+
output_fields : typing.Optional[typing.Sequence[str]]
|
|
782
|
+
Optional list of fields to return in results (default: chunk_id, source_id, metadata)
|
|
783
|
+
|
|
784
|
+
request_options : typing.Optional[RequestOptions]
|
|
785
|
+
Request-specific configuration.
|
|
786
|
+
|
|
787
|
+
Returns
|
|
788
|
+
-------
|
|
789
|
+
AsyncHttpResponse[typing.List[RawEmbeddingSearchResult]]
|
|
790
|
+
Successful Response
|
|
791
|
+
"""
|
|
792
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
793
|
+
"embeddings/search_raw_embeddings",
|
|
794
|
+
method="POST",
|
|
795
|
+
json={
|
|
796
|
+
"tenant_id": tenant_id,
|
|
797
|
+
"sub_tenant_id": sub_tenant_id,
|
|
798
|
+
"query_embedding": query_embedding,
|
|
799
|
+
"limit": limit,
|
|
800
|
+
"filter_expr": filter_expr,
|
|
801
|
+
"output_fields": output_fields,
|
|
802
|
+
},
|
|
803
|
+
headers={
|
|
804
|
+
"content-type": "application/json",
|
|
805
|
+
},
|
|
806
|
+
request_options=request_options,
|
|
807
|
+
omit=OMIT,
|
|
808
|
+
)
|
|
809
|
+
try:
|
|
810
|
+
if 200 <= _response.status_code < 300:
|
|
811
|
+
_data = typing.cast(
|
|
812
|
+
typing.List[RawEmbeddingSearchResult],
|
|
813
|
+
parse_obj_as(
|
|
814
|
+
type_=typing.List[RawEmbeddingSearchResult], # type: ignore
|
|
815
|
+
object_=_response.json(),
|
|
816
|
+
),
|
|
817
|
+
)
|
|
818
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
819
|
+
if _response.status_code == 400:
|
|
820
|
+
raise BadRequestError(
|
|
821
|
+
headers=dict(_response.headers),
|
|
822
|
+
body=typing.cast(
|
|
823
|
+
typing.Optional[typing.Any],
|
|
824
|
+
parse_obj_as(
|
|
825
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
826
|
+
object_=_response.json(),
|
|
827
|
+
),
|
|
828
|
+
),
|
|
829
|
+
)
|
|
830
|
+
if _response.status_code == 401:
|
|
831
|
+
raise UnauthorizedError(
|
|
832
|
+
headers=dict(_response.headers),
|
|
833
|
+
body=typing.cast(
|
|
834
|
+
typing.Optional[typing.Any],
|
|
835
|
+
parse_obj_as(
|
|
836
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
837
|
+
object_=_response.json(),
|
|
838
|
+
),
|
|
839
|
+
),
|
|
840
|
+
)
|
|
841
|
+
if _response.status_code == 403:
|
|
842
|
+
raise ForbiddenError(
|
|
843
|
+
headers=dict(_response.headers),
|
|
844
|
+
body=typing.cast(
|
|
845
|
+
typing.Optional[typing.Any],
|
|
846
|
+
parse_obj_as(
|
|
847
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
848
|
+
object_=_response.json(),
|
|
849
|
+
),
|
|
850
|
+
),
|
|
851
|
+
)
|
|
852
|
+
if _response.status_code == 404:
|
|
853
|
+
raise NotFoundError(
|
|
854
|
+
headers=dict(_response.headers),
|
|
855
|
+
body=typing.cast(
|
|
856
|
+
typing.Optional[typing.Any],
|
|
857
|
+
parse_obj_as(
|
|
858
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
859
|
+
object_=_response.json(),
|
|
860
|
+
),
|
|
861
|
+
),
|
|
862
|
+
)
|
|
863
|
+
if _response.status_code == 422:
|
|
864
|
+
raise UnprocessableEntityError(
|
|
865
|
+
headers=dict(_response.headers),
|
|
866
|
+
body=typing.cast(
|
|
867
|
+
typing.Optional[typing.Any],
|
|
868
|
+
parse_obj_as(
|
|
869
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
870
|
+
object_=_response.json(),
|
|
871
|
+
),
|
|
872
|
+
),
|
|
873
|
+
)
|
|
874
|
+
if _response.status_code == 500:
|
|
875
|
+
raise InternalServerError(
|
|
876
|
+
headers=dict(_response.headers),
|
|
877
|
+
body=typing.cast(
|
|
878
|
+
typing.Optional[typing.Any],
|
|
879
|
+
parse_obj_as(
|
|
880
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
881
|
+
object_=_response.json(),
|
|
882
|
+
),
|
|
883
|
+
),
|
|
884
|
+
)
|
|
885
|
+
if _response.status_code == 503:
|
|
886
|
+
raise ServiceUnavailableError(
|
|
887
|
+
headers=dict(_response.headers),
|
|
888
|
+
body=typing.cast(
|
|
889
|
+
typing.Optional[typing.Any],
|
|
890
|
+
parse_obj_as(
|
|
891
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
892
|
+
object_=_response.json(),
|
|
893
|
+
),
|
|
894
|
+
),
|
|
895
|
+
)
|
|
896
|
+
_response_json = _response.json()
|
|
897
|
+
except JSONDecodeError:
|
|
898
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
899
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
900
|
+
|
|
901
|
+
async def filter(
|
|
902
|
+
self,
|
|
903
|
+
*,
|
|
904
|
+
tenant_id: str,
|
|
905
|
+
sub_tenant_id: str,
|
|
906
|
+
source_id: typing.Optional[str] = OMIT,
|
|
907
|
+
chunk_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
908
|
+
output_fields: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
909
|
+
limit: typing.Optional[int] = OMIT,
|
|
910
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
911
|
+
) -> AsyncHttpResponse[typing.List[RawEmbeddingSearchResult]]:
|
|
912
|
+
"""
|
|
913
|
+
Parameters
|
|
914
|
+
----------
|
|
915
|
+
tenant_id : str
|
|
916
|
+
Unique identifier for the tenant/organization
|
|
917
|
+
|
|
918
|
+
sub_tenant_id : str
|
|
919
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
920
|
+
|
|
921
|
+
source_id : typing.Optional[str]
|
|
922
|
+
Optional source ID to filter by (mutually exclusive with chunk_ids)
|
|
923
|
+
|
|
924
|
+
chunk_ids : typing.Optional[typing.Sequence[str]]
|
|
925
|
+
Optional list of chunk IDs to filter by (mutually exclusive with source_id)
|
|
926
|
+
|
|
927
|
+
output_fields : typing.Optional[typing.Sequence[str]]
|
|
928
|
+
Optional list of fields to return in results (default: chunk_id, source_id, metadata)
|
|
929
|
+
|
|
930
|
+
limit : typing.Optional[int]
|
|
931
|
+
Maximum number of results to return
|
|
932
|
+
|
|
933
|
+
request_options : typing.Optional[RequestOptions]
|
|
934
|
+
Request-specific configuration.
|
|
935
|
+
|
|
936
|
+
Returns
|
|
937
|
+
-------
|
|
938
|
+
AsyncHttpResponse[typing.List[RawEmbeddingSearchResult]]
|
|
939
|
+
Successful Response
|
|
940
|
+
"""
|
|
941
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
942
|
+
"embeddings/filter_raw_embeddings",
|
|
943
|
+
method="POST",
|
|
944
|
+
json={
|
|
945
|
+
"tenant_id": tenant_id,
|
|
946
|
+
"sub_tenant_id": sub_tenant_id,
|
|
947
|
+
"source_id": source_id,
|
|
948
|
+
"chunk_ids": chunk_ids,
|
|
949
|
+
"output_fields": output_fields,
|
|
950
|
+
"limit": limit,
|
|
951
|
+
},
|
|
952
|
+
headers={
|
|
953
|
+
"content-type": "application/json",
|
|
954
|
+
},
|
|
955
|
+
request_options=request_options,
|
|
956
|
+
omit=OMIT,
|
|
957
|
+
)
|
|
958
|
+
try:
|
|
959
|
+
if 200 <= _response.status_code < 300:
|
|
960
|
+
_data = typing.cast(
|
|
961
|
+
typing.List[RawEmbeddingSearchResult],
|
|
962
|
+
parse_obj_as(
|
|
963
|
+
type_=typing.List[RawEmbeddingSearchResult], # type: ignore
|
|
964
|
+
object_=_response.json(),
|
|
965
|
+
),
|
|
966
|
+
)
|
|
967
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
968
|
+
if _response.status_code == 400:
|
|
969
|
+
raise BadRequestError(
|
|
970
|
+
headers=dict(_response.headers),
|
|
971
|
+
body=typing.cast(
|
|
972
|
+
typing.Optional[typing.Any],
|
|
973
|
+
parse_obj_as(
|
|
974
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
975
|
+
object_=_response.json(),
|
|
976
|
+
),
|
|
977
|
+
),
|
|
978
|
+
)
|
|
979
|
+
if _response.status_code == 401:
|
|
980
|
+
raise UnauthorizedError(
|
|
981
|
+
headers=dict(_response.headers),
|
|
982
|
+
body=typing.cast(
|
|
983
|
+
typing.Optional[typing.Any],
|
|
984
|
+
parse_obj_as(
|
|
985
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
986
|
+
object_=_response.json(),
|
|
987
|
+
),
|
|
988
|
+
),
|
|
989
|
+
)
|
|
990
|
+
if _response.status_code == 403:
|
|
991
|
+
raise ForbiddenError(
|
|
992
|
+
headers=dict(_response.headers),
|
|
993
|
+
body=typing.cast(
|
|
994
|
+
typing.Optional[typing.Any],
|
|
995
|
+
parse_obj_as(
|
|
996
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
997
|
+
object_=_response.json(),
|
|
998
|
+
),
|
|
999
|
+
),
|
|
1000
|
+
)
|
|
1001
|
+
if _response.status_code == 404:
|
|
1002
|
+
raise NotFoundError(
|
|
1003
|
+
headers=dict(_response.headers),
|
|
1004
|
+
body=typing.cast(
|
|
1005
|
+
typing.Optional[typing.Any],
|
|
1006
|
+
parse_obj_as(
|
|
1007
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1008
|
+
object_=_response.json(),
|
|
1009
|
+
),
|
|
1010
|
+
),
|
|
1011
|
+
)
|
|
1012
|
+
if _response.status_code == 422:
|
|
1013
|
+
raise UnprocessableEntityError(
|
|
1014
|
+
headers=dict(_response.headers),
|
|
1015
|
+
body=typing.cast(
|
|
1016
|
+
typing.Optional[typing.Any],
|
|
1017
|
+
parse_obj_as(
|
|
1018
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1019
|
+
object_=_response.json(),
|
|
1020
|
+
),
|
|
1021
|
+
),
|
|
1022
|
+
)
|
|
1023
|
+
if _response.status_code == 500:
|
|
1024
|
+
raise InternalServerError(
|
|
1025
|
+
headers=dict(_response.headers),
|
|
1026
|
+
body=typing.cast(
|
|
1027
|
+
typing.Optional[typing.Any],
|
|
1028
|
+
parse_obj_as(
|
|
1029
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1030
|
+
object_=_response.json(),
|
|
1031
|
+
),
|
|
1032
|
+
),
|
|
1033
|
+
)
|
|
1034
|
+
if _response.status_code == 503:
|
|
1035
|
+
raise ServiceUnavailableError(
|
|
1036
|
+
headers=dict(_response.headers),
|
|
1037
|
+
body=typing.cast(
|
|
1038
|
+
typing.Optional[typing.Any],
|
|
1039
|
+
parse_obj_as(
|
|
1040
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1041
|
+
object_=_response.json(),
|
|
1042
|
+
),
|
|
1043
|
+
),
|
|
1044
|
+
)
|
|
1045
|
+
_response_json = _response.json()
|
|
1046
|
+
except JSONDecodeError:
|
|
1047
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1048
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1049
|
+
|
|
1050
|
+
async def delete(
|
|
1051
|
+
self,
|
|
1052
|
+
*,
|
|
1053
|
+
tenant_id: str,
|
|
1054
|
+
sub_tenant_id: typing.Optional[str] = None,
|
|
1055
|
+
source_id: typing.Optional[str] = None,
|
|
1056
|
+
chunk_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
1057
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1058
|
+
) -> AsyncHttpResponse[DeleteResult]:
|
|
1059
|
+
"""
|
|
1060
|
+
Parameters
|
|
1061
|
+
----------
|
|
1062
|
+
tenant_id : str
|
|
1063
|
+
Unique identifier for the tenant/organization
|
|
1064
|
+
|
|
1065
|
+
sub_tenant_id : typing.Optional[str]
|
|
1066
|
+
Optional sub-tenant ID for scoping deletion
|
|
1067
|
+
|
|
1068
|
+
source_id : typing.Optional[str]
|
|
1069
|
+
Optional source ID to delete by (mutually exclusive with chunk_ids)
|
|
1070
|
+
|
|
1071
|
+
chunk_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
1072
|
+
Optional list of chunk IDs to delete (mutually exclusive with source_id)
|
|
1073
|
+
|
|
1074
|
+
request_options : typing.Optional[RequestOptions]
|
|
1075
|
+
Request-specific configuration.
|
|
1076
|
+
|
|
1077
|
+
Returns
|
|
1078
|
+
-------
|
|
1079
|
+
AsyncHttpResponse[DeleteResult]
|
|
1080
|
+
Successful Response
|
|
1081
|
+
"""
|
|
1082
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1083
|
+
"embeddings/delete_raw_embeddings",
|
|
1084
|
+
method="DELETE",
|
|
1085
|
+
params={
|
|
1086
|
+
"tenant_id": tenant_id,
|
|
1087
|
+
"sub_tenant_id": sub_tenant_id,
|
|
1088
|
+
"source_id": source_id,
|
|
1089
|
+
"chunk_ids": chunk_ids,
|
|
1090
|
+
},
|
|
1091
|
+
request_options=request_options,
|
|
1092
|
+
)
|
|
1093
|
+
try:
|
|
1094
|
+
if 200 <= _response.status_code < 300:
|
|
1095
|
+
_data = typing.cast(
|
|
1096
|
+
DeleteResult,
|
|
1097
|
+
parse_obj_as(
|
|
1098
|
+
type_=DeleteResult, # type: ignore
|
|
1099
|
+
object_=_response.json(),
|
|
1100
|
+
),
|
|
1101
|
+
)
|
|
1102
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1103
|
+
if _response.status_code == 400:
|
|
1104
|
+
raise BadRequestError(
|
|
1105
|
+
headers=dict(_response.headers),
|
|
1106
|
+
body=typing.cast(
|
|
1107
|
+
typing.Optional[typing.Any],
|
|
1108
|
+
parse_obj_as(
|
|
1109
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1110
|
+
object_=_response.json(),
|
|
1111
|
+
),
|
|
1112
|
+
),
|
|
1113
|
+
)
|
|
1114
|
+
if _response.status_code == 401:
|
|
1115
|
+
raise UnauthorizedError(
|
|
1116
|
+
headers=dict(_response.headers),
|
|
1117
|
+
body=typing.cast(
|
|
1118
|
+
typing.Optional[typing.Any],
|
|
1119
|
+
parse_obj_as(
|
|
1120
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1121
|
+
object_=_response.json(),
|
|
1122
|
+
),
|
|
1123
|
+
),
|
|
1124
|
+
)
|
|
1125
|
+
if _response.status_code == 403:
|
|
1126
|
+
raise ForbiddenError(
|
|
1127
|
+
headers=dict(_response.headers),
|
|
1128
|
+
body=typing.cast(
|
|
1129
|
+
typing.Optional[typing.Any],
|
|
1130
|
+
parse_obj_as(
|
|
1131
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1132
|
+
object_=_response.json(),
|
|
1133
|
+
),
|
|
1134
|
+
),
|
|
1135
|
+
)
|
|
1136
|
+
if _response.status_code == 404:
|
|
1137
|
+
raise NotFoundError(
|
|
1138
|
+
headers=dict(_response.headers),
|
|
1139
|
+
body=typing.cast(
|
|
1140
|
+
typing.Optional[typing.Any],
|
|
1141
|
+
parse_obj_as(
|
|
1142
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1143
|
+
object_=_response.json(),
|
|
1144
|
+
),
|
|
1145
|
+
),
|
|
1146
|
+
)
|
|
1147
|
+
if _response.status_code == 422:
|
|
1148
|
+
raise UnprocessableEntityError(
|
|
1149
|
+
headers=dict(_response.headers),
|
|
1150
|
+
body=typing.cast(
|
|
1151
|
+
typing.Optional[typing.Any],
|
|
1152
|
+
parse_obj_as(
|
|
1153
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1154
|
+
object_=_response.json(),
|
|
1155
|
+
),
|
|
1156
|
+
),
|
|
1157
|
+
)
|
|
1158
|
+
if _response.status_code == 500:
|
|
1159
|
+
raise InternalServerError(
|
|
1160
|
+
headers=dict(_response.headers),
|
|
1161
|
+
body=typing.cast(
|
|
1162
|
+
typing.Optional[typing.Any],
|
|
1163
|
+
parse_obj_as(
|
|
1164
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1165
|
+
object_=_response.json(),
|
|
1166
|
+
),
|
|
1167
|
+
),
|
|
1168
|
+
)
|
|
1169
|
+
if _response.status_code == 503:
|
|
1170
|
+
raise ServiceUnavailableError(
|
|
1171
|
+
headers=dict(_response.headers),
|
|
1172
|
+
body=typing.cast(
|
|
1173
|
+
typing.Optional[typing.Any],
|
|
1174
|
+
parse_obj_as(
|
|
1175
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1176
|
+
object_=_response.json(),
|
|
1177
|
+
),
|
|
1178
|
+
),
|
|
1179
|
+
)
|
|
1180
|
+
_response_json = _response.json()
|
|
1181
|
+
except JSONDecodeError:
|
|
1182
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1183
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|