hydra-db-python 0.1.3__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.
Files changed (120) hide show
  1. hydra_db_python-0.1.3/LICENSE +22 -0
  2. hydra_db_python-0.1.3/PKG-INFO +229 -0
  3. hydra_db_python-0.1.3/README.md +184 -0
  4. hydra_db_python-0.1.3/pyproject.toml +40 -0
  5. hydra_db_python-0.1.3/setup.cfg +4 -0
  6. hydra_db_python-0.1.3/src/hydra_db/__init__.py +160 -0
  7. hydra_db_python-0.1.3/src/hydra_db/client.py +245 -0
  8. hydra_db_python-0.1.3/src/hydra_db/core/__init__.py +52 -0
  9. hydra_db_python-0.1.3/src/hydra_db/core/api_error.py +23 -0
  10. hydra_db_python-0.1.3/src/hydra_db/core/client_wrapper.py +84 -0
  11. hydra_db_python-0.1.3/src/hydra_db/core/datetime_utils.py +28 -0
  12. hydra_db_python-0.1.3/src/hydra_db/core/file.py +67 -0
  13. hydra_db_python-0.1.3/src/hydra_db/core/force_multipart.py +18 -0
  14. hydra_db_python-0.1.3/src/hydra_db/core/http_client.py +543 -0
  15. hydra_db_python-0.1.3/src/hydra_db/core/http_response.py +55 -0
  16. hydra_db_python-0.1.3/src/hydra_db/core/jsonable_encoder.py +100 -0
  17. hydra_db_python-0.1.3/src/hydra_db/core/pydantic_utilities.py +258 -0
  18. hydra_db_python-0.1.3/src/hydra_db/core/query_encoder.py +58 -0
  19. hydra_db_python-0.1.3/src/hydra_db/core/remove_none_from_dict.py +11 -0
  20. hydra_db_python-0.1.3/src/hydra_db/core/request_options.py +35 -0
  21. hydra_db_python-0.1.3/src/hydra_db/core/serialization.py +276 -0
  22. hydra_db_python-0.1.3/src/hydra_db/data/__init__.py +4 -0
  23. hydra_db_python-0.1.3/src/hydra_db/data/client.py +123 -0
  24. hydra_db_python-0.1.3/src/hydra_db/data/raw_client.py +295 -0
  25. hydra_db_python-0.1.3/src/hydra_db/embeddings/__init__.py +4 -0
  26. hydra_db_python-0.1.3/src/hydra_db/embeddings/client.py +486 -0
  27. hydra_db_python-0.1.3/src/hydra_db/embeddings/raw_client.py +1183 -0
  28. hydra_db_python-0.1.3/src/hydra_db/environment.py +7 -0
  29. hydra_db_python-0.1.3/src/hydra_db/errors/__init__.py +23 -0
  30. hydra_db_python-0.1.3/src/hydra_db/errors/bad_request_error.py +10 -0
  31. hydra_db_python-0.1.3/src/hydra_db/errors/forbidden_error.py +10 -0
  32. hydra_db_python-0.1.3/src/hydra_db/errors/internal_server_error.py +10 -0
  33. hydra_db_python-0.1.3/src/hydra_db/errors/not_found_error.py +10 -0
  34. hydra_db_python-0.1.3/src/hydra_db/errors/service_unavailable_error.py +10 -0
  35. hydra_db_python-0.1.3/src/hydra_db/errors/too_many_requests_error.py +11 -0
  36. hydra_db_python-0.1.3/src/hydra_db/errors/unauthorized_error.py +10 -0
  37. hydra_db_python-0.1.3/src/hydra_db/errors/unprocessable_entity_error.py +10 -0
  38. hydra_db_python-0.1.3/src/hydra_db/fetch/__init__.py +7 -0
  39. hydra_db_python-0.1.3/src/hydra_db/fetch/client.py +408 -0
  40. hydra_db_python-0.1.3/src/hydra_db/fetch/raw_client.py +927 -0
  41. hydra_db_python-0.1.3/src/hydra_db/fetch/types/__init__.py +7 -0
  42. hydra_db_python-0.1.3/src/hydra_db/fetch/types/fetch_list_data_response.py +8 -0
  43. hydra_db_python-0.1.3/src/hydra_db/key/__init__.py +4 -0
  44. hydra_db_python-0.1.3/src/hydra_db/key/client.py +135 -0
  45. hydra_db_python-0.1.3/src/hydra_db/key/raw_client.py +309 -0
  46. hydra_db_python-0.1.3/src/hydra_db/raw_client.py +92 -0
  47. hydra_db_python-0.1.3/src/hydra_db/recall/__init__.py +4 -0
  48. hydra_db_python-0.1.3/src/hydra_db/recall/client.py +699 -0
  49. hydra_db_python-0.1.3/src/hydra_db/recall/raw_client.py +1490 -0
  50. hydra_db_python-0.1.3/src/hydra_db/tenant/__init__.py +4 -0
  51. hydra_db_python-0.1.3/src/hydra_db/tenant/client.py +380 -0
  52. hydra_db_python-0.1.3/src/hydra_db/tenant/raw_client.py +1259 -0
  53. hydra_db_python-0.1.3/src/hydra_db/types/__init__.py +125 -0
  54. hydra_db_python-0.1.3/src/hydra_db/types/actual_error_response.py +20 -0
  55. hydra_db_python-0.1.3/src/hydra_db/types/add_memory_response.py +39 -0
  56. hydra_db_python-0.1.3/src/hydra_db/types/alpha.py +5 -0
  57. hydra_db_python-0.1.3/src/hydra_db/types/api_key_create_response.py +48 -0
  58. hydra_db_python-0.1.3/src/hydra_db/types/attachment_model.py +53 -0
  59. hydra_db_python-0.1.3/src/hydra_db/types/batch_processing_status.py +23 -0
  60. hydra_db_python-0.1.3/src/hydra_db/types/bm_25_operator_type.py +5 -0
  61. hydra_db_python-0.1.3/src/hydra_db/types/collection_stats.py +27 -0
  62. hydra_db_python-0.1.3/src/hydra_db/types/content_filter.py +49 -0
  63. hydra_db_python-0.1.3/src/hydra_db/types/content_model.py +53 -0
  64. hydra_db_python-0.1.3/src/hydra_db/types/custom_property_definition.py +75 -0
  65. hydra_db_python-0.1.3/src/hydra_db/types/delete_result.py +36 -0
  66. hydra_db_python-0.1.3/src/hydra_db/types/delete_user_memory_response.py +31 -0
  67. hydra_db_python-0.1.3/src/hydra_db/types/entity.py +42 -0
  68. hydra_db_python-0.1.3/src/hydra_db/types/error_response.py +21 -0
  69. hydra_db_python-0.1.3/src/hydra_db/types/fetch_mode.py +5 -0
  70. hydra_db_python-0.1.3/src/hydra_db/types/forceful_relations_payload.py +27 -0
  71. hydra_db_python-0.1.3/src/hydra_db/types/graph_context.py +26 -0
  72. hydra_db_python-0.1.3/src/hydra_db/types/infra.py +21 -0
  73. hydra_db_python-0.1.3/src/hydra_db/types/infra_status_response.py +42 -0
  74. hydra_db_python-0.1.3/src/hydra_db/types/insert_result.py +41 -0
  75. hydra_db_python-0.1.3/src/hydra_db/types/list_content_kind.py +5 -0
  76. hydra_db_python-0.1.3/src/hydra_db/types/list_user_memories_response.py +43 -0
  77. hydra_db_python-0.1.3/src/hydra_db/types/memory_item.py +88 -0
  78. hydra_db_python-0.1.3/src/hydra_db/types/memory_result_item.py +47 -0
  79. hydra_db_python-0.1.3/src/hydra_db/types/milvus_data_type.py +21 -0
  80. hydra_db_python-0.1.3/src/hydra_db/types/pagination_meta.py +51 -0
  81. hydra_db_python-0.1.3/src/hydra_db/types/path_triplet.py +23 -0
  82. hydra_db_python-0.1.3/src/hydra_db/types/processing_status.py +43 -0
  83. hydra_db_python-0.1.3/src/hydra_db/types/processing_status_indexing_status.py +7 -0
  84. hydra_db_python-0.1.3/src/hydra_db/types/qn_a_search_response.py +49 -0
  85. hydra_db_python-0.1.3/src/hydra_db/types/raw_embedding_document.py +47 -0
  86. hydra_db_python-0.1.3/src/hydra_db/types/raw_embedding_search_result.py +47 -0
  87. hydra_db_python-0.1.3/src/hydra_db/types/raw_embedding_vector.py +31 -0
  88. hydra_db_python-0.1.3/src/hydra_db/types/recall_search_request.py +78 -0
  89. hydra_db_python-0.1.3/src/hydra_db/types/relation_evidence.py +72 -0
  90. hydra_db_python-0.1.3/src/hydra_db/types/retrieval_result.py +36 -0
  91. hydra_db_python-0.1.3/src/hydra_db/types/retrieve_mode.py +5 -0
  92. hydra_db_python-0.1.3/src/hydra_db/types/scored_path_response.py +31 -0
  93. hydra_db_python-0.1.3/src/hydra_db/types/search_mode.py +5 -0
  94. hydra_db_python-0.1.3/src/hydra_db/types/source_delete_response.py +30 -0
  95. hydra_db_python-0.1.3/src/hydra_db/types/source_delete_result_item.py +36 -0
  96. hydra_db_python-0.1.3/src/hydra_db/types/source_fetch_response.py +70 -0
  97. hydra_db_python-0.1.3/src/hydra_db/types/source_graph_relations_response.py +33 -0
  98. hydra_db_python-0.1.3/src/hydra_db/types/source_info.py +57 -0
  99. hydra_db_python-0.1.3/src/hydra_db/types/source_list_response.py +32 -0
  100. hydra_db_python-0.1.3/src/hydra_db/types/source_model.py +99 -0
  101. hydra_db_python-0.1.3/src/hydra_db/types/source_status.py +5 -0
  102. hydra_db_python-0.1.3/src/hydra_db/types/source_upload_response.py +35 -0
  103. hydra_db_python-0.1.3/src/hydra_db/types/source_upload_result_item.py +38 -0
  104. hydra_db_python-0.1.3/src/hydra_db/types/sub_tenant_ids_response.py +31 -0
  105. hydra_db_python-0.1.3/src/hydra_db/types/supported_llm_providers.py +5 -0
  106. hydra_db_python-0.1.3/src/hydra_db/types/tenant_create_accepted_response.py +36 -0
  107. hydra_db_python-0.1.3/src/hydra_db/types/tenant_delete_response.py +25 -0
  108. hydra_db_python-0.1.3/src/hydra_db/types/tenant_stats_response.py +38 -0
  109. hydra_db_python-0.1.3/src/hydra_db/types/triplet_with_evidence.py +35 -0
  110. hydra_db_python-0.1.3/src/hydra_db/types/user_assistant_pair.py +31 -0
  111. hydra_db_python-0.1.3/src/hydra_db/types/user_memory.py +31 -0
  112. hydra_db_python-0.1.3/src/hydra_db/types/vector_store_chunk.py +77 -0
  113. hydra_db_python-0.1.3/src/hydra_db/upload/__init__.py +4 -0
  114. hydra_db_python-0.1.3/src/hydra_db/upload/client.py +452 -0
  115. hydra_db_python-0.1.3/src/hydra_db/upload/raw_client.py +1147 -0
  116. hydra_db_python-0.1.3/src/hydra_db_python.egg-info/PKG-INFO +229 -0
  117. hydra_db_python-0.1.3/src/hydra_db_python.egg-info/SOURCES.txt +118 -0
  118. hydra_db_python-0.1.3/src/hydra_db_python.egg-info/dependency_links.txt +1 -0
  119. hydra_db_python-0.1.3/src/hydra_db_python.egg-info/requires.txt +2 -0
  120. hydra_db_python-0.1.3/src/hydra_db_python.egg-info/top_level.txt +1 -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,229 @@
