@usecortex_ai/node 0.3.1 → 0.3.3

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.
package/README.md CHANGED
@@ -2,14 +2,139 @@
2
2
 
3
3
  The official TypeScript SDK for the Cortex AI platform. Build powerful, context-aware AI applications in your Node.js or TypeScript projects.
4
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 - Cortex handles all!
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
+ ```
21
+ npm i @usecortex_ai/node
22
+ # or
23
+ yarn add @usecortex_ai/node
24
+ # or
25
+ pnpm add @usecortex_ai/node
26
+ ```
27
+
28
+ ### Client setup
29
+
30
+ ```ts
31
+ import { CortexAIClient } from "@usecortex_ai/node";
32
+
33
+ const client = new CortexAIClient({
34
+ token: process.env.CORTEX_API_KEY,
35
+ });
36
+ ```
37
+
38
+ ### Create a Tenant
39
+
40
+ 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)
41
+
42
+ ```ts
43
+ async function createTenant() {
44
+ const tenantCreationResponse = await client.user.createTenant({
45
+ tenant_id: "my-company"
46
+ });
47
+ return tenantCreationResponse;
48
+ }
49
+ ```
50
+
51
+ ### Index Your Data
52
+
53
+ When you index your data, you make it ready for retrieval from Cortex using natural language.
54
+
55
+ ```ts
56
+ // Upload text content
57
+ async function uploadText() {
58
+ const res = await client.upload.uploadText({
59
+ tenant_id: "my-company",
60
+ sub_tenant_id: "engineering",
61
+ body: {
62
+ content: "Our API rate limits are 1000 requests per minute for premium accounts.",
63
+ file_id: "api-docs-rate-limits",
64
+ tenant_metadata: { sub_tenant_id: "engineering" }
65
+ }
66
+ });
67
+ return res;
68
+ }
69
+
70
+ // Upload a document file
71
+ async function uploadFile() {
72
+ const uploadResult = await client.upload.uploadDocument({
73
+ file: fs.readFileSync("company-handbook.pdf"),
74
+ tenant_id: "my-company",
75
+ sub_tenant_id: "hr",
76
+ file_id: "doc_q1_summary"
77
+ });
78
+ return uploadResult;
79
+ }
80
+ ```
81
+
82
+ > **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).
83
+
84
+ ### Search and retrieval
85
+
86
+ ```ts
87
+ // Semantic search with retrieval
88
+ const results = await client.search.retrieve({
89
+ query: "What are the API rate limits?",
90
+ tenant_id: "my-company",
91
+ sub_tenant_id: "engineering",
92
+ max_chunks: 10
93
+ });
94
+
95
+ // List all sources
96
+ const allSources = await client.sources.getAll({
97
+ tenant_id: "my-company",
98
+ sub_tenant_id: "engineering"
99
+ });
100
+
101
+ // Get specific sources by ID
102
+ const specificSources = await client.sources.getByIds({
103
+ tenant_id: "my-company",
104
+ sub_tenant_id: "engineering",
105
+ source_ids: ["api-docs-rate-limits", "company-handbook"]
106
+ });
107
+ ```
108
+
109
+ > **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).
110
+
111
+ ## SDK Method Structure & Type Safety
112
+
113
+ Our SDKs follow a predictable pattern that mirrors the API structure while providing full type safety.
114
+
115
+ > **Method Mapping** : `client.<group>.<functionName>` mirrors `api.usecortex.ai/<group>/<function_name>`
116
+ >
117
+ > For example: `client.upload.uploadText()` corresponds to `POST /upload/upload_text`
118
+
119
+ The SDKs provide exact type parity with the API specification:
120
+
121
+ - **Request Parameters** : Every field documented in the API reference (required, optional, types, validation rules) is reflected in the SDK method signatures
122
+ - **Response Objects** : Return types match the exact JSON schema documented for each endpoint
123
+ - **Error Types** : Exception structures mirror the error response formats from the API
124
+ - **Nested Objects** : Complex nested parameters and responses maintain their full structure and typing
125
+
126
+ > 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.
127
+ >
128
+ > Just hit **Cmd+Space/Ctrl+Space!**
129
+
5
130
  ## Links
6
131
 
7
132
  - **Homepage:** [usecortex.ai](https://www.usecortex.ai/)
8
133
  - **Documentation:** [docs.usecortex.ai](https://docs.usecortex.ai/)
9
134
 
10
- ## Getting Started
135
+ ## Our docs
11
136
 
12
- 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.
137
+ 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.
13
138
 
14
139
  ## Support
15
140
 
@@ -1480,12 +1480,15 @@ class Upload {
1480
1480
  }
1481
1481
  async __verifyProcessing(request, requestOptions) {
1482
1482
  var _a, _b, _c;
1483
- const { file_id: fileId, tenant_id: tenantId } = request;
1483
+ const { file_id: fileId, tenant_id: tenantId, sub_tenant_id: subTenantId } = request;
1484
1484
  const _queryParams = {};
1485
1485
  _queryParams["file_id"] = fileId;
1486
1486
  if (tenantId != null) {
1487
1487
  _queryParams["tenant_id"] = tenantId;
1488
1488
  }
1489
+ if (subTenantId != null) {
1490
+ _queryParams["sub_tenant_id"] = subTenantId;
1491
+ }
1489
1492
  let _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: await this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
1490
1493
  const _response = await core.fetcher({
1491
1494
  url: core.url.join((_c = (_b = (await core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (await core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CortexAIEnvironment.CortexProd, "upload/verify_processing"),
@@ -13,4 +13,6 @@ export interface UploadVerifyProcessingRequest {
13
13
  file_id: string;
14
14
  /** Unique identifier for the tenant/organization */
15
15
  tenant_id?: string;
16
+ /** Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used. */
17
+ sub_tenant_id?: string;
16
18
  }
package/package.json CHANGED
@@ -1,19 +1,20 @@
1
1
  {
2
2
  "name": "@usecortex_ai/node",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "The official TypeScript SDK for the Cortex AI platform.",
5
5
  "author": "Nishkarsh Shrivastava <nishkarsh@usecortex.ai>",
6
- "license": "SEE LICENSE IN LICENSE",
7
- "private": false,
8
- "repository": {
9
- "type": "git",
10
- "url": "https://github.com/usefindr/cortex-ai-ts.git"
11
- },
12
6
  "main": "./dist/index.js",
13
7
  "types": "./dist/index.d.ts",
14
8
  "files": [
15
9
  "dist"
16
10
  ],
11
+ "keywords": [
12
+ "cortex",
13
+ "cortex-ai",
14
+ "cortex-ai-sdk",
15
+ "cortex-ai-typescript-sdk",
16
+ "rag", "gen-ai", "memory", "ai"
17
+ ],
17
18
  "scripts": {
18
19
  "build": "tsc",
19
20
  "prepublishOnly": "npm run build"