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,486 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
6
|
+
from ..core.request_options import RequestOptions
|
|
7
|
+
from ..types.delete_result import DeleteResult
|
|
8
|
+
from ..types.insert_result import InsertResult
|
|
9
|
+
from ..types.raw_embedding_document import RawEmbeddingDocument
|
|
10
|
+
from ..types.raw_embedding_search_result import RawEmbeddingSearchResult
|
|
11
|
+
from .raw_client import AsyncRawEmbeddingsClient, RawEmbeddingsClient
|
|
12
|
+
|
|
13
|
+
# this is used as the default value for optional parameters
|
|
14
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class EmbeddingsClient:
|
|
18
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
19
|
+
self._raw_client = RawEmbeddingsClient(client_wrapper=client_wrapper)
|
|
20
|
+
|
|
21
|
+
@property
|
|
22
|
+
def with_raw_response(self) -> RawEmbeddingsClient:
|
|
23
|
+
"""
|
|
24
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
25
|
+
|
|
26
|
+
Returns
|
|
27
|
+
-------
|
|
28
|
+
RawEmbeddingsClient
|
|
29
|
+
"""
|
|
30
|
+
return self._raw_client
|
|
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
|
+
) -> 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
|
+
InsertResult
|
|
62
|
+
Successful Response
|
|
63
|
+
|
|
64
|
+
Examples
|
|
65
|
+
--------
|
|
66
|
+
from hydra-db import HydraDB, RawEmbeddingDocument, RawEmbeddingVector
|
|
67
|
+
|
|
68
|
+
client = HydraDB(token="YOUR_TOKEN", )
|
|
69
|
+
client.embeddings.insert(tenant_id='tenant_1234', embeddings=[RawEmbeddingDocument(source_id='<source_id>', embeddings=[RawEmbeddingVector(chunk_id='<chunk_id>', embedding=[1.1], ), RawEmbeddingVector(chunk_id='<chunk_id>', embedding=[1.1], )], ), RawEmbeddingDocument(source_id='<source_id>', embeddings=[RawEmbeddingVector(chunk_id='<chunk_id>', embedding=[1.1], ), RawEmbeddingVector(chunk_id='<chunk_id>', embedding=[1.1], )], )], )
|
|
70
|
+
"""
|
|
71
|
+
_response = self._raw_client.insert(
|
|
72
|
+
tenant_id=tenant_id,
|
|
73
|
+
embeddings=embeddings,
|
|
74
|
+
sub_tenant_id=sub_tenant_id,
|
|
75
|
+
upsert=upsert,
|
|
76
|
+
request_options=request_options,
|
|
77
|
+
)
|
|
78
|
+
return _response.data
|
|
79
|
+
|
|
80
|
+
def search(
|
|
81
|
+
self,
|
|
82
|
+
*,
|
|
83
|
+
tenant_id: str,
|
|
84
|
+
sub_tenant_id: str,
|
|
85
|
+
query_embedding: typing.Sequence[float],
|
|
86
|
+
limit: typing.Optional[int] = OMIT,
|
|
87
|
+
filter_expr: typing.Optional[str] = OMIT,
|
|
88
|
+
output_fields: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
89
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
90
|
+
) -> typing.List[RawEmbeddingSearchResult]:
|
|
91
|
+
"""
|
|
92
|
+
Parameters
|
|
93
|
+
----------
|
|
94
|
+
tenant_id : str
|
|
95
|
+
Unique identifier for the tenant/organization
|
|
96
|
+
|
|
97
|
+
sub_tenant_id : str
|
|
98
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
99
|
+
|
|
100
|
+
query_embedding : typing.Sequence[float]
|
|
101
|
+
Query embedding vector to search for
|
|
102
|
+
|
|
103
|
+
limit : typing.Optional[int]
|
|
104
|
+
Maximum number of results to return
|
|
105
|
+
|
|
106
|
+
filter_expr : typing.Optional[str]
|
|
107
|
+
Optional Milvus filter expression for additional filtering
|
|
108
|
+
|
|
109
|
+
output_fields : typing.Optional[typing.Sequence[str]]
|
|
110
|
+
Optional list of fields to return in results (default: chunk_id, source_id, metadata)
|
|
111
|
+
|
|
112
|
+
request_options : typing.Optional[RequestOptions]
|
|
113
|
+
Request-specific configuration.
|
|
114
|
+
|
|
115
|
+
Returns
|
|
116
|
+
-------
|
|
117
|
+
typing.List[RawEmbeddingSearchResult]
|
|
118
|
+
Successful Response
|
|
119
|
+
|
|
120
|
+
Examples
|
|
121
|
+
--------
|
|
122
|
+
from hydra-db import HydraDB
|
|
123
|
+
|
|
124
|
+
client = HydraDB(token="YOUR_TOKEN", )
|
|
125
|
+
client.embeddings.search(tenant_id='tenant_1234', sub_tenant_id='sub_tenant_4567', query_embedding=[1.1], )
|
|
126
|
+
"""
|
|
127
|
+
_response = self._raw_client.search(
|
|
128
|
+
tenant_id=tenant_id,
|
|
129
|
+
sub_tenant_id=sub_tenant_id,
|
|
130
|
+
query_embedding=query_embedding,
|
|
131
|
+
limit=limit,
|
|
132
|
+
filter_expr=filter_expr,
|
|
133
|
+
output_fields=output_fields,
|
|
134
|
+
request_options=request_options,
|
|
135
|
+
)
|
|
136
|
+
return _response.data
|
|
137
|
+
|
|
138
|
+
def filter(
|
|
139
|
+
self,
|
|
140
|
+
*,
|
|
141
|
+
tenant_id: str,
|
|
142
|
+
sub_tenant_id: str,
|
|
143
|
+
source_id: typing.Optional[str] = OMIT,
|
|
144
|
+
chunk_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
145
|
+
output_fields: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
146
|
+
limit: typing.Optional[int] = OMIT,
|
|
147
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
148
|
+
) -> typing.List[RawEmbeddingSearchResult]:
|
|
149
|
+
"""
|
|
150
|
+
Parameters
|
|
151
|
+
----------
|
|
152
|
+
tenant_id : str
|
|
153
|
+
Unique identifier for the tenant/organization
|
|
154
|
+
|
|
155
|
+
sub_tenant_id : str
|
|
156
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
157
|
+
|
|
158
|
+
source_id : typing.Optional[str]
|
|
159
|
+
Optional source ID to filter by (mutually exclusive with chunk_ids)
|
|
160
|
+
|
|
161
|
+
chunk_ids : typing.Optional[typing.Sequence[str]]
|
|
162
|
+
Optional list of chunk IDs to filter by (mutually exclusive with source_id)
|
|
163
|
+
|
|
164
|
+
output_fields : typing.Optional[typing.Sequence[str]]
|
|
165
|
+
Optional list of fields to return in results (default: chunk_id, source_id, metadata)
|
|
166
|
+
|
|
167
|
+
limit : typing.Optional[int]
|
|
168
|
+
Maximum number of results to return
|
|
169
|
+
|
|
170
|
+
request_options : typing.Optional[RequestOptions]
|
|
171
|
+
Request-specific configuration.
|
|
172
|
+
|
|
173
|
+
Returns
|
|
174
|
+
-------
|
|
175
|
+
typing.List[RawEmbeddingSearchResult]
|
|
176
|
+
Successful Response
|
|
177
|
+
|
|
178
|
+
Examples
|
|
179
|
+
--------
|
|
180
|
+
from hydra-db import HydraDB
|
|
181
|
+
|
|
182
|
+
client = HydraDB(token="YOUR_TOKEN", )
|
|
183
|
+
client.embeddings.filter(tenant_id='tenant_1234', sub_tenant_id='sub_tenant_4567', )
|
|
184
|
+
"""
|
|
185
|
+
_response = self._raw_client.filter(
|
|
186
|
+
tenant_id=tenant_id,
|
|
187
|
+
sub_tenant_id=sub_tenant_id,
|
|
188
|
+
source_id=source_id,
|
|
189
|
+
chunk_ids=chunk_ids,
|
|
190
|
+
output_fields=output_fields,
|
|
191
|
+
limit=limit,
|
|
192
|
+
request_options=request_options,
|
|
193
|
+
)
|
|
194
|
+
return _response.data
|
|
195
|
+
|
|
196
|
+
def delete(
|
|
197
|
+
self,
|
|
198
|
+
*,
|
|
199
|
+
tenant_id: str,
|
|
200
|
+
sub_tenant_id: typing.Optional[str] = None,
|
|
201
|
+
source_id: typing.Optional[str] = None,
|
|
202
|
+
chunk_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
203
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
204
|
+
) -> DeleteResult:
|
|
205
|
+
"""
|
|
206
|
+
Parameters
|
|
207
|
+
----------
|
|
208
|
+
tenant_id : str
|
|
209
|
+
Unique identifier for the tenant/organization
|
|
210
|
+
|
|
211
|
+
sub_tenant_id : typing.Optional[str]
|
|
212
|
+
Optional sub-tenant ID for scoping deletion
|
|
213
|
+
|
|
214
|
+
source_id : typing.Optional[str]
|
|
215
|
+
Optional source ID to delete by (mutually exclusive with chunk_ids)
|
|
216
|
+
|
|
217
|
+
chunk_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
218
|
+
Optional list of chunk IDs to delete (mutually exclusive with source_id)
|
|
219
|
+
|
|
220
|
+
request_options : typing.Optional[RequestOptions]
|
|
221
|
+
Request-specific configuration.
|
|
222
|
+
|
|
223
|
+
Returns
|
|
224
|
+
-------
|
|
225
|
+
DeleteResult
|
|
226
|
+
Successful Response
|
|
227
|
+
|
|
228
|
+
Examples
|
|
229
|
+
--------
|
|
230
|
+
from hydra-db import HydraDB
|
|
231
|
+
|
|
232
|
+
client = HydraDB(token="YOUR_TOKEN", )
|
|
233
|
+
client.embeddings.delete(tenant_id='tenant_1234', )
|
|
234
|
+
"""
|
|
235
|
+
_response = self._raw_client.delete(
|
|
236
|
+
tenant_id=tenant_id,
|
|
237
|
+
sub_tenant_id=sub_tenant_id,
|
|
238
|
+
source_id=source_id,
|
|
239
|
+
chunk_ids=chunk_ids,
|
|
240
|
+
request_options=request_options,
|
|
241
|
+
)
|
|
242
|
+
return _response.data
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
class AsyncEmbeddingsClient:
|
|
246
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
247
|
+
self._raw_client = AsyncRawEmbeddingsClient(client_wrapper=client_wrapper)
|
|
248
|
+
|
|
249
|
+
@property
|
|
250
|
+
def with_raw_response(self) -> AsyncRawEmbeddingsClient:
|
|
251
|
+
"""
|
|
252
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
253
|
+
|
|
254
|
+
Returns
|
|
255
|
+
-------
|
|
256
|
+
AsyncRawEmbeddingsClient
|
|
257
|
+
"""
|
|
258
|
+
return self._raw_client
|
|
259
|
+
|
|
260
|
+
async def insert(
|
|
261
|
+
self,
|
|
262
|
+
*,
|
|
263
|
+
tenant_id: str,
|
|
264
|
+
embeddings: typing.Sequence[RawEmbeddingDocument],
|
|
265
|
+
sub_tenant_id: typing.Optional[str] = OMIT,
|
|
266
|
+
upsert: typing.Optional[bool] = OMIT,
|
|
267
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
268
|
+
) -> InsertResult:
|
|
269
|
+
"""
|
|
270
|
+
Parameters
|
|
271
|
+
----------
|
|
272
|
+
tenant_id : str
|
|
273
|
+
Unique identifier for the tenant/organization
|
|
274
|
+
|
|
275
|
+
embeddings : typing.Sequence[RawEmbeddingDocument]
|
|
276
|
+
List of raw embedding documents to insert
|
|
277
|
+
|
|
278
|
+
sub_tenant_id : typing.Optional[str]
|
|
279
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
280
|
+
|
|
281
|
+
upsert : typing.Optional[bool]
|
|
282
|
+
If True, update existing embeddings; if False, insert only
|
|
283
|
+
|
|
284
|
+
request_options : typing.Optional[RequestOptions]
|
|
285
|
+
Request-specific configuration.
|
|
286
|
+
|
|
287
|
+
Returns
|
|
288
|
+
-------
|
|
289
|
+
InsertResult
|
|
290
|
+
Successful Response
|
|
291
|
+
|
|
292
|
+
Examples
|
|
293
|
+
--------
|
|
294
|
+
import asyncio
|
|
295
|
+
|
|
296
|
+
from hydra-db import AsyncHydraDB, RawEmbeddingDocument, RawEmbeddingVector
|
|
297
|
+
|
|
298
|
+
client = AsyncHydraDB(token="YOUR_TOKEN", )
|
|
299
|
+
async def main() -> None:
|
|
300
|
+
await client.embeddings.insert(tenant_id='tenant_1234', embeddings=[RawEmbeddingDocument(source_id='<source_id>', embeddings=[RawEmbeddingVector(chunk_id='<chunk_id>', embedding=[1.1], ), RawEmbeddingVector(chunk_id='<chunk_id>', embedding=[1.1], )], ), RawEmbeddingDocument(source_id='<source_id>', embeddings=[RawEmbeddingVector(chunk_id='<chunk_id>', embedding=[1.1], ), RawEmbeddingVector(chunk_id='<chunk_id>', embedding=[1.1], )], )], )
|
|
301
|
+
asyncio.run(main())
|
|
302
|
+
"""
|
|
303
|
+
_response = await self._raw_client.insert(
|
|
304
|
+
tenant_id=tenant_id,
|
|
305
|
+
embeddings=embeddings,
|
|
306
|
+
sub_tenant_id=sub_tenant_id,
|
|
307
|
+
upsert=upsert,
|
|
308
|
+
request_options=request_options,
|
|
309
|
+
)
|
|
310
|
+
return _response.data
|
|
311
|
+
|
|
312
|
+
async def search(
|
|
313
|
+
self,
|
|
314
|
+
*,
|
|
315
|
+
tenant_id: str,
|
|
316
|
+
sub_tenant_id: str,
|
|
317
|
+
query_embedding: typing.Sequence[float],
|
|
318
|
+
limit: typing.Optional[int] = OMIT,
|
|
319
|
+
filter_expr: typing.Optional[str] = OMIT,
|
|
320
|
+
output_fields: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
321
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
322
|
+
) -> typing.List[RawEmbeddingSearchResult]:
|
|
323
|
+
"""
|
|
324
|
+
Parameters
|
|
325
|
+
----------
|
|
326
|
+
tenant_id : str
|
|
327
|
+
Unique identifier for the tenant/organization
|
|
328
|
+
|
|
329
|
+
sub_tenant_id : str
|
|
330
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
331
|
+
|
|
332
|
+
query_embedding : typing.Sequence[float]
|
|
333
|
+
Query embedding vector to search for
|
|
334
|
+
|
|
335
|
+
limit : typing.Optional[int]
|
|
336
|
+
Maximum number of results to return
|
|
337
|
+
|
|
338
|
+
filter_expr : typing.Optional[str]
|
|
339
|
+
Optional Milvus filter expression for additional filtering
|
|
340
|
+
|
|
341
|
+
output_fields : typing.Optional[typing.Sequence[str]]
|
|
342
|
+
Optional list of fields to return in results (default: chunk_id, source_id, metadata)
|
|
343
|
+
|
|
344
|
+
request_options : typing.Optional[RequestOptions]
|
|
345
|
+
Request-specific configuration.
|
|
346
|
+
|
|
347
|
+
Returns
|
|
348
|
+
-------
|
|
349
|
+
typing.List[RawEmbeddingSearchResult]
|
|
350
|
+
Successful Response
|
|
351
|
+
|
|
352
|
+
Examples
|
|
353
|
+
--------
|
|
354
|
+
import asyncio
|
|
355
|
+
|
|
356
|
+
from hydra-db import AsyncHydraDB
|
|
357
|
+
|
|
358
|
+
client = AsyncHydraDB(token="YOUR_TOKEN", )
|
|
359
|
+
async def main() -> None:
|
|
360
|
+
await client.embeddings.search(tenant_id='tenant_1234', sub_tenant_id='sub_tenant_4567', query_embedding=[1.1], )
|
|
361
|
+
asyncio.run(main())
|
|
362
|
+
"""
|
|
363
|
+
_response = await self._raw_client.search(
|
|
364
|
+
tenant_id=tenant_id,
|
|
365
|
+
sub_tenant_id=sub_tenant_id,
|
|
366
|
+
query_embedding=query_embedding,
|
|
367
|
+
limit=limit,
|
|
368
|
+
filter_expr=filter_expr,
|
|
369
|
+
output_fields=output_fields,
|
|
370
|
+
request_options=request_options,
|
|
371
|
+
)
|
|
372
|
+
return _response.data
|
|
373
|
+
|
|
374
|
+
async def filter(
|
|
375
|
+
self,
|
|
376
|
+
*,
|
|
377
|
+
tenant_id: str,
|
|
378
|
+
sub_tenant_id: str,
|
|
379
|
+
source_id: typing.Optional[str] = OMIT,
|
|
380
|
+
chunk_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
381
|
+
output_fields: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
382
|
+
limit: typing.Optional[int] = OMIT,
|
|
383
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
384
|
+
) -> typing.List[RawEmbeddingSearchResult]:
|
|
385
|
+
"""
|
|
386
|
+
Parameters
|
|
387
|
+
----------
|
|
388
|
+
tenant_id : str
|
|
389
|
+
Unique identifier for the tenant/organization
|
|
390
|
+
|
|
391
|
+
sub_tenant_id : str
|
|
392
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
393
|
+
|
|
394
|
+
source_id : typing.Optional[str]
|
|
395
|
+
Optional source ID to filter by (mutually exclusive with chunk_ids)
|
|
396
|
+
|
|
397
|
+
chunk_ids : typing.Optional[typing.Sequence[str]]
|
|
398
|
+
Optional list of chunk IDs to filter by (mutually exclusive with source_id)
|
|
399
|
+
|
|
400
|
+
output_fields : typing.Optional[typing.Sequence[str]]
|
|
401
|
+
Optional list of fields to return in results (default: chunk_id, source_id, metadata)
|
|
402
|
+
|
|
403
|
+
limit : typing.Optional[int]
|
|
404
|
+
Maximum number of results to return
|
|
405
|
+
|
|
406
|
+
request_options : typing.Optional[RequestOptions]
|
|
407
|
+
Request-specific configuration.
|
|
408
|
+
|
|
409
|
+
Returns
|
|
410
|
+
-------
|
|
411
|
+
typing.List[RawEmbeddingSearchResult]
|
|
412
|
+
Successful Response
|
|
413
|
+
|
|
414
|
+
Examples
|
|
415
|
+
--------
|
|
416
|
+
import asyncio
|
|
417
|
+
|
|
418
|
+
from hydra-db import AsyncHydraDB
|
|
419
|
+
|
|
420
|
+
client = AsyncHydraDB(token="YOUR_TOKEN", )
|
|
421
|
+
async def main() -> None:
|
|
422
|
+
await client.embeddings.filter(tenant_id='tenant_1234', sub_tenant_id='sub_tenant_4567', )
|
|
423
|
+
asyncio.run(main())
|
|
424
|
+
"""
|
|
425
|
+
_response = await self._raw_client.filter(
|
|
426
|
+
tenant_id=tenant_id,
|
|
427
|
+
sub_tenant_id=sub_tenant_id,
|
|
428
|
+
source_id=source_id,
|
|
429
|
+
chunk_ids=chunk_ids,
|
|
430
|
+
output_fields=output_fields,
|
|
431
|
+
limit=limit,
|
|
432
|
+
request_options=request_options,
|
|
433
|
+
)
|
|
434
|
+
return _response.data
|
|
435
|
+
|
|
436
|
+
async def delete(
|
|
437
|
+
self,
|
|
438
|
+
*,
|
|
439
|
+
tenant_id: str,
|
|
440
|
+
sub_tenant_id: typing.Optional[str] = None,
|
|
441
|
+
source_id: typing.Optional[str] = None,
|
|
442
|
+
chunk_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
443
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
444
|
+
) -> DeleteResult:
|
|
445
|
+
"""
|
|
446
|
+
Parameters
|
|
447
|
+
----------
|
|
448
|
+
tenant_id : str
|
|
449
|
+
Unique identifier for the tenant/organization
|
|
450
|
+
|
|
451
|
+
sub_tenant_id : typing.Optional[str]
|
|
452
|
+
Optional sub-tenant ID for scoping deletion
|
|
453
|
+
|
|
454
|
+
source_id : typing.Optional[str]
|
|
455
|
+
Optional source ID to delete by (mutually exclusive with chunk_ids)
|
|
456
|
+
|
|
457
|
+
chunk_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
458
|
+
Optional list of chunk IDs to delete (mutually exclusive with source_id)
|
|
459
|
+
|
|
460
|
+
request_options : typing.Optional[RequestOptions]
|
|
461
|
+
Request-specific configuration.
|
|
462
|
+
|
|
463
|
+
Returns
|
|
464
|
+
-------
|
|
465
|
+
DeleteResult
|
|
466
|
+
Successful Response
|
|
467
|
+
|
|
468
|
+
Examples
|
|
469
|
+
--------
|
|
470
|
+
import asyncio
|
|
471
|
+
|
|
472
|
+
from hydra-db import AsyncHydraDB
|
|
473
|
+
|
|
474
|
+
client = AsyncHydraDB(token="YOUR_TOKEN", )
|
|
475
|
+
async def main() -> None:
|
|
476
|
+
await client.embeddings.delete(tenant_id='tenant_1234', )
|
|
477
|
+
asyncio.run(main())
|
|
478
|
+
"""
|
|
479
|
+
_response = await self._raw_client.delete(
|
|
480
|
+
tenant_id=tenant_id,
|
|
481
|
+
sub_tenant_id=sub_tenant_id,
|
|
482
|
+
source_id=source_id,
|
|
483
|
+
chunk_ids=chunk_ids,
|
|
484
|
+
request_options=request_options,
|
|
485
|
+
)
|
|
486
|
+
return _response.data
|