1
+ Metadata-Version: 2.4
2
+ Name: hydra-db-python
3
+ Version: 0.1.3
4
+ Summary: The official Python SDK for the Hydra DB (hydradb.com)
5
+ Author-email: Soham Ratnaparkhi <soham@usecortex.ai>
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: hydra-db,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: Intended Audience :: Developers
37
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
38
+ Classifier: Typing :: Typed
39
+ Requires-Python: >=3.10
40
+ Description-Content-Type: text/markdown
41
+ License-File: LICENSE
42
+ Requires-Dist: httpx>=0.24
43
+ Requires-Dist: pydantic<3,>=1.10
44
+ Dynamic: license-file
45
+
46
+ # Hydra DB Python SDK - [hydradb.com](https://www.hydradb.com/)
47
+
48
+ The official Python SDK for the Hydra DB platform. Build powerful, context-aware AI applications in your Python applications.
49
+
50
+ **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.
51
+
52
+ [Learn more about the SDK from our docs](https://docs.hydradb.com)
53
+
54
+ ## Core features
55
+
56
+ * **Dynamic retrieval and querying** that always retrieve the most relevant context
57
+ * **Built-in long-term memory** that evolves with every user interaction
58
+ * **Personalization hooks** for user preferences, intent, and history
59
+ * **Developer-first SDK** with the most flexible APIs and fine-grained controls
60
+
61
+ ## Getting started
62
+
63
+ ### Installation
64
+
65
+ ```bash
66
+ pip install hydra-db-python
67
+ ```
68
+
69
+ ### Client setup
70
+
71
+ We provide both synchronous and asynchronous clients. Use **`AsyncHydraDB`** when working with async/await patterns, and **`HydraDB`** for traditional synchronous workflows. Client initialization does not trigger any network requests, so you can safely create as many client instances as needed. Both clients expose the exact same set of methods.
72
+
73
+ ```python
74
+ import os
75
+ from hydra_db import HydraDB, AsyncHydraDB
76
+
77
+ api_key = os.environ["HYDRA_DB_API_KEY"] # Set your Hydra DB API key in the environment variable HYDRA_DB_API_KEY. Optional, but recommended.
78
+
79
+ # Sync client
80
+ client = HydraDB(token=api_key)
81
+
82
+ # Async client (for async/await usage)
83
+ async_client = AsyncHydraDB(token=api_key)
84
+ ```
85
+
86
+ ### Create a Tenant
87
+
88
+ You can consider a `tenant` as a single database that can have internal isolated collections called `sub-tenants`. [Know more about the concept of tenant here](https://docs.hydradb.com/essentials/multi-tenant)
89
+
90
+ ```python
91
+ def create_tenant():
92
+ return client.tenant.create(tenant_id="my-company")
93
+ ```
94
+
95
+ ### Ingest Your Data
96
+
97
+ When you index your data, you make it ready for retrieval from Hydra DB using natural language.
98
+
99
+ ```python
100
+ # ingest in your knowledge base
101
+ with open("a.pdf", 'rb') as f1, open("b.pdf", 'rb') as f2:
102
+ files = [
103
+ ("a.pdf", f1),
104
+ ("b.pdf", f2)
105
+ ]
106
+ upload_result = client.upload.knowledge(
107
+ tenant_id="tenant_123",
108
+ files=files,
109
+ file_metadata=[
110
+ {
111
+ "id": "doc_a",
112
+ "tenant_metadata": {"dept": "sales"},
113
+ "document_metadata": {"author": "Alice"}
114
+ },
115
+ {
116
+ "id": "doc_b",
117
+ "tenant_metadata": {"dept": "marketing"},
118
+ "document_metadata": {"author": "Bob"}
119
+ }
120
+ ]
121
+ ))
122
+
123
+ # Ingest user memories
124
+ from hydra_db import HydraDBClient
125
+
126
+ client = HydraDBClient(api_key="your_api_key")
127
+
128
+ # Simple text memory
129
+ result = client.user_memory.add(
130
+ memories=[
131
+ {
132
+ "text": "User prefers detailed explanations and dark mode",
133
+ "infer": True,
134
+ "user_name": "John"
135
+ }
136
+ ],
137
+ tenant_id="tenant-01",
138
+ sub_tenant_id="",
139
+ upsert=True
140
+ )
141
+
142
+ # Markdown content
143
+ markdown_result = client.user_memory.add(
144
+ memories=[
145
+ {
146
+ "text": "# Meeting Notes\n\n## Key Points\n- Budget approved",
147
+ "is_markdown": True,
148
+ "infer": False,
149
+ "title": "Meeting Notes"
150
+ }
151
+ ],
152
+ tenant_id="tenant-01",
153
+ sub_tenant_id="",
154
+ upsert=True
155
+ )
156
+
157
+ # User-assistant pairs with inference
158
+ conversation_result = client.user_memory.add(
159
+ memories=[
160
+ {
161
+ "user_assistant_pairs": [
162
+ {"user": "What are my preferences?", "assistant": "You prefer dark mode."},
163
+ {"user": "How do I like reports?", "assistant": "Weekly summaries with charts."}
164
+ ],
165
+ "infer": True,
166
+ "user_name": "John",
167
+ "custom_instructions": "Extract user preferences"
168
+ }
169
+ ],
170
+ tenant_id="tenant-01",
171
+ sub_tenant_id="",
172
+ upsert=True
173
+ )
174
+ ```
175
+
176
+ **For a more detailed explanation** of document upload, including supported file formats, processing pipeline, metadata handling, and advanced configuration options, refer to the [Ingest Knowledge endpoint](https://docs.hydradb.com/api-reference/endpoint/add-knowledge-memories).
177
+
178
+ ### Search
179
+
180
+ ```python
181
+ # Semantic Recall
182
+ results = client.recall.full_recall(
183
+ query="Which mode does user prefer",
184
+ tenant_id="tenant_1234",
185
+ sub_tenant_id="sub_tenant_4567",
186
+ alpha=0.8,
187
+ recency_bias=0
188
+ )
189
+
190
+ # Get ingested data (memories + knowledge base)
191
+ all_sources = client.data.list_data(
192
+ tenant_id="tenant_1234",
193
+ sub_tenant_id="sub_tenant_4567"
194
+ )
195
+ ```
196
+
197
+ **For a more detailed explanation** of search and retrieval, including query parameters, scoring mechanisms, result structure, and advanced search features, refer to the [Search endpoint documentation](https://docs.hydradb.com/api-reference/endpoint/search).
198
+
199
+ ## SDK Method Structure & Type Safety
200
+
201
+ Our SDKs follow a predictable pattern that mirrors the API structure while providing full type safety.
202
+
203
+ > **Method Mapping** : `client.<group>.<function_name>` mirrors `api.hydradb.com/<group>/<function_name>`
204
+ >
205
+ > For example: `client.upload.upload_text()` corresponds to `POST /upload/upload_text`
206
+
207
+ The SDKs provide exact type parity with the API specification:
208
+
209
+ - **Request Parameters** : Every field documented in the API reference (required, optional, types, validation rules) is reflected in the SDK method signatures
210
+ - **Response Objects** : Return types match the exact JSON schema documented for each endpoint
211
+ - **Error Types** : Exception structures mirror the error response formats from the API
212
+ - **Nested Objects** : Complex nested parameters and responses maintain their full structure and typing
213
+
214
+ > This means you can rely on your IDE’s autocomplete and type checking. If a parameter is optional in the API docs, it’s optional in the SDK. If a response contains a specific field, your IDE will know about it. Our SDKs are built in such a way that your IDE will automatically provide **autocompletion, type-checking, inline documentation with examples, and compile time validation** for each and every method.
215
+ >
216
+ > Just hit **Cmd+Space/Ctrl+Space**
217
+
218
+ ## Links
219
+
220
+ - **Homepage:** [hydradb.com](https://www.hydradb.com/)
221
+ - **Documentation:** [docs.usecortex.ai](https://docs.usecortex.ai/)
222
+
223
+ ## Our docs
224
+
225
+ Please refer to our [API reference](https://docs.usecortex.ai/api-reference/introduction) for detailed explanations of every API endpoint, parameter options, and advanced use cases.
226
+
227
+ ## Support
228
+
229
+ If you have any questions or need help, please reach out to our support team at [founders@usecortex.ai](mailto:founders@usecortex.ai).
@@ -0,0 +1,184 @@
1
+ # Hydra DB Python SDK - [hydradb.com](https://www.hydradb.com/)
2
+
3
+ The official Python SDK for the Hydra DB platform. Build powerful, context-aware AI applications in your Python applications.
4
+
5
+ **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.
6
+
7
+ [Learn more about the SDK from our docs](https://docs.hydradb.com)
8
+
9
+ ## Core features
10
+
11
+ * **Dynamic retrieval and querying** that always retrieve the most relevant context
12
+ * **Built-in long-term memory** that evolves with every user interaction
13
+ * **Personalization hooks** for user preferences, intent, and history
14
+ * **Developer-first SDK** with the most flexible APIs and fine-grained controls
15
+
16
+ ## Getting started
17
+
18
+ ### Installation
19
+
20
+ ```bash
21
+ pip install hydra-db-python
22
+ ```
23
+
24
+ ### Client setup
25
+
26
+ We provide both synchronous and asynchronous clients. Use **`AsyncHydraDB`** when working with async/await patterns, and **`HydraDB`** for traditional synchronous workflows. Client initialization does not trigger any network requests, so you can safely create as many client instances as needed. Both clients expose the exact same set of methods.
27
+
28
+ ```python
29
+ import os
30
+ from hydra_db import HydraDB, AsyncHydraDB
31
+
32
+ api_key = os.environ["HYDRA_DB_API_KEY"] # Set your Hydra DB API key in the environment variable HYDRA_DB_API_KEY. Optional, but recommended.
33
+
34
+ # Sync client
35
+ client = HydraDB(token=api_key)
36
+
37
+ # Async client (for async/await usage)
38
+ async_client = AsyncHydraDB(token=api_key)
39
+ ```
40
+
41
+ ### Create a Tenant
42
+
43
+ You can consider a `tenant` as a single database that can have internal isolated collections called `sub-tenants`. [Know more about the concept of tenant here](https://docs.hydradb.com/essentials/multi-tenant)
44
+
45
+ ```python
46
+ def create_tenant():
47
+ return client.tenant.create(tenant_id="my-company")
48
+ ```
49
+
50
+ ### Ingest Your Data
51
+
52
+ When you index your data, you make it ready for retrieval from Hydra DB using natural language.
53
+
54
+ ```python
55
+ # ingest in your knowledge base
56
+ with open("a.pdf", 'rb') as f1, open("b.pdf", 'rb') as f2:
57
+ files = [
58
+ ("a.pdf", f1),
59
+ ("b.pdf", f2)
60
+ ]
61
+ upload_result = client.upload.knowledge(
62
+ tenant_id="tenant_123",
63
+ files=files,
64
+ file_metadata=[
65
+ {
66
+ "id": "doc_a",
67
+ "tenant_metadata": {"dept": "sales"},
68
+ "document_metadata": {"author": "Alice"}
69
+ },
70
+ {
71
+ "id": "doc_b",
72
+ "tenant_metadata": {"dept": "marketing"},
73
+ "document_metadata": {"author": "Bob"}
74
+ }
75
+ ]
76
+ ))
77
+
78
+ # Ingest user memories
79
+ from hydra_db import HydraDBClient
80
+
81
+ client = HydraDBClient(api_key="your_api_key")
82
+
83
+ # Simple text memory
84
+ result = client.user_memory.add(
85
+ memories=[
86
+ {
87
+ "text": "User prefers detailed explanations and dark mode",
88
+ "infer": True,
89
+ "user_name": "John"
90
+ }
91
+ ],
92
+ tenant_id="tenant-01",
93
+ sub_tenant_id="",
94
+ upsert=True
95
+ )
96
+
97
+ # Markdown content
98
+ markdown_result = client.user_memory.add(
99
+ memories=[
100
+ {
101
+ "text": "# Meeting Notes\n\n## Key Points\n- Budget approved",
102
+ "is_markdown": True,
103
+ "infer": False,
104
+ "title": "Meeting Notes"
105
+ }
106
+ ],
107
+ tenant_id="tenant-01",
108
+ sub_tenant_id="",
109
+ upsert=True
110
+ )
111
+
112
+ # User-assistant pairs with inference
113
+ conversation_result = client.user_memory.add(
114
+ memories=[
115
+ {
116
+ "user_assistant_pairs": [
117
+ {"user": "What are my preferences?", "assistant": "You prefer dark mode."},
118
+ {"user": "How do I like reports?", "assistant": "Weekly summaries with charts."}
119
+ ],
120
+ "infer": True,
121
+ "user_name": "John",
122
+ "custom_instructions": "Extract user preferences"
123
+ }
124
+ ],
125
+ tenant_id="tenant-01",
126
+ sub_tenant_id="",
127
+ upsert=True
128
+ )
129
+ ```
130
+
131
+ **For a more detailed explanation** of document upload, including supported file formats, processing pipeline, metadata handling, and advanced configuration options, refer to the [Ingest Knowledge endpoint](https://docs.hydradb.com/api-reference/endpoint/add-knowledge-memories).
132
+
133
+ ### Search
134
+
135
+ ```python
136
+ # Semantic Recall
137
+ results = client.recall.full_recall(
138
+ query="Which mode does user prefer",
139
+ tenant_id="tenant_1234",
140
+ sub_tenant_id="sub_tenant_4567",
141
+ alpha=0.8,
142
+ recency_bias=0
143
+ )
144
+
145
+ # Get ingested data (memories + knowledge base)
146
+ all_sources = client.data.list_data(
147
+ tenant_id="tenant_1234",
148
+ sub_tenant_id="sub_tenant_4567"
149
+ )
150
+ ```
151
+
152
+ **For a more detailed explanation** of search and retrieval, including query parameters, scoring mechanisms, result structure, and advanced search features, refer to the [Search endpoint documentation](https://docs.hydradb.com/api-reference/endpoint/search).
153
+
154
+ ## SDK Method Structure & Type Safety
155
+
156
+ Our SDKs follow a predictable pattern that mirrors the API structure while providing full type safety.
157
+
158
+ > **Method Mapping** : `client.<group>.<function_name>` mirrors `api.hydradb.com/<group>/<function_name>`
159
+ >
160
+ > For example: `client.upload.upload_text()` corresponds to `POST /upload/upload_text`
161
+
162
+ The SDKs provide exact type parity with the API specification:
163
+
164
+ - **Request Parameters** : Every field documented in the API reference (required, optional, types, validation rules) is reflected in the SDK method signatures
165
+ - **Response Objects** : Return types match the exact JSON schema documented for each endpoint
166
+ - **Error Types** : Exception structures mirror the error response formats from the API
167
+ - **Nested Objects** : Complex nested parameters and responses maintain their full structure and typing
168
+
169
+ > This means you can rely on your IDE’s autocomplete and type checking. If a parameter is optional in the API docs, it’s optional in the SDK. If a response contains a specific field, your IDE will know about it. Our SDKs are built in such a way that your IDE will automatically provide **autocompletion, type-checking, inline documentation with examples, and compile time validation** for each and every method.
170
+ >
171
+ > Just hit **Cmd+Space/Ctrl+Space**
172
+
173
+ ## Links
174
+
175
+ - **Homepage:** [hydradb.com](https://www.hydradb.com/)
176
+ - **Documentation:** [docs.usecortex.ai](https://docs.usecortex.ai/)
177
+
178
+ ## Our docs
179
+
180
+ Please refer to our [API reference](https://docs.usecortex.ai/api-reference/introduction) for detailed explanations of every API endpoint, parameter options, and advanced use cases.
181
+
182
+ ## Support
183
+
184
+ If you have any questions or need help, please reach out to our support team at [founders@usecortex.ai](mailto:founders@usecortex.ai).
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "hydra-db-python"
7
+
8
+ version = "0.1.3"
9
+
10
+ authors = [
11
+ { name = "Soham Ratnaparkhi", email = "soham@usecortex.ai" },
12
+ ]
13
+ description = "The official Python SDK for the Hydra DB (hydradb.com)"
14
+ readme = "README.md"
15
+ requires-python = ">=3.10"
16
+ license = { file = "LICENSE" }
17
+ keywords = ["hydra-db", "ai", "sdk", "api", "generative ai", "rag", "db"]
18
+
19
+ # Add classifiers to help users find your package on PyPI
20
+ classifiers = [
21
+ # See https://pypi.org/classifiers/
22
+ "Development Status :: 5 - Production/Stable",
23
+ "Programming Language :: Python :: 3",
24
+ "Programming Language :: Python :: 3.10",
25
+ "Programming Language :: Python :: 3.11",
26
+ "Programming Language :: Python :: 3.12",
27
+ "Intended Audience :: Developers",
28
+ "Topic :: Software Development :: Libraries :: Python Modules",
29
+ "Typing :: Typed",
30
+ ]
31
+
32
+ dependencies = [
33
+ "httpx>=0.24",
34
+ "pydantic>=1.10,<3",
35
+ ]
36
+
37
+ [project.urls]
38
+ Homepage = "https://hydradb.com/"
39
+ Documentation = "https://docs.hydradb.com/"
40
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,160 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ from .types import (
6
+ ActualErrorResponse,
7
+ AddMemoryResponse,
8
+ Alpha,
9
+ ApiKeyCreateResponse,
10
+ AttachmentModel,
11
+ BatchProcessingStatus,
12
+ Bm25OperatorType,
13
+ CollectionStats,
14
+ ContentFilter,
15
+ ContentModel,
16
+ CustomPropertyDefinition,
17
+ DeleteResult,
18
+ DeleteUserMemoryResponse,
19
+ Entity,
20
+ ErrorResponse,
21
+ FetchMode,
22
+ ForcefulRelationsPayload,
23
+ GraphContext,
24
+ Infra,
25
+ InfraStatusResponse,
26
+ InsertResult,
27
+ ListContentKind,
28
+ ListUserMemoriesResponse,
29
+ MemoryItem,
30
+ MemoryResultItem,
31
+ MilvusDataType,
32
+ PaginationMeta,
33
+ PathTriplet,
34
+ ProcessingStatus,
35
+ ProcessingStatusIndexingStatus,
36
+ QnASearchResponse,
37
+ RawEmbeddingDocument,
38
+ RawEmbeddingSearchResult,
39
+ RawEmbeddingVector,
40
+ RecallSearchRequest,
41
+ RelationEvidence,
42
+ RetrievalResult,
43
+ RetrieveMode,
44
+ ScoredPathResponse,
45
+ SearchMode,
46
+ SourceDeleteResponse,
47
+ SourceDeleteResultItem,
48
+ SourceFetchResponse,
49
+ SourceGraphRelationsResponse,
50
+ SourceInfo,
51
+ SourceListResponse,
52
+ SourceModel,
53
+ SourceStatus,
54
+ SourceUploadResponse,
55
+ SourceUploadResultItem,
56
+ SubTenantIdsResponse,
57
+ SupportedLlmProviders,
58
+ TenantCreateAcceptedResponse,
59
+ TenantDeleteResponse,
60
+ TenantStatsResponse,
61
+ TripletWithEvidence,
62
+ UserAssistantPair,
63
+ UserMemory,
64
+ VectorStoreChunk,
65
+ )
66
+ from .errors import (
67
+ BadRequestError,
68
+ ForbiddenError,
69
+ InternalServerError,
70
+ NotFoundError,
71
+ ServiceUnavailableError,
72
+ TooManyRequestsError,
73
+ UnauthorizedError,
74
+ UnprocessableEntityError,
75
+ )
76
+ from . import data, embeddings, fetch, key, recall, tenant, upload
77
+ from .client import AsyncHydraDB, HydraDB
78
+ from .environment import HydraDBEnvironment
79
+ from .fetch import FetchListDataResponse
80
+
81
+ __all__ = [
82
+ "ActualErrorResponse",
83
+ "AddMemoryResponse",
84
+ "Alpha",
85
+ "ApiKeyCreateResponse",
86
+ "AsyncHydraDB",
87
+ "AttachmentModel",
88
+ "BadRequestError",
89
+ "BatchProcessingStatus",
90
+ "Bm25OperatorType",
91
+ "CollectionStats",
92
+ "ContentFilter",
93
+ "ContentModel",
94
+ "CustomPropertyDefinition",
95
+ "DeleteResult",
96
+ "DeleteUserMemoryResponse",
97
+ "Entity",
98
+ "ErrorResponse",
99
+ "FetchListDataResponse",
100
+ "FetchMode",
101
+ "ForbiddenError",
102
+ "ForcefulRelationsPayload",
103
+ "GraphContext",
104
+ "HydraDB",
105
+ "HydraDBEnvironment",
106
+ "Infra",
107
+ "InfraStatusResponse",
108
+ "InsertResult",
109
+ "InternalServerError",
110
+ "ListContentKind",
111
+ "ListUserMemoriesResponse",
112
+ "MemoryItem",
113
+ "MemoryResultItem",
114
+ "MilvusDataType",
115
+ "NotFoundError",
116
+ "PaginationMeta",
117
+ "PathTriplet",
118
+ "ProcessingStatus",
119
+ "ProcessingStatusIndexingStatus",
120
+ "QnASearchResponse",
121
+ "RawEmbeddingDocument",
122
+ "RawEmbeddingSearchResult",
123
+ "RawEmbeddingVector",
124
+ "RecallSearchRequest",
125
+ "RelationEvidence",
126
+ "RetrievalResult",
127
+ "RetrieveMode",
128
+ "ScoredPathResponse",
129
+ "SearchMode",
130
+ "ServiceUnavailableError",
131
+ "SourceDeleteResponse",
132
+ "SourceDeleteResultItem",
133
+ "SourceFetchResponse",
134
+ "SourceGraphRelationsResponse",
135
+ "SourceInfo",
136
+ "SourceListResponse",
137
+ "SourceModel",
138
+ "SourceStatus",
139
+ "SourceUploadResponse",
140
+ "SourceUploadResultItem",
141
+ "SubTenantIdsResponse",
142
+ "SupportedLlmProviders",
143
+ "TenantCreateAcceptedResponse",
144
+ "TenantDeleteResponse",
145
+ "TenantStatsResponse",
146
+ "TooManyRequestsError",
147
+ "TripletWithEvidence",
148
+ "UnauthorizedError",
149
+ "UnprocessableEntityError",
150
+ "UserAssistantPair",
151
+ "UserMemory",
152
+ "VectorStoreChunk",
153
+ "data",
154
+ "embeddings",
155
+ "fetch",
156
+ "key",
157
+ "recall",
158
+ "tenant",
159
+ "upload",
160
+ ]