hydradb-sdk 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hydradb_sdk-0.0.1/LICENSE +22 -0
- hydradb_sdk-0.0.1/PKG-INFO +607 -0
- hydradb_sdk-0.0.1/README.md +561 -0
- hydradb_sdk-0.0.1/pyproject.toml +47 -0
- hydradb_sdk-0.0.1/setup.cfg +4 -0
- hydradb_sdk-0.0.1/src/hydra_db/__init__.py +302 -0
- hydradb_sdk-0.0.1/src/hydra_db/_default_clients.py +30 -0
- hydradb_sdk-0.0.1/src/hydra_db/client.py +439 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/__init__.py +127 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/api_error.py +23 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/client_wrapper.py +105 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/datetime_utils.py +70 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/file.py +67 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/force_multipart.py +18 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/http_client.py +839 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/http_response.py +59 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/http_sse/__init__.py +42 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/http_sse/_api.py +148 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/http_sse/_decoders.py +61 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/http_sse/_exceptions.py +7 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/http_sse/_models.py +17 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/jsonable_encoder.py +120 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/logging.py +107 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/parse_error.py +36 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/pydantic_utilities.py +634 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/query_encoder.py +58 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/remove_none_from_dict.py +11 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/request_options.py +35 -0
- hydradb_sdk-0.0.1/src/hydra_db/core/serialization.py +276 -0
- hydradb_sdk-0.0.1/src/hydra_db/data/__init__.py +4 -0
- hydradb_sdk-0.0.1/src/hydra_db/data/client.py +137 -0
- hydradb_sdk-0.0.1/src/hydra_db/data/raw_client.py +305 -0
- hydradb_sdk-0.0.1/src/hydra_db/embeddings/__init__.py +4 -0
- hydradb_sdk-0.0.1/src/hydra_db/embeddings/client.py +596 -0
- hydradb_sdk-0.0.1/src/hydra_db/embeddings/raw_client.py +1217 -0
- hydradb_sdk-0.0.1/src/hydra_db/environment.py +7 -0
- hydradb_sdk-0.0.1/src/hydra_db/errors/__init__.py +59 -0
- hydradb_sdk-0.0.1/src/hydra_db/errors/bad_request_error.py +10 -0
- hydradb_sdk-0.0.1/src/hydra_db/errors/forbidden_error.py +10 -0
- hydradb_sdk-0.0.1/src/hydra_db/errors/internal_server_error.py +10 -0
- hydradb_sdk-0.0.1/src/hydra_db/errors/not_found_error.py +10 -0
- hydradb_sdk-0.0.1/src/hydra_db/errors/service_unavailable_error.py +10 -0
- hydradb_sdk-0.0.1/src/hydra_db/errors/too_many_requests_error.py +11 -0
- hydradb_sdk-0.0.1/src/hydra_db/errors/unauthorized_error.py +10 -0
- hydradb_sdk-0.0.1/src/hydra_db/errors/unprocessable_entity_error.py +10 -0
- hydradb_sdk-0.0.1/src/hydra_db/fetch/__init__.py +34 -0
- hydradb_sdk-0.0.1/src/hydra_db/fetch/client.py +448 -0
- hydradb_sdk-0.0.1/src/hydra_db/fetch/raw_client.py +953 -0
- hydradb_sdk-0.0.1/src/hydra_db/fetch/types/__init__.py +34 -0
- hydradb_sdk-0.0.1/src/hydra_db/fetch/types/list_data_fetch_response.py +8 -0
- hydradb_sdk-0.0.1/src/hydra_db/graph_health/__init__.py +4 -0
- hydradb_sdk-0.0.1/src/hydra_db/graph_health/client.py +152 -0
- hydradb_sdk-0.0.1/src/hydra_db/graph_health/raw_client.py +308 -0
- hydradb_sdk-0.0.1/src/hydra_db/ingestion_pipeline/__init__.py +4 -0
- hydradb_sdk-0.0.1/src/hydra_db/ingestion_pipeline/client.py +191 -0
- hydradb_sdk-0.0.1/src/hydra_db/ingestion_pipeline/raw_client.py +215 -0
- hydradb_sdk-0.0.1/src/hydra_db/key/__init__.py +4 -0
- hydradb_sdk-0.0.1/src/hydra_db/key/client.py +143 -0
- hydradb_sdk-0.0.1/src/hydra_db/key/raw_client.py +319 -0
- hydradb_sdk-0.0.1/src/hydra_db/raw_client.py +102 -0
- hydradb_sdk-0.0.1/src/hydra_db/recall/__init__.py +4 -0
- hydradb_sdk-0.0.1/src/hydra_db/recall/client.py +765 -0
- hydradb_sdk-0.0.1/src/hydra_db/recall/raw_client.py +1542 -0
- hydradb_sdk-0.0.1/src/hydra_db/tenant/__init__.py +4 -0
- hydradb_sdk-0.0.1/src/hydra_db/tenant/client.py +497 -0
- hydradb_sdk-0.0.1/src/hydra_db/tenant/raw_client.py +1532 -0
- hydradb_sdk-0.0.1/src/hydra_db/tests/conftest.py +21 -0
- hydradb_sdk-0.0.1/src/hydra_db/tests/test_aiohttp_autodetect.py +113 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/__init__.py +239 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/actual_error_response.py +20 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/add_memory_response.py +39 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/api_key_create_response.py +48 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/attachment_model.py +53 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/batch_processing_status.py +23 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/bm25operator_type.py +5 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/collection_stats.py +27 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/content_filter.py +49 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/content_model.py +47 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/cortex_models_response_commons_actual_error_response.py +20 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/cortex_models_response_commons_error_response.py +21 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/custom_property_definition.py +74 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/delete_result.py +36 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/delete_user_memory_response.py +31 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/entity.py +42 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/error_response.py +21 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/fetch_mode.py +5 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/forceful_relations_payload.py +27 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/graph_context.py +30 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/http_validation_error.py +20 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/infra.py +21 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/infra_status_response.py +42 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/ingest_response.py +20 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/insert_result.py +41 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/list_content_kind.py +5 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/list_user_memories_response.py +43 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/memory_item.py +98 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/memory_result_item.py +47 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/milvus_data_type.py +21 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/pagination_meta.py +51 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/path_triplet.py +23 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/processing_status.py +48 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/processing_status_indexing_status.py +7 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/qn_a_search_response.py +49 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/raw_embedding_document.py +47 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/raw_embedding_search_result.py +47 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/raw_embedding_vector.py +31 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/recall_search_request.py +78 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/recall_search_request_alpha.py +5 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/relation_evidence.py +72 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/retrieval_result.py +36 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/retrieve_mode.py +5 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/scored_path_response.py +31 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/search_mode.py +5 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/source_delete_response.py +30 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/source_delete_result_item.py +36 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/source_fetch_response.py +66 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/source_graph_relations_response.py +33 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/source_info.py +57 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/source_list_response.py +5 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/source_model.py +99 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/source_status.py +5 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/source_upload_response.py +35 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/source_upload_result_item.py +38 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/sub_tenant_ids_response.py +31 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/super_node_item.py +26 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/super_node_response.py +28 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/supported_llm_providers.py +5 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/tenant_create_accepted_response.py +36 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/tenant_delete_response.py +25 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/tenant_ids_response.py +32 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/tenant_stats_response.py +38 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/triplet_with_evidence.py +35 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/user_assistant_pair.py +31 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/user_memory.py +31 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/validation_error.py +22 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/validation_error_loc_item.py +5 -0
- hydradb_sdk-0.0.1/src/hydra_db/types/vector_store_chunk.py +77 -0
- hydradb_sdk-0.0.1/src/hydra_db/upload/__init__.py +4 -0
- hydradb_sdk-0.0.1/src/hydra_db/upload/client.py +514 -0
- hydradb_sdk-0.0.1/src/hydra_db/upload/raw_client.py +1191 -0
- hydradb_sdk-0.0.1/src/hydradb_sdk.egg-info/PKG-INFO +607 -0
- hydradb_sdk-0.0.1/src/hydradb_sdk.egg-info/SOURCES.txt +144 -0
- hydradb_sdk-0.0.1/src/hydradb_sdk.egg-info/dependency_links.txt +1 -0
- hydradb_sdk-0.0.1/src/hydradb_sdk.egg-info/requires.txt +2 -0
- hydradb_sdk-0.0.1/src/hydradb_sdk.egg-info/top_level.txt +1 -0
- hydradb_sdk-0.0.1/tests/test_sdk.py +656 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2026 Hydra DB
|
|
2
|
+
|
|
3
|
+
All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
PROPRIETARY AND CONFIDENTIAL
|
|
6
|
+
|
|
7
|
+
This software is the proprietary and confidential property of AGI Context, INC ("the Company").
|
|
8
|
+
Permission is hereby granted to users to install and use this software as part of the Hydra DB service, subject to the terms and conditions of the service agreement entered into with the Company.
|
|
9
|
+
|
|
10
|
+
You may not, without the express written permission of the Company:
|
|
11
|
+
|
|
12
|
+
1. Copy, modify, or create derivative works of the software.
|
|
13
|
+
2. Distribute, sell, rent, lease, sublicense, or otherwise transfer the software to any third party.
|
|
14
|
+
3. Reverse engineer, decompile, or disassemble the software, except and only to the extent that such activity is expressly permitted by applicable law notwithstanding this limitation.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hydradb-sdk
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: The official Python SDK for the Hydra DB (hydradb.com)
|
|
5
|
+
Author-email: Nishkarsh Srivastava <nishkarsh@hydradb.com>
|
|
6
|
+
License: Copyright (c) 2026 Hydra DB
|
|
7
|
+
|
|
8
|
+
All Rights Reserved.
|
|
9
|
+
|
|
10
|
+
PROPRIETARY AND CONFIDENTIAL
|
|
11
|
+
|
|
12
|
+
This software is the proprietary and confidential property of AGI Context, INC ("the Company").
|
|
13
|
+
Permission is hereby granted to users to install and use this software as part of the Hydra DB service, subject to the terms and conditions of the service agreement entered into with the Company.
|
|
14
|
+
|
|
15
|
+
You may not, without the express written permission of the Company:
|
|
16
|
+
|
|
17
|
+
1. Copy, modify, or create derivative works of the software.
|
|
18
|
+
2. Distribute, sell, rent, lease, sublicense, or otherwise transfer the software to any third party.
|
|
19
|
+
3. Reverse engineer, decompile, or disassemble the software, except and only to the extent that such activity is expressly permitted by applicable law notwithstanding this limitation.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
Project-URL: Homepage, https://hydradb.com/
|
|
29
|
+
Project-URL: Documentation, https://docs.hydradb.com/
|
|
30
|
+
Keywords: hydradb-sdk,hydradb,ai,sdk,api,generative ai,rag,db
|
|
31
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
32
|
+
Classifier: Programming Language :: Python :: 3
|
|
33
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
37
|
+
Classifier: Intended Audience :: Developers
|
|
38
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
39
|
+
Classifier: Typing :: Typed
|
|
40
|
+
Requires-Python: >=3.10
|
|
41
|
+
Description-Content-Type: text/markdown
|
|
42
|
+
License-File: LICENSE
|
|
43
|
+
Requires-Dist: httpx>=0.24
|
|
44
|
+
Requires-Dist: pydantic<3,>=1.10
|
|
45
|
+
Dynamic: license-file
|
|
46
|
+
|
|
47
|
+
# Hydra DB Python SDK - [hydradb.com](https://www.hydradb.com/)
|
|
48
|
+
|
|
49
|
+
The official Python SDK for the Hydra DB platform. Build powerful, context-aware AI applications in your Python applications.
|
|
50
|
+
|
|
51
|
+
**Hydra DB** is your plug-and-play memory infrastructure. It powers intelligent, context-aware retrieval for any AI app or agent. Whether you're building a customer support bot, research copilot, or internal knowledge assistant.
|
|
52
|
+
|
|
53
|
+
[Learn more about the SDK from our docs](https://docs.hydradb.com)
|
|
54
|
+
|
|
55
|
+
## Core features
|
|
56
|
+
|
|
57
|
+
* **Dynamic retrieval and querying** that always retrieves the most relevant context
|
|
58
|
+
* **Built-in long-term memory** that evolves with every user interaction
|
|
59
|
+
* **Personalization hooks** for user preferences, intent, and history
|
|
60
|
+
* **Raw embeddings support** for bring-your-own vector workflows
|
|
61
|
+
* **Developer-first SDK** with full type safety and IDE autocompletion
|
|
62
|
+
|
|
63
|
+
## Getting started
|
|
64
|
+
|
|
65
|
+
### Installation
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install hydra-db-python
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Client setup
|
|
72
|
+
|
|
73
|
+
Both synchronous and asynchronous clients are available. Use `AsyncHydraDB` for async/await patterns and `HydraDB` for traditional synchronous workflows. Both expose the exact same set of methods.
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
import os
|
|
77
|
+
from hydra_db import HydraDB, AsyncHydraDB
|
|
78
|
+
|
|
79
|
+
api_key = os.environ["HYDRA_DB_API_KEY"]
|
|
80
|
+
|
|
81
|
+
# Sync client
|
|
82
|
+
client = HydraDB(token=api_key)
|
|
83
|
+
|
|
84
|
+
# Async client
|
|
85
|
+
async_client = AsyncHydraDB(token=api_key)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Tenant Management
|
|
91
|
+
|
|
92
|
+
A `tenant` is a single isolated database. Within it you can create further isolated collections called `sub-tenants`. [Learn more](https://docs.hydradb.com/essentials/multi-tenant)
|
|
93
|
+
|
|
94
|
+
### Create a Tenant
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
response = client.tenant.create(tenant_id="my-company")
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
You can also create a tenant optimised for raw vector embeddings:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
response = client.tenant.create(
|
|
104
|
+
tenant_id="my-embeddings-tenant",
|
|
105
|
+
is_embeddings_tenant=True,
|
|
106
|
+
embeddings_dimension=1536,
|
|
107
|
+
)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Get Sub-Tenant IDs
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
sub_tenants = client.tenant.get_sub_tenant_ids(tenant_id="my-company")
|
|
114
|
+
# sub_tenants.sub_tenant_ids -> list of sub-tenant ID strings
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Get Infrastructure Status
|
|
118
|
+
|
|
119
|
+
Check whether the tenant's underlying infrastructure is ready:
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
status = client.tenant.get_infra_status(tenant_id="my-company")
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Monitor Tenant Stats
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
stats = client.tenant.monitor(tenant_id="my-company")
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Delete a Tenant
|
|
132
|
+
|
|
133
|
+
> **Warning:** This is irreversible and permanently removes all data.
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
client.tenant.delete_tenant(tenant_id="my-company")
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Index Your Data
|
|
142
|
+
|
|
143
|
+
### Upload Knowledge (Files)
|
|
144
|
+
|
|
145
|
+
Upload documents to make them retrievable via natural language search.
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
with open("report.pdf", "rb") as f:
|
|
149
|
+
result = client.upload.knowledge(
|
|
150
|
+
tenant_id="my-company",
|
|
151
|
+
sub_tenant_id="my-sub-tenant",
|
|
152
|
+
files=[("report.pdf", f, "application/pdf")],
|
|
153
|
+
upsert=True,
|
|
154
|
+
)
|
|
155
|
+
# result.results[0].source_id -> ID you can use later
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
You can attach metadata to each file. Pass it as a **JSON string** — each object corresponds to the file at the same index:
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
import json
|
|
162
|
+
|
|
163
|
+
file_metadata = json.dumps([
|
|
164
|
+
{
|
|
165
|
+
"id": "doc_a",
|
|
166
|
+
"tenant_metadata": {"dept": "sales"},
|
|
167
|
+
"document_metadata": {"author": "Alice"},
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"id": "doc_b",
|
|
171
|
+
"tenant_metadata": {"dept": "marketing"},
|
|
172
|
+
"document_metadata": {"author": "Bob"},
|
|
173
|
+
"relations": {
|
|
174
|
+
"cortex_source_ids": ["doc_a"],
|
|
175
|
+
"properties": {"relation": "same_upload_batch"},
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
])
|
|
179
|
+
|
|
180
|
+
with open("a.pdf", "rb") as f1, open("b.pdf", "rb") as f2:
|
|
181
|
+
result = client.upload.knowledge(
|
|
182
|
+
tenant_id="my-company",
|
|
183
|
+
sub_tenant_id="my-sub-tenant",
|
|
184
|
+
files=[
|
|
185
|
+
("a.pdf", f1, "application/pdf"),
|
|
186
|
+
("b.pdf", f2, "application/pdf"),
|
|
187
|
+
],
|
|
188
|
+
file_metadata=file_metadata,
|
|
189
|
+
upsert=True,
|
|
190
|
+
)
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Verify Processing Status
|
|
194
|
+
|
|
195
|
+
After uploading, check when files have finished indexing:
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
status = client.upload.verify_processing(
|
|
199
|
+
tenant_id="my-company",
|
|
200
|
+
sub_tenant_id="my-sub-tenant",
|
|
201
|
+
file_ids=["source-id-1", "source-id-2"],
|
|
202
|
+
)
|
|
203
|
+
# status.statuses[0].indexing_status -> "queued" | "processing" | "completed" | "errored"
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Add Memories
|
|
207
|
+
|
|
208
|
+
Index free-form text, markdown content, or conversation pairs as searchable memories.
|
|
209
|
+
|
|
210
|
+
**Plain text:**
|
|
211
|
+
|
|
212
|
+
```python
|
|
213
|
+
result = client.upload.add_memory(
|
|
214
|
+
tenant_id="my-company",
|
|
215
|
+
sub_tenant_id="my-sub-tenant",
|
|
216
|
+
upsert=True,
|
|
217
|
+
memories=[
|
|
218
|
+
{
|
|
219
|
+
"text": "User prefers detailed explanations and dark mode",
|
|
220
|
+
"infer": True,
|
|
221
|
+
"user_name": "John",
|
|
222
|
+
}
|
|
223
|
+
],
|
|
224
|
+
)
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
**Markdown:**
|
|
228
|
+
|
|
229
|
+
```python
|
|
230
|
+
result = client.upload.add_memory(
|
|
231
|
+
tenant_id="my-company",
|
|
232
|
+
sub_tenant_id="my-sub-tenant",
|
|
233
|
+
upsert=True,
|
|
234
|
+
memories=[
|
|
235
|
+
{
|
|
236
|
+
"text": "# Meeting Notes\n\n## Key Points\n- Budget approved\n- Launch date: Q2",
|
|
237
|
+
"is_markdown": True,
|
|
238
|
+
"infer": False,
|
|
239
|
+
"title": "Meeting Notes",
|
|
240
|
+
}
|
|
241
|
+
],
|
|
242
|
+
)
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**User–assistant conversation pairs:**
|
|
246
|
+
|
|
247
|
+
```python
|
|
248
|
+
result = client.upload.add_memory(
|
|
249
|
+
tenant_id="my-company",
|
|
250
|
+
sub_tenant_id="my-sub-tenant",
|
|
251
|
+
upsert=True,
|
|
252
|
+
memories=[
|
|
253
|
+
{
|
|
254
|
+
"user_assistant_pairs": [
|
|
255
|
+
{"user": "What are my preferences?", "assistant": "You prefer dark mode and detailed explanations."},
|
|
256
|
+
{"user": "How do I like my reports?", "assistant": "You prefer weekly summary reports with charts."},
|
|
257
|
+
],
|
|
258
|
+
"infer": True,
|
|
259
|
+
"user_name": "John",
|
|
260
|
+
"custom_instructions": "Extract user preferences",
|
|
261
|
+
}
|
|
262
|
+
],
|
|
263
|
+
)
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Delete a Memory
|
|
267
|
+
|
|
268
|
+
```python
|
|
269
|
+
client.upload.delete_memory(
|
|
270
|
+
tenant_id="my-company",
|
|
271
|
+
sub_tenant_id="my-sub-tenant",
|
|
272
|
+
memory_id="memory-source-id",
|
|
273
|
+
)
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## Search & Retrieval
|
|
279
|
+
|
|
280
|
+
### Full Recall
|
|
281
|
+
|
|
282
|
+
Hybrid semantic + keyword search across both knowledge and memories:
|
|
283
|
+
|
|
284
|
+
```python
|
|
285
|
+
results = client.recall.full_recall(
|
|
286
|
+
tenant_id="my-company",
|
|
287
|
+
sub_tenant_id="my-sub-tenant",
|
|
288
|
+
query="Which mode does the user prefer?",
|
|
289
|
+
alpha=0.8, # 1.0 = pure semantic, 0.0 = pure keyword
|
|
290
|
+
recency_bias=0, # 0.0 = no bias, 1.0 = strongly prefer recent
|
|
291
|
+
max_results=10,
|
|
292
|
+
)
|
|
293
|
+
# results.chunks -> list of VectorStoreChunk
|
|
294
|
+
# results.sources -> list of SourceInfo
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Recall Preferences
|
|
298
|
+
|
|
299
|
+
Search only user memory/preference data:
|
|
300
|
+
|
|
301
|
+
```python
|
|
302
|
+
preferences = client.recall.recall_preferences(
|
|
303
|
+
tenant_id="my-company",
|
|
304
|
+
sub_tenant_id="my-sub-tenant",
|
|
305
|
+
query="dark mode preference",
|
|
306
|
+
max_results=5,
|
|
307
|
+
)
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Boolean Recall
|
|
311
|
+
|
|
312
|
+
Exact keyword / phrase / boolean search (BM25):
|
|
313
|
+
|
|
314
|
+
```python
|
|
315
|
+
results = client.recall.boolean_recall(
|
|
316
|
+
tenant_id="my-company",
|
|
317
|
+
sub_tenant_id="my-sub-tenant",
|
|
318
|
+
query="dark mode",
|
|
319
|
+
operator="phrase", # "or" | "and" | "phrase"
|
|
320
|
+
max_results=10,
|
|
321
|
+
search_mode="memories", # "sources" | "memories"
|
|
322
|
+
)
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### Q&A (LLM-powered answer)
|
|
326
|
+
|
|
327
|
+
Ask a question and get a grounded answer generated by an LLM over your indexed content:
|
|
328
|
+
|
|
329
|
+
```python
|
|
330
|
+
answer = client.recall.qna(
|
|
331
|
+
tenant_id="my-company",
|
|
332
|
+
sub_tenant_id="my-sub-tenant",
|
|
333
|
+
question="What is the user's preferred reporting format?",
|
|
334
|
+
mode="fast", # "fast" | "thinking"
|
|
335
|
+
search_mode="memories",
|
|
336
|
+
max_chunks=6,
|
|
337
|
+
)
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
You can optionally choose the LLM provider and model:
|
|
341
|
+
|
|
342
|
+
```python
|
|
343
|
+
answer = client.recall.qna(
|
|
344
|
+
tenant_id="my-company",
|
|
345
|
+
sub_tenant_id="my-sub-tenant",
|
|
346
|
+
question="Summarise the budget decisions from the meeting notes.",
|
|
347
|
+
mode="thinking",
|
|
348
|
+
search_mode="sources",
|
|
349
|
+
max_chunks=10,
|
|
350
|
+
llm_provider="anthropic",
|
|
351
|
+
model="claude-sonnet-4-6",
|
|
352
|
+
temperature=0.2,
|
|
353
|
+
max_tokens=1024,
|
|
354
|
+
)
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
## Fetch & Inspect Data
|
|
360
|
+
|
|
361
|
+
### List All Data
|
|
362
|
+
|
|
363
|
+
List sources (knowledge) or memories with optional filtering and pagination:
|
|
364
|
+
|
|
365
|
+
```python
|
|
366
|
+
# List knowledge sources
|
|
367
|
+
sources = client.fetch.list_data(
|
|
368
|
+
tenant_id="my-company",
|
|
369
|
+
sub_tenant_id="my-sub-tenant",
|
|
370
|
+
kind="knowledge",
|
|
371
|
+
page=1,
|
|
372
|
+
page_size=50,
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
# List user memories
|
|
376
|
+
memories = client.fetch.list_data(
|
|
377
|
+
tenant_id="my-company",
|
|
378
|
+
sub_tenant_id="my-sub-tenant",
|
|
379
|
+
kind="memories",
|
|
380
|
+
)
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
Filter by metadata:
|
|
384
|
+
|
|
385
|
+
```python
|
|
386
|
+
filtered = client.fetch.list_data(
|
|
387
|
+
tenant_id="my-company",
|
|
388
|
+
sub_tenant_id="my-sub-tenant",
|
|
389
|
+
kind="knowledge",
|
|
390
|
+
filters={"tenant_metadata": {"dept": "sales"}},
|
|
391
|
+
)
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### Fetch Source Content
|
|
395
|
+
|
|
396
|
+
Retrieve the full content of a specific source by its ID:
|
|
397
|
+
|
|
398
|
+
```python
|
|
399
|
+
source = client.fetch.content(
|
|
400
|
+
tenant_id="my-company",
|
|
401
|
+
sub_tenant_id="my-sub-tenant",
|
|
402
|
+
source_id="your-source-id",
|
|
403
|
+
mode="content", # "content" | "url" | "both"
|
|
404
|
+
)
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### Fetch Graph Relations
|
|
408
|
+
|
|
409
|
+
Retrieve the graph relations (linked sources) for a given source:
|
|
410
|
+
|
|
411
|
+
```python
|
|
412
|
+
relations = client.fetch.graph_relations_by_source_id(
|
|
413
|
+
tenant_id="my-company",
|
|
414
|
+
sub_tenant_id="my-sub-tenant",
|
|
415
|
+
source_id="your-source-id",
|
|
416
|
+
is_memory=False,
|
|
417
|
+
limit=10,
|
|
418
|
+
)
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
---
|
|
422
|
+
|
|
423
|
+
## Delete Data
|
|
424
|
+
|
|
425
|
+
Delete one or more sources (knowledge or memories) by their IDs:
|
|
426
|
+
|
|
427
|
+
```python
|
|
428
|
+
client.data.delete(
|
|
429
|
+
tenant_id="my-company",
|
|
430
|
+
sub_tenant_id="my-sub-tenant",
|
|
431
|
+
ids=["source-id-1", "source-id-2"],
|
|
432
|
+
)
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
---
|
|
436
|
+
|
|
437
|
+
## API Key Management
|
|
438
|
+
|
|
439
|
+
> **Note:** This endpoint requires a dashboard session token (obtained via your Hydra DB dashboard login), not a standard API key.
|
|
440
|
+
|
|
441
|
+
```python
|
|
442
|
+
new_key = client.key.create_api_key(
|
|
443
|
+
owner="service-account@myapp.com",
|
|
444
|
+
scopes=["query"],
|
|
445
|
+
env="live",
|
|
446
|
+
prefix="sk",
|
|
447
|
+
)
|
|
448
|
+
# new_key.full_api_key -> the actual key (only shown once)
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
## Raw Embeddings
|
|
454
|
+
|
|
455
|
+
Use Hydra DB as a vector store with your own embeddings.
|
|
456
|
+
|
|
457
|
+
> **Note:** Raw embeddings require a tenant created with `is_embeddings_tenant=True` and a fixed `embeddings_dimension`. A standard knowledge tenant does not support raw embedding operations.
|
|
458
|
+
|
|
459
|
+
### Insert Embeddings
|
|
460
|
+
|
|
461
|
+
```python
|
|
462
|
+
client.embeddings.insert(
|
|
463
|
+
tenant_id="my-embeddings-tenant",
|
|
464
|
+
sub_tenant_id="my-sub-tenant",
|
|
465
|
+
upsert=True,
|
|
466
|
+
embeddings=[
|
|
467
|
+
{
|
|
468
|
+
"source_id": "my-doc-001",
|
|
469
|
+
"metadata": {"category": "finance", "year": 2024},
|
|
470
|
+
"embeddings": [
|
|
471
|
+
{"chunk_id": "my-doc-001-chunk-0", "embedding": [0.1, 0.2, 0.3]}, # 1536 dims
|
|
472
|
+
{"chunk_id": "my-doc-001-chunk-1", "embedding": [0.4, 0.5, 0.6]},
|
|
473
|
+
],
|
|
474
|
+
}
|
|
475
|
+
],
|
|
476
|
+
)
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
### Search by Vector
|
|
480
|
+
|
|
481
|
+
```python
|
|
482
|
+
results = client.embeddings.search(
|
|
483
|
+
tenant_id="my-embeddings-tenant",
|
|
484
|
+
sub_tenant_id="my-sub-tenant",
|
|
485
|
+
query_embedding=[0.1, 0.2, 0.3], # 1536 dims
|
|
486
|
+
limit=10,
|
|
487
|
+
)
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### Filter Embeddings
|
|
491
|
+
|
|
492
|
+
```python
|
|
493
|
+
# By source
|
|
494
|
+
by_source = client.embeddings.filter(
|
|
495
|
+
tenant_id="my-embeddings-tenant",
|
|
496
|
+
sub_tenant_id="my-sub-tenant",
|
|
497
|
+
source_id="my-doc-001",
|
|
498
|
+
limit=50,
|
|
499
|
+
)
|
|
500
|
+
|
|
501
|
+
# By chunk IDs
|
|
502
|
+
by_chunks = client.embeddings.filter(
|
|
503
|
+
tenant_id="my-embeddings-tenant",
|
|
504
|
+
sub_tenant_id="my-sub-tenant",
|
|
505
|
+
chunk_ids=["my-doc-001-chunk-0", "my-doc-001-chunk-1"],
|
|
506
|
+
)
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
### Delete Embeddings
|
|
510
|
+
|
|
511
|
+
```python
|
|
512
|
+
# Delete all embeddings for a source
|
|
513
|
+
client.embeddings.delete(
|
|
514
|
+
tenant_id="my-embeddings-tenant",
|
|
515
|
+
sub_tenant_id="my-sub-tenant",
|
|
516
|
+
source_id="my-doc-001",
|
|
517
|
+
)
|
|
518
|
+
|
|
519
|
+
# Delete specific chunks
|
|
520
|
+
client.embeddings.delete(
|
|
521
|
+
tenant_id="my-embeddings-tenant",
|
|
522
|
+
sub_tenant_id="my-sub-tenant",
|
|
523
|
+
chunk_ids=["my-doc-001-chunk-0"],
|
|
524
|
+
)
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
---
|
|
528
|
+
|
|
529
|
+
## Async Usage
|
|
530
|
+
|
|
531
|
+
Every method has an async equivalent on `AsyncHydraDB`. Method names and parameters are identical:
|
|
532
|
+
|
|
533
|
+
```python
|
|
534
|
+
import asyncio
|
|
535
|
+
from hydra_db import AsyncHydraDB
|
|
536
|
+
|
|
537
|
+
async_client = AsyncHydraDB(token="your-api-key")
|
|
538
|
+
|
|
539
|
+
async def main():
|
|
540
|
+
result = await async_client.recall.full_recall(
|
|
541
|
+
tenant_id="my-company",
|
|
542
|
+
sub_tenant_id="my-sub-tenant",
|
|
543
|
+
query="Which mode does the user prefer?",
|
|
544
|
+
alpha=0.8,
|
|
545
|
+
max_results=10,
|
|
546
|
+
)
|
|
547
|
+
print(result.chunks)
|
|
548
|
+
|
|
549
|
+
asyncio.run(main())
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
---
|
|
553
|
+
|
|
554
|
+
## SDK Method Reference
|
|
555
|
+
|
|
556
|
+
| Method | Description |
|
|
557
|
+
|---|---|
|
|
558
|
+
| `client.tenant.create` | Create a new tenant (standard or embeddings) |
|
|
559
|
+
| `client.tenant.get_sub_tenant_ids` | List all sub-tenant IDs within a tenant |
|
|
560
|
+
| `client.tenant.get_infra_status` | Check tenant infrastructure readiness |
|
|
561
|
+
| `client.tenant.monitor` | Get tenant usage and stats |
|
|
562
|
+
| `client.tenant.delete_tenant` | Permanently delete a tenant and all its data |
|
|
563
|
+
| `client.upload.knowledge` | Upload files to the knowledge base |
|
|
564
|
+
| `client.upload.verify_processing` | Poll indexing status of uploaded files |
|
|
565
|
+
| `client.upload.add_memory` | Index text, markdown, or conversation pairs as memories |
|
|
566
|
+
| `client.upload.delete_memory` | Delete a specific memory by ID |
|
|
567
|
+
| `client.recall.full_recall` | Hybrid semantic + keyword search |
|
|
568
|
+
| `client.recall.recall_preferences` | Search user memory / preference data only |
|
|
569
|
+
| `client.recall.boolean_recall` | Exact keyword / phrase / boolean search |
|
|
570
|
+
| `client.recall.qna` | LLM-powered question answering over indexed content |
|
|
571
|
+
| `client.fetch.list_data` | List all knowledge sources or memories |
|
|
572
|
+
| `client.fetch.content` | Fetch full content of a source by ID |
|
|
573
|
+
| `client.fetch.graph_relations_by_source_id` | Fetch graph relations for a source |
|
|
574
|
+
| `client.data.delete` | Delete sources or memories by ID |
|
|
575
|
+
| `client.key.create_api_key` | Create a scoped API key *(requires dashboard session token)* |
|
|
576
|
+
| `client.embeddings.insert` | Store raw vector embeddings *(requires embeddings tenant)* |
|
|
577
|
+
| `client.embeddings.search` | Vector similarity search |
|
|
578
|
+
| `client.embeddings.filter` | Retrieve embeddings by source or chunk IDs |
|
|
579
|
+
| `client.embeddings.delete` | Delete embeddings by source or chunk IDs |
|
|
580
|
+
|
|
581
|
+
> **Method Mapping:** `client.<group>.<method>` mirrors `api.hydradb.com/<group>/<method>`
|
|
582
|
+
>
|
|
583
|
+
> For example: `client.upload.knowledge()` → `POST /ingestion/upload_knowledge`
|
|
584
|
+
|
|
585
|
+
---
|
|
586
|
+
|
|
587
|
+
## Type Safety & IDE Support
|
|
588
|
+
|
|
589
|
+
The SDK provides exact type parity with the API:
|
|
590
|
+
|
|
591
|
+
- **Request parameters** — every field (required, optional, type, validation) is reflected in method signatures
|
|
592
|
+
- **Response objects** — return types are fully typed Pydantic models matching the API JSON schema
|
|
593
|
+
- **Nested objects** — complex parameters and responses preserve their full structure
|
|
594
|
+
|
|
595
|
+
Your IDE will automatically provide autocompletion, type-checking, inline documentation, and compile-time validation. Just hit **Cmd+Space / Ctrl+Space**.
|
|
596
|
+
|
|
597
|
+
---
|
|
598
|
+
|
|
599
|
+
## Links
|
|
600
|
+
|
|
601
|
+
- **Homepage:** [hydradb.com](https://www.hydradb.com/)
|
|
602
|
+
- **Documentation:** [docs.hydradb.com](https://docs.hydradb.com/)
|
|
603
|
+
- **API Reference:** [docs.hydradb.com/api-reference/introduction](https://docs.hydradb.com/api-reference/introduction)
|
|
604
|
+
|
|
605
|
+
## Support
|
|
606
|
+
|
|
607
|
+
If you have any questions or need help, reach out at [founders@hydradb.com](mailto:founders@usecortex.ai).
|