@usecortex_ai/node 0.5.1 → 0.5.2

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 (2) hide show
  1. package/README.md +86 -45
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -41,7 +41,7 @@ You can consider a `tenant` as a single database that can have internal isolated
41
41
 
42
42
  ```ts
43
43
  async function createTenant() {
44
- const tenantCreationResponse = await client.user.createTenant({
44
+ const tenantCreationResponse = await client.tenant.create({
45
45
  tenant_id: "my-company"
46
46
  });
47
47
  return tenantCreationResponse;
@@ -53,60 +53,101 @@ async function createTenant() {
53
53
  When you index your data, you make it ready for retrieval from Cortex using natural language.
54
54
 
55
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" }
56
+ // Add to your knowledge base
57
+ import fs from 'fs';
58
+
59
+ const uploadResult = await client.upload.knowledge({
60
+ files: [
61
+ fs.readFileSync("a.pdf"),
62
+ fs.readFileSync("b.pdf")
63
+ ],
64
+ tenant_id: "tenant_123",
65
+ file_metadata: [
66
+ {
67
+ id: "doc_a",
68
+ tenant_metadata: { dept: "sales" },
69
+ document_metadata: { author: "Alice" },
70
+ relations: false
71
+ },
72
+ {
73
+ id: "doc_b",
74
+ tenant_metadata: { dept: "marketing" },
75
+ document_metadata: { author: "Bob" },
76
+ relations: true
65
77
  }
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).
78
+ ]
79
+ });
83
80
 
84
- ### Search and retrieval
81
+ // Index user memories
82
+ const result = await client.userMemory.add({
83
+ memories: [
84
+ {
85
+ text: "User prefers detailed explanations and dark mode",
86
+ infer: true,
87
+ user_name: "John"
88
+ }
89
+ ],
90
+ tenant_id: "tenant-01",
91
+ sub_tenant_id: "",
92
+ upsert: true
93
+ });
85
94
 
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
95
+ // Markdown content
96
+ const markdownResult = await client.userMemory.add({
97
+ memories: [
98
+ {
99
+ text: "# Meeting Notes\n\n## Key Points\n- Budget approved\n- Launch date: Q2",
100
+ is_markdown: true,
101
+ infer: false,
102
+ title: "Meeting Notes"
103
+ }
104
+ ],
105
+ tenant_id: "tenant-01",
106
+ sub_tenant_id: "",
107
+ upsert: true
93
108
  });
94
109
 
95
- // List all sources
96
- const allSources = await client.sources.getAll({
97
- tenant_id: "my-company",
98
- sub_tenant_id: "engineering"
110
+ // User-assistant pairs with inference
111
+ const conversationResult = await client.userMemory.add({
112
+ memories: [
113
+ {
114
+ user_assistant_pairs: [
115
+ { user: "What are my preferences?", assistant: "You prefer dark mode and detailed explanations." },
116
+ { user: "How do I like my reports?", assistant: "You prefer weekly summary reports with charts." }
117
+ ],
118
+ infer: true,
119
+ user_name: "John",
120
+ custom_instructions: "Extract user preferences"
121
+ }
122
+ ],
123
+ tenant_id: "tenant-01",
124
+ sub_tenant_id: "",
125
+ upsert: true
99
126
  });
127
+ ```
128
+
129
+ > **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](https://docs.usecortex.ai/api-reference/endpoint/add-knowledge-memories).
100
130
 
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"]
131
+ ### Search
132
+
133
+ ```ts
134
+ // Search across memories/knowledge base
135
+ const results = await client.recall.fullRecall({
136
+ query: "Which mode does user prefer",
137
+ tenantId: "tenant_1234",
138
+ subTenantId: "sub_tenant_4567",
139
+ alpha: 0.8,
140
+ recencyBias: 0
141
+ });;
142
+
143
+ // List all the data (memories + knowledge base)
144
+ const allSources = await client.data.listData({
145
+ tenant_id: "tenant_1234",
146
+ sub_tenant_id: "sub_tenant_4567"
106
147
  });
107
148
  ```
108
149
 
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).
150
+ > **For a more detailed explanation** of search and retrieval, including query parameters, scoring mechanisms, result structure, and advanced search features, refer to the [Recall endpoint documentation](https://docs.usecortex.ai/api-reference/endpoint/smart).
110
151
 
111
152
  ## SDK Method Structure & Type Safety
112
153
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usecortex_ai/node",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "The official TypeScript SDK for the Cortex AI platform.",
5
5
  "author": "Nishkarsh Shrivastava <nishkarsh@usecortex.ai>",
6
6
  "main": "./dist/index.js",