usecortex-ai 0.3.1__tar.gz → 0.3.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.
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/LICENSE +1 -1
- usecortex_ai-0.3.3/PKG-INFO +180 -0
- usecortex_ai-0.3.3/README.md +135 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/pyproject.toml +2 -8
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/upload/client.py +10 -2
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/upload/raw_client.py +10 -0
- usecortex_ai-0.3.3/src/usecortex_ai.egg-info/PKG-INFO +180 -0
- usecortex_ai-0.3.1/PKG-INFO +0 -66
- usecortex_ai-0.3.1/README.md +0 -21
- usecortex_ai-0.3.1/src/usecortex_ai.egg-info/PKG-INFO +0 -66
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/setup.cfg +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/__init__.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/client.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/core/__init__.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/core/api_error.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/core/client_wrapper.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/core/datetime_utils.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/core/file.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/core/force_multipart.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/core/http_client.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/core/http_response.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/core/jsonable_encoder.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/core/pydantic_utilities.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/core/query_encoder.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/core/remove_none_from_dict.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/core/request_options.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/core/serialization.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/document/__init__.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/document/client.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/document/raw_client.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/embeddings/__init__.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/embeddings/client.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/embeddings/raw_client.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/environment.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/errors/__init__.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/errors/bad_request_error.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/errors/forbidden_error.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/errors/internal_server_error.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/errors/not_found_error.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/errors/service_unavailable_error.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/errors/unauthorized_error.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/errors/unprocessable_entity_error.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/fetch/__init__.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/fetch/client.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/fetch/raw_client.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/raw_client.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/search/__init__.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/search/client.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/search/raw_client.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/search/types/__init__.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/search/types/alpha.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/sources/__init__.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/sources/client.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/sources/raw_client.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/tenant/__init__.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/tenant/client.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/tenant/raw_client.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/__init__.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/actual_error_response.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/add_user_memory_response.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/app_sources_upload_data.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/attachment_model.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/batch_upload_data.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/bm_25_operator_type.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/body_scrape_webpage_upload_scrape_webpage_post.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/body_update_scrape_job_upload_update_webpage_patch.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/content_model.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/delete_memory_request.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/delete_sources.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/delete_sub_tenant_data.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/delete_user_memory_response.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/embeddings_create_collection_data.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/embeddings_delete_data.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/embeddings_get_data.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/embeddings_search_data.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/error_response.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/extended_context.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/fetch_content_data.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/file_upload_result.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/generate_user_memory_response.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/http_validation_error.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/list_sources_response.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/list_user_memories_response.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/markdown_upload_request.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/processing_status.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/related_chunk.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/relations.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/retrieve_user_memory_response.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/search_chunk.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/single_upload_data.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/source.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/source_model.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/sub_tenant_ids_data.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/tenant_create_data.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/tenant_stats.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/user_memory.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/validation_error.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/validation_error_loc_item.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/upload/__init__.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/user/__init__.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/user/client.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/user/raw_client.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/user_memory/__init__.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/user_memory/client.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/user_memory/raw_client.py +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai.egg-info/SOURCES.txt +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai.egg-info/dependency_links.txt +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai.egg-info/requires.txt +0 -0
- {usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai.egg-info/top_level.txt +0 -0
|
@@ -5,7 +5,7 @@ All Rights Reserved.
|
|
|
5
5
|
PROPRIETARY AND CONFIDENTIAL
|
|
6
6
|
|
|
7
7
|
This software is the proprietary and confidential property of Cortex AI ("the Company").
|
|
8
|
-
Permission is hereby granted to
|
|
8
|
+
Permission is hereby granted to users to install and use this software as part of the Cortex AI service, subject to the terms and conditions of the service agreement entered into with the Company.
|
|
9
9
|
|
|
10
10
|
You may not, without the express written permission of the Company:
|
|
11
11
|
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: usecortex-ai
|
|
3
|
+
Version: 0.3.3
|
|
4
|
+
Summary: The official Python SDK for the Cortex AI platform.
|
|
5
|
+
Author-email: Nishkarsh Shrivastava <nishkarsh@usecortex.ai>
|
|
6
|
+
License: Copyright (c) 2024 Cortex AI
|
|
7
|
+
|
|
8
|
+
All Rights Reserved.
|
|
9
|
+
|
|
10
|
+
PROPRIETARY AND CONFIDENTIAL
|
|
11
|
+
|
|
12
|
+
This software is the proprietary and confidential property of Cortex AI ("the Company").
|
|
13
|
+
Permission is hereby granted to users to install and use this software as part of the Cortex AI 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://www.usecortex.ai/
|
|
29
|
+
Project-URL: Documentation, https://docs.usecortex.ai/
|
|
30
|
+
Keywords: cortex,ai,sdk,api,generative ai,rag
|
|
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
|
+
# Cortex AI Python SDK - [usecortex.ai](https://www.usecortex.ai/)
|
|
47
|
+
|
|
48
|
+
The official Python SDK for the Cortex AI platform. Build powerful, context-aware AI applications in your Python applications.
|
|
49
|
+
|
|
50
|
+
**Cortex** 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.usecortex.ai/)
|
|
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 usecortex-ai
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Client setup
|
|
70
|
+
|
|
71
|
+
We provide both synchronous and asynchronous clients. Use **`AsyncCortexAI`** when working with async/await patterns, and **`CortexAI`** 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 usecortex_ai import CortexAI, AsyncCortexAI
|
|
76
|
+
|
|
77
|
+
api_key = os.environ["CORTEX_API_KEY"] # Set your Cortex API key in the environment variable CORTEX_API_KEY. Optional, but recommended.
|
|
78
|
+
|
|
79
|
+
# Sync client
|
|
80
|
+
client = CortexAI(token=api_key)
|
|
81
|
+
|
|
82
|
+
# Async client (for async/await usage)
|
|
83
|
+
async_client = AsyncCortexAI(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.usecortex.ai/essentials/multi-tenant)
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
def create_tenant():
|
|
92
|
+
return client.user.create_tenant(tenant_id="my-company")
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Index Your Data
|
|
96
|
+
|
|
97
|
+
When you index your data, you make it ready for retrieval from Cortex using natural language.
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
# Upload text content
|
|
101
|
+
def upload_text():
|
|
102
|
+
return client.upload.upload_text(
|
|
103
|
+
tenant_id="my-company-py-sync",
|
|
104
|
+
sub_tenant_id="engineering",
|
|
105
|
+
content="Our API rate limits are 1000 requests per minute for premium accounts.",
|
|
106
|
+
file_id="api-docs-rate-limits",
|
|
107
|
+
tenant_metadata={"sub_tenant_id": "engineering"}
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
# Upload document file
|
|
111
|
+
def upload_file():
|
|
112
|
+
with open("company-handbook.pdf", 'rb') as file_obj:
|
|
113
|
+
file_data = ("company-handbook.pdf", file_obj)
|
|
114
|
+
return client.upload.upload_document(
|
|
115
|
+
tenant_id="my-company",
|
|
116
|
+
file=file_data,
|
|
117
|
+
file_id="company-handbook.pdf"
|
|
118
|
+
)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**For a more detailed explanation** of document upload, including supported file formats, processing pipeline, metadata handling, and advanced configuration options, refer to the [Upload Document endpoint documentation](https://docs.usecortex.ai/api-reference/endpoint/upload-document).
|
|
122
|
+
|
|
123
|
+
### Search and retrieval
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
# Semantic search with retrieval
|
|
127
|
+
results = client.search.retrieve(
|
|
128
|
+
query="What are the API rate limits?",
|
|
129
|
+
tenant_id="my-company",
|
|
130
|
+
sub_tenant_id="engineering",
|
|
131
|
+
max_chunks=10
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
# List all sources
|
|
135
|
+
all_sources = client.sources.get_all(
|
|
136
|
+
tenant_id="my-company",
|
|
137
|
+
sub_tenant_id="engineering",
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
# Get specific sources by ID
|
|
141
|
+
specific_sources = client.sources.get_by_ids(
|
|
142
|
+
tenant_id="my-company",
|
|
143
|
+
sub_tenant_id="engineering",
|
|
144
|
+
source_ids=["api-docs-rate-limits", "company-handbook"]
|
|
145
|
+
)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**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.usecortex.ai/api-reference/endpoint/search).
|
|
149
|
+
|
|
150
|
+
## SDK Method Structure & Type Safety
|
|
151
|
+
|
|
152
|
+
Our SDKs follow a predictable pattern that mirrors the API structure while providing full type safety.
|
|
153
|
+
|
|
154
|
+
> **Method Mapping** : `client.<group>.<function_name>` mirrors `api.usecortex.ai/<group>/<function_name>`
|
|
155
|
+
>
|
|
156
|
+
> For example: `client.upload.upload_text()` corresponds to `POST /upload/upload_text`
|
|
157
|
+
|
|
158
|
+
The SDKs provide exact type parity with the API specification:
|
|
159
|
+
|
|
160
|
+
- **Request Parameters** : Every field documented in the API reference (required, optional, types, validation rules) is reflected in the SDK method signatures
|
|
161
|
+
- **Response Objects** : Return types match the exact JSON schema documented for each endpoint
|
|
162
|
+
- **Error Types** : Exception structures mirror the error response formats from the API
|
|
163
|
+
- **Nested Objects** : Complex nested parameters and responses maintain their full structure and typing
|
|
164
|
+
|
|
165
|
+
> 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.
|
|
166
|
+
>
|
|
167
|
+
> Just hit **Cmd+Space/Ctrl+Space!**
|
|
168
|
+
|
|
169
|
+
## Links
|
|
170
|
+
|
|
171
|
+
- **Homepage:** [usecortex.ai](https://www.usecortex.ai/)
|
|
172
|
+
- **Documentation:** [docs.usecortex.ai](https://docs.usecortex.ai/)
|
|
173
|
+
|
|
174
|
+
## Our docs
|
|
175
|
+
|
|
176
|
+
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.
|
|
177
|
+
|
|
178
|
+
## Support
|
|
179
|
+
|
|
180
|
+
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,135 @@
|
|
|
1
|
+
# Cortex AI Python SDK - [usecortex.ai](https://www.usecortex.ai/)
|
|
2
|
+
|
|
3
|
+
The official Python SDK for the Cortex AI platform. Build powerful, context-aware AI applications in your Python applications.
|
|
4
|
+
|
|
5
|
+
**Cortex** 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.usecortex.ai/)
|
|
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 usecortex-ai
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Client setup
|
|
25
|
+
|
|
26
|
+
We provide both synchronous and asynchronous clients. Use **`AsyncCortexAI`** when working with async/await patterns, and **`CortexAI`** 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 usecortex_ai import CortexAI, AsyncCortexAI
|
|
31
|
+
|
|
32
|
+
api_key = os.environ["CORTEX_API_KEY"] # Set your Cortex API key in the environment variable CORTEX_API_KEY. Optional, but recommended.
|
|
33
|
+
|
|
34
|
+
# Sync client
|
|
35
|
+
client = CortexAI(token=api_key)
|
|
36
|
+
|
|
37
|
+
# Async client (for async/await usage)
|
|
38
|
+
async_client = AsyncCortexAI(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.usecortex.ai/essentials/multi-tenant)
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
def create_tenant():
|
|
47
|
+
return client.user.create_tenant(tenant_id="my-company")
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Index Your Data
|
|
51
|
+
|
|
52
|
+
When you index your data, you make it ready for retrieval from Cortex using natural language.
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
# Upload text content
|
|
56
|
+
def upload_text():
|
|
57
|
+
return client.upload.upload_text(
|
|
58
|
+
tenant_id="my-company-py-sync",
|
|
59
|
+
sub_tenant_id="engineering",
|
|
60
|
+
content="Our API rate limits are 1000 requests per minute for premium accounts.",
|
|
61
|
+
file_id="api-docs-rate-limits",
|
|
62
|
+
tenant_metadata={"sub_tenant_id": "engineering"}
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
# Upload document file
|
|
66
|
+
def upload_file():
|
|
67
|
+
with open("company-handbook.pdf", 'rb') as file_obj:
|
|
68
|
+
file_data = ("company-handbook.pdf", file_obj)
|
|
69
|
+
return client.upload.upload_document(
|
|
70
|
+
tenant_id="my-company",
|
|
71
|
+
file=file_data,
|
|
72
|
+
file_id="company-handbook.pdf"
|
|
73
|
+
)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**For a more detailed explanation** of document upload, including supported file formats, processing pipeline, metadata handling, and advanced configuration options, refer to the [Upload Document endpoint documentation](https://docs.usecortex.ai/api-reference/endpoint/upload-document).
|
|
77
|
+
|
|
78
|
+
### Search and retrieval
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
# Semantic search with retrieval
|
|
82
|
+
results = client.search.retrieve(
|
|
83
|
+
query="What are the API rate limits?",
|
|
84
|
+
tenant_id="my-company",
|
|
85
|
+
sub_tenant_id="engineering",
|
|
86
|
+
max_chunks=10
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
# List all sources
|
|
90
|
+
all_sources = client.sources.get_all(
|
|
91
|
+
tenant_id="my-company",
|
|
92
|
+
sub_tenant_id="engineering",
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
# Get specific sources by ID
|
|
96
|
+
specific_sources = client.sources.get_by_ids(
|
|
97
|
+
tenant_id="my-company",
|
|
98
|
+
sub_tenant_id="engineering",
|
|
99
|
+
source_ids=["api-docs-rate-limits", "company-handbook"]
|
|
100
|
+
)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**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.usecortex.ai/api-reference/endpoint/search).
|
|
104
|
+
|
|
105
|
+
## SDK Method Structure & Type Safety
|
|
106
|
+
|
|
107
|
+
Our SDKs follow a predictable pattern that mirrors the API structure while providing full type safety.
|
|
108
|
+
|
|
109
|
+
> **Method Mapping** : `client.<group>.<function_name>` mirrors `api.usecortex.ai/<group>/<function_name>`
|
|
110
|
+
>
|
|
111
|
+
> For example: `client.upload.upload_text()` corresponds to `POST /upload/upload_text`
|
|
112
|
+
|
|
113
|
+
The SDKs provide exact type parity with the API specification:
|
|
114
|
+
|
|
115
|
+
- **Request Parameters** : Every field documented in the API reference (required, optional, types, validation rules) is reflected in the SDK method signatures
|
|
116
|
+
- **Response Objects** : Return types match the exact JSON schema documented for each endpoint
|
|
117
|
+
- **Error Types** : Exception structures mirror the error response formats from the API
|
|
118
|
+
- **Nested Objects** : Complex nested parameters and responses maintain their full structure and typing
|
|
119
|
+
|
|
120
|
+
> 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.
|
|
121
|
+
>
|
|
122
|
+
> Just hit **Cmd+Space/Ctrl+Space!**
|
|
123
|
+
|
|
124
|
+
## Links
|
|
125
|
+
|
|
126
|
+
- **Homepage:** [usecortex.ai](https://www.usecortex.ai/)
|
|
127
|
+
- **Documentation:** [docs.usecortex.ai](https://docs.usecortex.ai/)
|
|
128
|
+
|
|
129
|
+
## Our docs
|
|
130
|
+
|
|
131
|
+
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.
|
|
132
|
+
|
|
133
|
+
## Support
|
|
134
|
+
|
|
135
|
+
If you have any questions or need help, please reach out to our support team at [founders@usecortex.ai](mailto:founders@usecortex.ai).
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
# pyproject.toml
|
|
2
|
-
|
|
3
1
|
[build-system]
|
|
4
2
|
requires = ["setuptools>=61.0"]
|
|
5
3
|
build-backend = "setuptools.build_meta"
|
|
6
4
|
|
|
7
5
|
[project]
|
|
8
|
-
# This is the name used for 'pip install usecortex-ai'
|
|
9
6
|
name = "usecortex-ai"
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
version = "0.3.1"
|
|
8
|
+
version = "0.3.3"
|
|
13
9
|
|
|
14
10
|
authors = [
|
|
15
11
|
{ name = "Nishkarsh Shrivastava", email = "nishkarsh@usecortex.ai" },
|
|
@@ -23,7 +19,7 @@ keywords = ["cortex", "ai", "sdk", "api", "generative ai", "rag"]
|
|
|
23
19
|
# Add classifiers to help users find your package on PyPI
|
|
24
20
|
classifiers = [
|
|
25
21
|
# See https://pypi.org/classifiers/
|
|
26
|
-
"Development Status ::
|
|
22
|
+
"Development Status :: 5 - Production/Stable",
|
|
27
23
|
"Programming Language :: Python :: 3",
|
|
28
24
|
"Programming Language :: Python :: 3.10",
|
|
29
25
|
"Programming Language :: Python :: 3.11",
|
|
@@ -41,6 +37,4 @@ dependencies = [
|
|
|
41
37
|
[project.urls]
|
|
42
38
|
Homepage = "https://www.usecortex.ai/"
|
|
43
39
|
Documentation = "https://docs.usecortex.ai/"
|
|
44
|
-
# Add this if you have a public issue tracker
|
|
45
|
-
# "Bug Tracker" = "https://github.com/your-org/your-repo/issues"
|
|
46
40
|
|
|
@@ -951,6 +951,7 @@ class UploadClient:
|
|
|
951
951
|
*,
|
|
952
952
|
file_id: str,
|
|
953
953
|
tenant_id: typing.Optional[str] = None,
|
|
954
|
+
sub_tenant_id: typing.Optional[str] = None,
|
|
954
955
|
request_options: typing.Optional[RequestOptions] = None,
|
|
955
956
|
) -> ProcessingStatus:
|
|
956
957
|
"""
|
|
@@ -968,6 +969,9 @@ class UploadClient:
|
|
|
968
969
|
tenant_id : typing.Optional[str]
|
|
969
970
|
Unique identifier for the tenant/organization
|
|
970
971
|
|
|
972
|
+
sub_tenant_id : typing.Optional[str]
|
|
973
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
974
|
+
|
|
971
975
|
request_options : typing.Optional[RequestOptions]
|
|
972
976
|
Request-specific configuration.
|
|
973
977
|
|
|
@@ -984,7 +988,7 @@ class UploadClient:
|
|
|
984
988
|
client.upload.verify_processing(file_id='CortexDoc1234', tenant_id='tenant_1234', )
|
|
985
989
|
"""
|
|
986
990
|
_response = self._raw_client.verify_processing(
|
|
987
|
-
file_id=file_id, tenant_id=tenant_id, request_options=request_options
|
|
991
|
+
file_id=file_id, tenant_id=tenant_id, sub_tenant_id=sub_tenant_id, request_options=request_options
|
|
988
992
|
)
|
|
989
993
|
return _response.data
|
|
990
994
|
|
|
@@ -1984,6 +1988,7 @@ class AsyncUploadClient:
|
|
|
1984
1988
|
*,
|
|
1985
1989
|
file_id: str,
|
|
1986
1990
|
tenant_id: typing.Optional[str] = None,
|
|
1991
|
+
sub_tenant_id: typing.Optional[str] = None,
|
|
1987
1992
|
request_options: typing.Optional[RequestOptions] = None,
|
|
1988
1993
|
) -> ProcessingStatus:
|
|
1989
1994
|
"""
|
|
@@ -2001,6 +2006,9 @@ class AsyncUploadClient:
|
|
|
2001
2006
|
tenant_id : typing.Optional[str]
|
|
2002
2007
|
Unique identifier for the tenant/organization
|
|
2003
2008
|
|
|
2009
|
+
sub_tenant_id : typing.Optional[str]
|
|
2010
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
2011
|
+
|
|
2004
2012
|
request_options : typing.Optional[RequestOptions]
|
|
2005
2013
|
Request-specific configuration.
|
|
2006
2014
|
|
|
@@ -2021,6 +2029,6 @@ class AsyncUploadClient:
|
|
|
2021
2029
|
asyncio.run(main())
|
|
2022
2030
|
"""
|
|
2023
2031
|
_response = await self._raw_client.verify_processing(
|
|
2024
|
-
file_id=file_id, tenant_id=tenant_id, request_options=request_options
|
|
2032
|
+
file_id=file_id, tenant_id=tenant_id, sub_tenant_id=sub_tenant_id, request_options=request_options
|
|
2025
2033
|
)
|
|
2026
2034
|
return _response.data
|
|
@@ -2225,6 +2225,7 @@ class RawUploadClient:
|
|
|
2225
2225
|
*,
|
|
2226
2226
|
file_id: str,
|
|
2227
2227
|
tenant_id: typing.Optional[str] = None,
|
|
2228
|
+
sub_tenant_id: typing.Optional[str] = None,
|
|
2228
2229
|
request_options: typing.Optional[RequestOptions] = None,
|
|
2229
2230
|
) -> HttpResponse[ProcessingStatus]:
|
|
2230
2231
|
"""
|
|
@@ -2242,6 +2243,9 @@ class RawUploadClient:
|
|
|
2242
2243
|
tenant_id : typing.Optional[str]
|
|
2243
2244
|
Unique identifier for the tenant/organization
|
|
2244
2245
|
|
|
2246
|
+
sub_tenant_id : typing.Optional[str]
|
|
2247
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
2248
|
+
|
|
2245
2249
|
request_options : typing.Optional[RequestOptions]
|
|
2246
2250
|
Request-specific configuration.
|
|
2247
2251
|
|
|
@@ -2256,6 +2260,7 @@ class RawUploadClient:
|
|
|
2256
2260
|
params={
|
|
2257
2261
|
"file_id": file_id,
|
|
2258
2262
|
"tenant_id": tenant_id,
|
|
2263
|
+
"sub_tenant_id": sub_tenant_id,
|
|
2259
2264
|
},
|
|
2260
2265
|
request_options=request_options,
|
|
2261
2266
|
)
|
|
@@ -4549,6 +4554,7 @@ class AsyncRawUploadClient:
|
|
|
4549
4554
|
*,
|
|
4550
4555
|
file_id: str,
|
|
4551
4556
|
tenant_id: typing.Optional[str] = None,
|
|
4557
|
+
sub_tenant_id: typing.Optional[str] = None,
|
|
4552
4558
|
request_options: typing.Optional[RequestOptions] = None,
|
|
4553
4559
|
) -> AsyncHttpResponse[ProcessingStatus]:
|
|
4554
4560
|
"""
|
|
@@ -4566,6 +4572,9 @@ class AsyncRawUploadClient:
|
|
|
4566
4572
|
tenant_id : typing.Optional[str]
|
|
4567
4573
|
Unique identifier for the tenant/organization
|
|
4568
4574
|
|
|
4575
|
+
sub_tenant_id : typing.Optional[str]
|
|
4576
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
4577
|
+
|
|
4569
4578
|
request_options : typing.Optional[RequestOptions]
|
|
4570
4579
|
Request-specific configuration.
|
|
4571
4580
|
|
|
@@ -4580,6 +4589,7 @@ class AsyncRawUploadClient:
|
|
|
4580
4589
|
params={
|
|
4581
4590
|
"file_id": file_id,
|
|
4582
4591
|
"tenant_id": tenant_id,
|
|
4592
|
+
"sub_tenant_id": sub_tenant_id,
|
|
4583
4593
|
},
|
|
4584
4594
|
request_options=request_options,
|
|
4585
4595
|
)
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: usecortex-ai
|
|
3
|
+
Version: 0.3.3
|
|
4
|
+
Summary: The official Python SDK for the Cortex AI platform.
|
|
5
|
+
Author-email: Nishkarsh Shrivastava <nishkarsh@usecortex.ai>
|
|
6
|
+
License: Copyright (c) 2024 Cortex AI
|
|
7
|
+
|
|
8
|
+
All Rights Reserved.
|
|
9
|
+
|
|
10
|
+
PROPRIETARY AND CONFIDENTIAL
|
|
11
|
+
|
|
12
|
+
This software is the proprietary and confidential property of Cortex AI ("the Company").
|
|
13
|
+
Permission is hereby granted to users to install and use this software as part of the Cortex AI 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://www.usecortex.ai/
|
|
29
|
+
Project-URL: Documentation, https://docs.usecortex.ai/
|
|
30
|
+
Keywords: cortex,ai,sdk,api,generative ai,rag
|
|
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
|
+
# Cortex AI Python SDK - [usecortex.ai](https://www.usecortex.ai/)
|
|
47
|
+
|
|
48
|
+
The official Python SDK for the Cortex AI platform. Build powerful, context-aware AI applications in your Python applications.
|
|
49
|
+
|
|
50
|
+
**Cortex** 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.usecortex.ai/)
|
|
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 usecortex-ai
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Client setup
|
|
70
|
+
|
|
71
|
+
We provide both synchronous and asynchronous clients. Use **`AsyncCortexAI`** when working with async/await patterns, and **`CortexAI`** 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 usecortex_ai import CortexAI, AsyncCortexAI
|
|
76
|
+
|
|
77
|
+
api_key = os.environ["CORTEX_API_KEY"] # Set your Cortex API key in the environment variable CORTEX_API_KEY. Optional, but recommended.
|
|
78
|
+
|
|
79
|
+
# Sync client
|
|
80
|
+
client = CortexAI(token=api_key)
|
|
81
|
+
|
|
82
|
+
# Async client (for async/await usage)
|
|
83
|
+
async_client = AsyncCortexAI(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.usecortex.ai/essentials/multi-tenant)
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
def create_tenant():
|
|
92
|
+
return client.user.create_tenant(tenant_id="my-company")
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Index Your Data
|
|
96
|
+
|
|
97
|
+
When you index your data, you make it ready for retrieval from Cortex using natural language.
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
# Upload text content
|
|
101
|
+
def upload_text():
|
|
102
|
+
return client.upload.upload_text(
|
|
103
|
+
tenant_id="my-company-py-sync",
|
|
104
|
+
sub_tenant_id="engineering",
|
|
105
|
+
content="Our API rate limits are 1000 requests per minute for premium accounts.",
|
|
106
|
+
file_id="api-docs-rate-limits",
|
|
107
|
+
tenant_metadata={"sub_tenant_id": "engineering"}
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
# Upload document file
|
|
111
|
+
def upload_file():
|
|
112
|
+
with open("company-handbook.pdf", 'rb') as file_obj:
|
|
113
|
+
file_data = ("company-handbook.pdf", file_obj)
|
|
114
|
+
return client.upload.upload_document(
|
|
115
|
+
tenant_id="my-company",
|
|
116
|
+
file=file_data,
|
|
117
|
+
file_id="company-handbook.pdf"
|
|
118
|
+
)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**For a more detailed explanation** of document upload, including supported file formats, processing pipeline, metadata handling, and advanced configuration options, refer to the [Upload Document endpoint documentation](https://docs.usecortex.ai/api-reference/endpoint/upload-document).
|
|
122
|
+
|
|
123
|
+
### Search and retrieval
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
# Semantic search with retrieval
|
|
127
|
+
results = client.search.retrieve(
|
|
128
|
+
query="What are the API rate limits?",
|
|
129
|
+
tenant_id="my-company",
|
|
130
|
+
sub_tenant_id="engineering",
|
|
131
|
+
max_chunks=10
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
# List all sources
|
|
135
|
+
all_sources = client.sources.get_all(
|
|
136
|
+
tenant_id="my-company",
|
|
137
|
+
sub_tenant_id="engineering",
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
# Get specific sources by ID
|
|
141
|
+
specific_sources = client.sources.get_by_ids(
|
|
142
|
+
tenant_id="my-company",
|
|
143
|
+
sub_tenant_id="engineering",
|
|
144
|
+
source_ids=["api-docs-rate-limits", "company-handbook"]
|
|
145
|
+
)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**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.usecortex.ai/api-reference/endpoint/search).
|
|
149
|
+
|
|
150
|
+
## SDK Method Structure & Type Safety
|
|
151
|
+
|
|
152
|
+
Our SDKs follow a predictable pattern that mirrors the API structure while providing full type safety.
|
|
153
|
+
|
|
154
|
+
> **Method Mapping** : `client.<group>.<function_name>` mirrors `api.usecortex.ai/<group>/<function_name>`
|
|
155
|
+
>
|
|
156
|
+
> For example: `client.upload.upload_text()` corresponds to `POST /upload/upload_text`
|
|
157
|
+
|
|
158
|
+
The SDKs provide exact type parity with the API specification:
|
|
159
|
+
|
|
160
|
+
- **Request Parameters** : Every field documented in the API reference (required, optional, types, validation rules) is reflected in the SDK method signatures
|
|
161
|
+
- **Response Objects** : Return types match the exact JSON schema documented for each endpoint
|
|
162
|
+
- **Error Types** : Exception structures mirror the error response formats from the API
|
|
163
|
+
- **Nested Objects** : Complex nested parameters and responses maintain their full structure and typing
|
|
164
|
+
|
|
165
|
+
> 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.
|
|
166
|
+
>
|
|
167
|
+
> Just hit **Cmd+Space/Ctrl+Space!**
|
|
168
|
+
|
|
169
|
+
## Links
|
|
170
|
+
|
|
171
|
+
- **Homepage:** [usecortex.ai](https://www.usecortex.ai/)
|
|
172
|
+
- **Documentation:** [docs.usecortex.ai](https://docs.usecortex.ai/)
|
|
173
|
+
|
|
174
|
+
## Our docs
|
|
175
|
+
|
|
176
|
+
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.
|
|
177
|
+
|
|
178
|
+
## Support
|
|
179
|
+
|
|
180
|
+
If you have any questions or need help, please reach out to our support team at [founders@usecortex.ai](mailto:founders@usecortex.ai).
|
usecortex_ai-0.3.1/PKG-INFO
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: usecortex-ai
|
|
3
|
-
Version: 0.3.1
|
|
4
|
-
Summary: The official Python SDK for the Cortex AI platform.
|
|
5
|
-
Author-email: Nishkarsh Shrivastava <nishkarsh@usecortex.ai>
|
|
6
|
-
License: Copyright (c) 2024 Cortex AI
|
|
7
|
-
|
|
8
|
-
All Rights Reserved.
|
|
9
|
-
|
|
10
|
-
PROPRIETARY AND CONFIDENTIAL
|
|
11
|
-
|
|
12
|
-
This software is the proprietary and confidential property of Cortex AI ("the Company").
|
|
13
|
-
Permission is hereby granted to authorized users to install and use this software as part of the Cortex AI 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://www.usecortex.ai/
|
|
29
|
-
Project-URL: Documentation, https://docs.usecortex.ai/
|
|
30
|
-
Keywords: cortex,ai,sdk,api,generative ai,rag
|
|
31
|
-
Classifier: Development Status :: 4 - Beta
|
|
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
|
-
```
|
|
47
|
-
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
# Cortex AI Python SDK
|
|
52
|
-
|
|
53
|
-
The official Python SDK for the Cortex AI platform. Build powerful, context-aware AI applications in your Python applications.
|
|
54
|
-
|
|
55
|
-
## Links
|
|
56
|
-
|
|
57
|
-
- **Homepage:** [usecortex.ai](https://www.usecortex.ai/)
|
|
58
|
-
- **Documentation:** [docs.usecortex.ai](https://docs.usecortex.ai/)
|
|
59
|
-
|
|
60
|
-
## Getting Started
|
|
61
|
-
|
|
62
|
-
Please refer to our [SDK documentation](https://docs.usecortex.ai/api-reference/sdks) and [API reference](https://docs.usecortex.ai/api-reference/introduction) to get started.
|
|
63
|
-
|
|
64
|
-
## Support
|
|
65
|
-
|
|
66
|
-
If you have any questions or need help, please reach out to our support team at [founders@usecortex.ai](mailto:founders@usecortex.ai).
|
usecortex_ai-0.3.1/README.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
```
|
|
2
|
-
|
|
3
|
-
```
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
# Cortex AI Python SDK
|
|
7
|
-
|
|
8
|
-
The official Python SDK for the Cortex AI platform. Build powerful, context-aware AI applications in your Python applications.
|
|
9
|
-
|
|
10
|
-
## Links
|
|
11
|
-
|
|
12
|
-
- **Homepage:** [usecortex.ai](https://www.usecortex.ai/)
|
|
13
|
-
- **Documentation:** [docs.usecortex.ai](https://docs.usecortex.ai/)
|
|
14
|
-
|
|
15
|
-
## Getting Started
|
|
16
|
-
|
|
17
|
-
Please refer to our [SDK documentation](https://docs.usecortex.ai/api-reference/sdks) and [API reference](https://docs.usecortex.ai/api-reference/introduction) to get started.
|
|
18
|
-
|
|
19
|
-
## Support
|
|
20
|
-
|
|
21
|
-
If you have any questions or need help, please reach out to our support team at [founders@usecortex.ai](mailto:founders@usecortex.ai).
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: usecortex-ai
|
|
3
|
-
Version: 0.3.1
|
|
4
|
-
Summary: The official Python SDK for the Cortex AI platform.
|
|
5
|
-
Author-email: Nishkarsh Shrivastava <nishkarsh@usecortex.ai>
|
|
6
|
-
License: Copyright (c) 2024 Cortex AI
|
|
7
|
-
|
|
8
|
-
All Rights Reserved.
|
|
9
|
-
|
|
10
|
-
PROPRIETARY AND CONFIDENTIAL
|
|
11
|
-
|
|
12
|
-
This software is the proprietary and confidential property of Cortex AI ("the Company").
|
|
13
|
-
Permission is hereby granted to authorized users to install and use this software as part of the Cortex AI 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://www.usecortex.ai/
|
|
29
|
-
Project-URL: Documentation, https://docs.usecortex.ai/
|
|
30
|
-
Keywords: cortex,ai,sdk,api,generative ai,rag
|
|
31
|
-
Classifier: Development Status :: 4 - Beta
|
|
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
|
-
```
|
|
47
|
-
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
# Cortex AI Python SDK
|
|
52
|
-
|
|
53
|
-
The official Python SDK for the Cortex AI platform. Build powerful, context-aware AI applications in your Python applications.
|
|
54
|
-
|
|
55
|
-
## Links
|
|
56
|
-
|
|
57
|
-
- **Homepage:** [usecortex.ai](https://www.usecortex.ai/)
|
|
58
|
-
- **Documentation:** [docs.usecortex.ai](https://docs.usecortex.ai/)
|
|
59
|
-
|
|
60
|
-
## Getting Started
|
|
61
|
-
|
|
62
|
-
Please refer to our [SDK documentation](https://docs.usecortex.ai/api-reference/sdks) and [API reference](https://docs.usecortex.ai/api-reference/introduction) to get started.
|
|
63
|
-
|
|
64
|
-
## Support
|
|
65
|
-
|
|
66
|
-
If you have any questions or need help, please reach out to our support team at [founders@usecortex.ai](mailto:founders@usecortex.ai).
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/errors/service_unavailable_error.py
RENAMED
|
File without changes
|
|
File without changes
|
{usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/errors/unprocessable_entity_error.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/add_user_memory_response.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/delete_user_memory_response.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/generate_user_memory_response.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/list_user_memories_response.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/retrieve_user_memory_response.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{usecortex_ai-0.3.1 → usecortex_ai-0.3.3}/src/usecortex_ai/types/validation_error_loc_item.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|