@nebula-ai/sdk 0.0.19 → 0.0.21
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/LICENSE +1 -1
- package/README.md +73 -18
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +119 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +119 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +65 -65
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @nebula-ai/sdk
|
|
2
2
|
|
|
3
|
-
Official JavaScript/TypeScript SDK for Nebula
|
|
3
|
+
Official JavaScript/TypeScript SDK for Nebula - Memory, Search, and AI-powered conversations.
|
|
4
4
|
|
|
5
5
|
[](https://badge.fury.io/js/%40nebula-ai%2Fsdk)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -31,10 +31,10 @@ pnpm add @nebula-ai/sdk
|
|
|
31
31
|
## Quick Start
|
|
32
32
|
|
|
33
33
|
```typescript
|
|
34
|
-
import {
|
|
34
|
+
import { NebulaClient, RetrievalType } from '@nebula-ai/sdk';
|
|
35
35
|
|
|
36
36
|
// Initialize the SDK
|
|
37
|
-
const client = new
|
|
37
|
+
const client = new NebulaClient({
|
|
38
38
|
apiKey: 'your-nebula-api-key',
|
|
39
39
|
baseUrl: 'https://api.nebulacloud.app', // optional, defaults to this
|
|
40
40
|
timeout: 30000 // optional, defaults to 30 seconds
|
|
@@ -70,7 +70,7 @@ console.log('Found memories:', results);
|
|
|
70
70
|
### Constructor
|
|
71
71
|
|
|
72
72
|
```typescript
|
|
73
|
-
new
|
|
73
|
+
new NebulaClient(config: NebulaClientConfig)
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
**Config Options:**
|
|
@@ -102,6 +102,20 @@ await client.updateCluster(clusterId: string, name?: string, description?: strin
|
|
|
102
102
|
await client.deleteCluster(clusterId: string)
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
+
#### Conversations
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
// List conversations for the authenticated user
|
|
109
|
+
await client.listConversations(limit?: number, offset?: number, cluster_ids?: string[])
|
|
110
|
+
|
|
111
|
+
// Get conversation messages
|
|
112
|
+
await client.getConversationMessages(conversationId: string): Promise<MemoryResponse[]>
|
|
113
|
+
await client.getConversationMessages(conversationIds: string[]): Promise<Record<string, MemoryResponse[]>>
|
|
114
|
+
|
|
115
|
+
// Delete a conversation and all its messages
|
|
116
|
+
await client.deleteConversation(conversationId: string)
|
|
117
|
+
```
|
|
118
|
+
|
|
105
119
|
#### Memories
|
|
106
120
|
|
|
107
121
|
```typescript
|
|
@@ -115,7 +129,7 @@ await client.storeMemories(memories: Memory[])
|
|
|
115
129
|
await client.getMemory(memoryId: string)
|
|
116
130
|
|
|
117
131
|
// List memories from clusters
|
|
118
|
-
await client.listMemories(clusterIds: string[], limit?: number, offset?: number)
|
|
132
|
+
await client.listMemories(clusterIds: string | string[], limit?: number, offset?: number)
|
|
119
133
|
|
|
120
134
|
// Delete a memory
|
|
121
135
|
await client.delete(memoryId: string)
|
|
@@ -127,8 +141,8 @@ await client.delete(memoryId: string)
|
|
|
127
141
|
// Search within clusters
|
|
128
142
|
await client.search(
|
|
129
143
|
query: string,
|
|
130
|
-
|
|
131
|
-
limit?: number,
|
|
144
|
+
clusters: string | string[],
|
|
145
|
+
limitOrOptions?: number | { limit?: number },
|
|
132
146
|
retrievalType?: RetrievalType | string,
|
|
133
147
|
filters?: Record<string, any>,
|
|
134
148
|
searchSettings?: Record<string, any>
|
|
@@ -191,6 +205,18 @@ interface SearchResult {
|
|
|
191
205
|
}
|
|
192
206
|
```
|
|
193
207
|
|
|
208
|
+
#### AgentResponse
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
interface AgentResponse {
|
|
212
|
+
content: string;
|
|
213
|
+
agent_id: string;
|
|
214
|
+
conversation_id?: string;
|
|
215
|
+
metadata: Record<string, any>;
|
|
216
|
+
citations: Record<string, any>[];
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
194
220
|
#### RetrievalType
|
|
195
221
|
|
|
196
222
|
```typescript
|
|
@@ -258,9 +284,9 @@ try {
|
|
|
258
284
|
### Basic Memory Management
|
|
259
285
|
|
|
260
286
|
```typescript
|
|
261
|
-
import {
|
|
287
|
+
import { NebulaClient } from '@nebula-ai/sdk';
|
|
262
288
|
|
|
263
|
-
const client = new
|
|
289
|
+
const client = new NebulaClient({ apiKey: 'your-key' });
|
|
264
290
|
|
|
265
291
|
async function manageMemories() {
|
|
266
292
|
// Create a cluster
|
|
@@ -296,9 +322,9 @@ async function manageMemories() {
|
|
|
296
322
|
### Conversation Tracking
|
|
297
323
|
|
|
298
324
|
```typescript
|
|
299
|
-
import {
|
|
325
|
+
import { NebulaClient } from '@nebula-ai/sdk';
|
|
300
326
|
|
|
301
|
-
const client = new
|
|
327
|
+
const client = new NebulaClient({ apiKey: 'your-key' });
|
|
302
328
|
|
|
303
329
|
async function trackConversation() {
|
|
304
330
|
const cluster = await client.createCluster('Conversations', 'AI chat history');
|
|
@@ -322,15 +348,44 @@ async function trackConversation() {
|
|
|
322
348
|
// Store conversation (returns conversation IDs)
|
|
323
349
|
const conversationIds = await client.storeMemories(conversationMemories);
|
|
324
350
|
console.log('Conversation IDs:', conversationIds);
|
|
351
|
+
|
|
352
|
+
// Retrieve conversation messages directly from conversations API
|
|
353
|
+
const messages = await client.getConversationMessages(conversationIds[0]);
|
|
354
|
+
console.log('Conversation messages:', messages);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
### Managing Conversations
|
|
358
|
+
|
|
359
|
+
```typescript
|
|
360
|
+
import { NebulaClient } from '@nebula-ai/sdk';
|
|
361
|
+
|
|
362
|
+
const client = new NebulaClient({ apiKey: 'your-key' });
|
|
363
|
+
|
|
364
|
+
async function manageConversations() {
|
|
365
|
+
// List all conversations
|
|
366
|
+
const conversations = await client.listConversations(10, 0);
|
|
367
|
+
console.log('All conversations:', conversations);
|
|
368
|
+
|
|
369
|
+
// Get messages from a specific conversation
|
|
370
|
+
const messages = await client.getConversationMessages('conversation-id');
|
|
371
|
+
console.log('Conversation messages:', messages);
|
|
372
|
+
|
|
373
|
+
// Get messages from multiple conversations at once
|
|
374
|
+
const multipleMessages = await client.getConversationMessages(['conv1', 'conv2']);
|
|
375
|
+
console.log('Multiple conversations:', multipleMessages);
|
|
376
|
+
|
|
377
|
+
// Delete a conversation
|
|
378
|
+
await client.deleteConversation('conversation-id');
|
|
379
|
+
console.log('Conversation deleted');
|
|
325
380
|
}
|
|
326
381
|
```
|
|
327
382
|
|
|
328
383
|
### Advanced Search with Graph Results
|
|
329
384
|
|
|
330
385
|
```typescript
|
|
331
|
-
import {
|
|
386
|
+
import { NebulaClient, RetrievalType } from '@nebula-ai/sdk';
|
|
332
387
|
|
|
333
|
-
const client = new
|
|
388
|
+
const client = new NebulaClient({ apiKey: 'your-key' });
|
|
334
389
|
|
|
335
390
|
async function advancedSearch() {
|
|
336
391
|
const cluster = await client.createCluster('Knowledge Graph', 'Entity relationships');
|
|
@@ -380,9 +435,9 @@ async function advancedSearch() {
|
|
|
380
435
|
### Browser Usage
|
|
381
436
|
|
|
382
437
|
```typescript
|
|
383
|
-
import {
|
|
438
|
+
import { NebulaClient } from '@nebula-ai/sdk';
|
|
384
439
|
|
|
385
|
-
const client = new
|
|
440
|
+
const client = new NebulaClient({
|
|
386
441
|
apiKey: 'your-api-key'
|
|
387
442
|
// Note: CORS handling is now built into the SDK
|
|
388
443
|
});
|
|
@@ -391,9 +446,9 @@ const client = new NebulaSDK({
|
|
|
391
446
|
### Node.js Usage
|
|
392
447
|
|
|
393
448
|
```typescript
|
|
394
|
-
import {
|
|
449
|
+
import { NebulaClient } from '@nebula-ai/sdk';
|
|
395
450
|
|
|
396
|
-
const client = new
|
|
451
|
+
const client = new NebulaClient({
|
|
397
452
|
apiKey: 'your-api-key'
|
|
398
453
|
// No additional configuration needed
|
|
399
454
|
});
|
|
@@ -435,7 +490,7 @@ MIT License - see [LICENSE](LICENSE) file for details.
|
|
|
435
490
|
|
|
436
491
|
- 📧 Email: support@trynebula.ai
|
|
437
492
|
- 🐛 Issues: [GitHub Issues](https://github.com/nebula-cloud/nebula-sdk-js/issues)
|
|
438
|
-
- 📚 Documentation: [Nebula
|
|
493
|
+
- 📚 Documentation: [Nebula Docs](https://docs.trynebula.ai)
|
|
439
494
|
|
|
440
495
|
## Changelog
|
|
441
496
|
|
package/dist/index.d.mts
CHANGED
|
@@ -173,6 +173,10 @@ declare class NebulaSDK {
|
|
|
173
173
|
* Delete a specific memory
|
|
174
174
|
*/
|
|
175
175
|
delete(memoryId: string): Promise<boolean>;
|
|
176
|
+
/**
|
|
177
|
+
* Delete a conversation and all its messages
|
|
178
|
+
*/
|
|
179
|
+
deleteConversation(conversationId: string): Promise<boolean>;
|
|
176
180
|
/**
|
|
177
181
|
* Get all memories from specific clusters
|
|
178
182
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -173,6 +173,10 @@ declare class NebulaSDK {
|
|
|
173
173
|
* Delete a specific memory
|
|
174
174
|
*/
|
|
175
175
|
delete(memoryId: string): Promise<boolean>;
|
|
176
|
+
/**
|
|
177
|
+
* Delete a conversation and all its messages
|
|
178
|
+
*/
|
|
179
|
+
deleteConversation(conversationId: string): Promise<boolean>;
|
|
176
180
|
/**
|
|
177
181
|
* Get all memories from specific clusters
|
|
178
182
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
// src/types.ts
|
|
6
4
|
var RetrievalType = /* @__PURE__ */ ((RetrievalType2) => {
|
|
7
5
|
RetrievalType2["BASIC"] = "basic";
|
|
@@ -57,7 +55,7 @@ var NebulaClusterNotFoundException = class extends NebulaException {
|
|
|
57
55
|
};
|
|
58
56
|
|
|
59
57
|
// src/client.ts
|
|
60
|
-
var
|
|
58
|
+
var NebulaClient = class {
|
|
61
59
|
constructor(config) {
|
|
62
60
|
this.apiKey = config.apiKey;
|
|
63
61
|
if (!this.apiKey) {
|
|
@@ -108,12 +106,23 @@ var NebulaSDK = class {
|
|
|
108
106
|
async _makeRequest(method, endpoint, jsonData, params) {
|
|
109
107
|
const url = new URL(endpoint, this.baseUrl);
|
|
110
108
|
if (params) {
|
|
109
|
+
console.log("SDK: _makeRequest params before processing:", params);
|
|
111
110
|
Object.entries(params).forEach(([key, value]) => {
|
|
112
111
|
if (value !== void 0 && value !== null) {
|
|
113
|
-
|
|
112
|
+
if (Array.isArray(value)) {
|
|
113
|
+
console.log(`SDK: Adding array param ${key}:`, value);
|
|
114
|
+
value.forEach((item) => {
|
|
115
|
+
url.searchParams.append(key, String(item));
|
|
116
|
+
console.log(`SDK: Appended ${key}=${item} to URL`);
|
|
117
|
+
});
|
|
118
|
+
} else {
|
|
119
|
+
console.log(`SDK: Adding single param ${key}:`, value);
|
|
120
|
+
url.searchParams.append(key, String(value));
|
|
121
|
+
}
|
|
114
122
|
}
|
|
115
123
|
});
|
|
116
124
|
}
|
|
125
|
+
console.log("SDK: Final URL being requested:", url.toString());
|
|
117
126
|
const headers = this._buildAuthHeaders(true);
|
|
118
127
|
const controller = new AbortController();
|
|
119
128
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
@@ -158,26 +167,26 @@ var NebulaSDK = class {
|
|
|
158
167
|
const data = { name };
|
|
159
168
|
if (description) data.description = description;
|
|
160
169
|
if (metadata) data.metadata = metadata;
|
|
161
|
-
const response = await this._makeRequest("POST", "/
|
|
170
|
+
const response = await this._makeRequest("POST", "/v1/collections", data);
|
|
162
171
|
const result = response.results || response;
|
|
163
172
|
return this._clusterFromDict(result);
|
|
164
173
|
}
|
|
165
174
|
/** Get a specific cluster by ID */
|
|
166
175
|
async getCluster(clusterId) {
|
|
167
|
-
const response = await this._makeRequest("GET", `/
|
|
176
|
+
const response = await this._makeRequest("GET", `/v1/collections/${clusterId}`);
|
|
168
177
|
const result = response.results || response;
|
|
169
178
|
return this._clusterFromDict(result);
|
|
170
179
|
}
|
|
171
180
|
/** Get a specific cluster by name */
|
|
172
181
|
async getClusterByName(name) {
|
|
173
|
-
const response = await this._makeRequest("GET", `/
|
|
182
|
+
const response = await this._makeRequest("GET", `/v1/collections/name/${name}`);
|
|
174
183
|
const result = response.results || response;
|
|
175
184
|
return this._clusterFromDict(result);
|
|
176
185
|
}
|
|
177
186
|
/** Get all clusters */
|
|
178
187
|
async listClusters(limit = 100, offset = 0) {
|
|
179
188
|
const params = { limit, offset };
|
|
180
|
-
const response = await this._makeRequest("GET", "/
|
|
189
|
+
const response = await this._makeRequest("GET", "/v1/collections", void 0, params);
|
|
181
190
|
let clusters;
|
|
182
191
|
if (response.results) {
|
|
183
192
|
clusters = response.results;
|
|
@@ -190,9 +199,12 @@ var NebulaSDK = class {
|
|
|
190
199
|
}
|
|
191
200
|
// Conversations Methods
|
|
192
201
|
/** List conversations for the authenticated user */
|
|
193
|
-
async listConversations(limit = 100, offset = 0) {
|
|
202
|
+
async listConversations(limit = 100, offset = 0, cluster_ids) {
|
|
194
203
|
const params = { limit, offset };
|
|
195
|
-
|
|
204
|
+
if (cluster_ids && cluster_ids.length > 0) {
|
|
205
|
+
params.collection_ids = cluster_ids;
|
|
206
|
+
}
|
|
207
|
+
const response = await this._makeRequest("GET", "/v1/conversations", void 0, params);
|
|
196
208
|
let conversations;
|
|
197
209
|
if (response && response.results) {
|
|
198
210
|
conversations = response.results;
|
|
@@ -203,19 +215,91 @@ var NebulaSDK = class {
|
|
|
203
215
|
}
|
|
204
216
|
return conversations;
|
|
205
217
|
}
|
|
218
|
+
async getConversationMessages(conversationIdOrIds) {
|
|
219
|
+
if (typeof conversationIdOrIds === "string") {
|
|
220
|
+
const response2 = await this._makeRequest("GET", `/v1/conversations/${conversationIdOrIds}`);
|
|
221
|
+
if (!response2 || !response2.results) {
|
|
222
|
+
return [];
|
|
223
|
+
}
|
|
224
|
+
return this._transformConversationMessages(response2.results);
|
|
225
|
+
}
|
|
226
|
+
if (!Array.isArray(conversationIdOrIds) || conversationIdOrIds.length === 0) {
|
|
227
|
+
return {};
|
|
228
|
+
}
|
|
229
|
+
const response = await this._makeRequest("POST", "/v1/conversations/batch", {
|
|
230
|
+
conversation_ids: conversationIdOrIds
|
|
231
|
+
});
|
|
232
|
+
console.log("\u{1F50D} SDK: Raw batch response:", response);
|
|
233
|
+
console.log("\u{1F50D} SDK: Response has results?", !!response?.results);
|
|
234
|
+
if (response?.results) {
|
|
235
|
+
console.log("\u{1F50D} SDK: Results keys:", Object.keys(response.results));
|
|
236
|
+
console.log("\u{1F50D} SDK: Sample result:", Object.keys(response.results)[0], ":", response.results[Object.keys(response.results)[0]]);
|
|
237
|
+
}
|
|
238
|
+
const results = {};
|
|
239
|
+
if (response && response.results) {
|
|
240
|
+
const batchResults = response.results.results || response.results;
|
|
241
|
+
console.log("\u{1F50D} SDK: Processing", Object.keys(batchResults).length, "conversations");
|
|
242
|
+
for (const [conversationId, messages] of Object.entries(batchResults)) {
|
|
243
|
+
if (Array.isArray(messages)) {
|
|
244
|
+
const transformed = this._transformConversationMessages(messages);
|
|
245
|
+
results[conversationId] = transformed;
|
|
246
|
+
console.log(`\u{1F50D} SDK: Conversation ${conversationId.slice(-8)}: ${messages.length} raw -> ${transformed.length} transformed`);
|
|
247
|
+
} else {
|
|
248
|
+
results[conversationId] = [];
|
|
249
|
+
console.log(`\u{1F50D} SDK: Conversation ${conversationId.slice(-8)}: not array, setting empty`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
for (const conversationId of conversationIdOrIds) {
|
|
254
|
+
if (!(conversationId in results)) {
|
|
255
|
+
results[conversationId] = [];
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return results;
|
|
259
|
+
}
|
|
260
|
+
/** Helper method to transform conversation messages to MemoryResponse format */
|
|
261
|
+
_transformConversationMessages(messageResponses) {
|
|
262
|
+
return messageResponses.map((msgResp) => {
|
|
263
|
+
const msgId = String(msgResp.id || "");
|
|
264
|
+
const msg = msgResp.message || {};
|
|
265
|
+
const metadata = msgResp.metadata || {};
|
|
266
|
+
let text = "";
|
|
267
|
+
const rawContent = msg.content;
|
|
268
|
+
if (typeof rawContent === "string") {
|
|
269
|
+
text = rawContent;
|
|
270
|
+
} else if (rawContent && typeof rawContent === "object") {
|
|
271
|
+
text = String(rawContent.content || rawContent.text || JSON.stringify(rawContent));
|
|
272
|
+
} else if (rawContent != null) {
|
|
273
|
+
text = String(rawContent);
|
|
274
|
+
}
|
|
275
|
+
const role = msg.role || metadata.role || "user";
|
|
276
|
+
const combinedMetadata = {
|
|
277
|
+
...metadata,
|
|
278
|
+
role
|
|
279
|
+
// Ensure role is in metadata for UI compatibility
|
|
280
|
+
};
|
|
281
|
+
return {
|
|
282
|
+
id: msgId,
|
|
283
|
+
content: text,
|
|
284
|
+
metadata: combinedMetadata,
|
|
285
|
+
created_at: msgResp.created_at,
|
|
286
|
+
cluster_ids: msgResp.collection_ids || []
|
|
287
|
+
};
|
|
288
|
+
});
|
|
289
|
+
}
|
|
206
290
|
/** Update a cluster */
|
|
207
291
|
async updateCluster(clusterId, name, description, metadata) {
|
|
208
292
|
const data = {};
|
|
209
293
|
if (name !== void 0) data.name = name;
|
|
210
294
|
if (description !== void 0) data.description = description;
|
|
211
295
|
if (metadata !== void 0) data.metadata = metadata;
|
|
212
|
-
const response = await this._makeRequest("POST", `/
|
|
296
|
+
const response = await this._makeRequest("POST", `/v1/collections/${clusterId}`, data);
|
|
213
297
|
const result = response.results || response;
|
|
214
298
|
return this._clusterFromDict(result);
|
|
215
299
|
}
|
|
216
300
|
/** Delete a cluster */
|
|
217
301
|
async deleteCluster(clusterId) {
|
|
218
|
-
await this._makeRequest("DELETE", `/
|
|
302
|
+
await this._makeRequest("DELETE", `/v1/collections/${clusterId}`);
|
|
219
303
|
return true;
|
|
220
304
|
}
|
|
221
305
|
// Memory Management Methods
|
|
@@ -234,7 +318,7 @@ var NebulaSDK = class {
|
|
|
234
318
|
collection_ids: JSON.stringify([clusterId]),
|
|
235
319
|
raw_text: String(content || "")
|
|
236
320
|
};
|
|
237
|
-
const url = `${this.baseUrl}/
|
|
321
|
+
const url = `${this.baseUrl}/v1/documents`;
|
|
238
322
|
const headers = this._buildAuthHeaders(false);
|
|
239
323
|
const response = await fetch(url, {
|
|
240
324
|
method: "POST",
|
|
@@ -278,7 +362,7 @@ var NebulaSDK = class {
|
|
|
278
362
|
if (mem.role) {
|
|
279
363
|
let convId = mem.parent_id;
|
|
280
364
|
if (!convId) {
|
|
281
|
-
const created = await this._makeRequest("POST", "/
|
|
365
|
+
const created = await this._makeRequest("POST", "/v1/conversations", {});
|
|
282
366
|
const conv = created.results || created;
|
|
283
367
|
convId = conv.id;
|
|
284
368
|
if (!convId) {
|
|
@@ -295,7 +379,7 @@ var NebulaSDK = class {
|
|
|
295
379
|
],
|
|
296
380
|
collection_id: mem.cluster_id
|
|
297
381
|
};
|
|
298
|
-
await this._makeRequest("POST", `/
|
|
382
|
+
await this._makeRequest("POST", `/v1/conversations/${convId}/messages`, payload);
|
|
299
383
|
return String(convId);
|
|
300
384
|
}
|
|
301
385
|
const contentText = String(mem.content || "");
|
|
@@ -309,7 +393,7 @@ var NebulaSDK = class {
|
|
|
309
393
|
collection_ids: JSON.stringify([mem.cluster_id]),
|
|
310
394
|
raw_text: contentText
|
|
311
395
|
};
|
|
312
|
-
const url = `${this.baseUrl}/
|
|
396
|
+
const url = `${this.baseUrl}/v1/documents`;
|
|
313
397
|
const headers = this._buildAuthHeaders(false);
|
|
314
398
|
const response = await fetch(url, {
|
|
315
399
|
method: "POST",
|
|
@@ -349,7 +433,7 @@ var NebulaSDK = class {
|
|
|
349
433
|
const clusterId = group[0].cluster_id;
|
|
350
434
|
let convId;
|
|
351
435
|
if (key.startsWith("__new__::")) {
|
|
352
|
-
const created = await this._makeRequest("POST", "/
|
|
436
|
+
const created = await this._makeRequest("POST", "/v1/conversations", {});
|
|
353
437
|
const conv = created.results || created;
|
|
354
438
|
convId = conv.id;
|
|
355
439
|
if (!convId) {
|
|
@@ -364,7 +448,7 @@ var NebulaSDK = class {
|
|
|
364
448
|
metadata: m.metadata || {}
|
|
365
449
|
}));
|
|
366
450
|
const payload = { messages, collection_id: clusterId };
|
|
367
|
-
await this._makeRequest("POST", `/
|
|
451
|
+
await this._makeRequest("POST", `/v1/conversations/${convId}/messages`, payload);
|
|
368
452
|
results.push(...Array(group.length).fill(String(convId)));
|
|
369
453
|
}
|
|
370
454
|
for (const m of others) {
|
|
@@ -375,7 +459,19 @@ var NebulaSDK = class {
|
|
|
375
459
|
/** Delete a specific memory */
|
|
376
460
|
async delete(memoryId) {
|
|
377
461
|
try {
|
|
378
|
-
await this._makeRequest("DELETE", `/
|
|
462
|
+
await this._makeRequest("DELETE", `/v1/documents/${memoryId}`);
|
|
463
|
+
return true;
|
|
464
|
+
} catch (error) {
|
|
465
|
+
if (error instanceof Error) {
|
|
466
|
+
throw error;
|
|
467
|
+
}
|
|
468
|
+
throw new NebulaClientException(`Unknown error: ${String(error)}`);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
/** Delete a conversation and all its messages */
|
|
472
|
+
async deleteConversation(conversationId) {
|
|
473
|
+
try {
|
|
474
|
+
await this._makeRequest("DELETE", `/v1/conversations/${conversationId}`);
|
|
379
475
|
return true;
|
|
380
476
|
} catch (error) {
|
|
381
477
|
if (error instanceof Error) {
|
|
@@ -391,7 +487,7 @@ var NebulaSDK = class {
|
|
|
391
487
|
throw new NebulaClientException("cluster_ids must be provided to list_memories().");
|
|
392
488
|
}
|
|
393
489
|
const params = { limit, offset, collection_ids: ids };
|
|
394
|
-
const response = await this._makeRequest("GET", "/
|
|
490
|
+
const response = await this._makeRequest("GET", "/v1/documents", void 0, params);
|
|
395
491
|
let documents;
|
|
396
492
|
if (response.results) {
|
|
397
493
|
documents = response.results;
|
|
@@ -404,7 +500,7 @@ var NebulaSDK = class {
|
|
|
404
500
|
}
|
|
405
501
|
/** Get a specific memory by ID */
|
|
406
502
|
async getMemory(memoryId) {
|
|
407
|
-
const response = await this._makeRequest("GET", `/
|
|
503
|
+
const response = await this._makeRequest("GET", `/v1/documents/${memoryId}`);
|
|
408
504
|
const content = response.text || response.content;
|
|
409
505
|
const chunks = Array.isArray(response.chunks) ? response.chunks : void 0;
|
|
410
506
|
const memoryData = {
|
|
@@ -462,7 +558,7 @@ var NebulaSDK = class {
|
|
|
462
558
|
search_mode: "custom",
|
|
463
559
|
search_settings: effectiveSettings
|
|
464
560
|
};
|
|
465
|
-
const response = await this._makeRequest("POST", "/
|
|
561
|
+
const response = await this._makeRequest("POST", "/v1/retrieval/search", data);
|
|
466
562
|
let chunkResults = [];
|
|
467
563
|
let graphResults = [];
|
|
468
564
|
if (response.results) {
|
|
@@ -647,18 +743,14 @@ Assistant: ${String(assistantMessage || "")}`;
|
|
|
647
743
|
}
|
|
648
744
|
};
|
|
649
745
|
|
|
650
|
-
// src/index.ts
|
|
651
|
-
var index_default = NebulaSDK;
|
|
652
|
-
|
|
653
746
|
exports.GraphSearchResultType = GraphSearchResultType;
|
|
654
747
|
exports.NebulaAuthenticationException = NebulaAuthenticationException;
|
|
748
|
+
exports.NebulaClient = NebulaClient;
|
|
655
749
|
exports.NebulaClientException = NebulaClientException;
|
|
656
750
|
exports.NebulaClusterNotFoundException = NebulaClusterNotFoundException;
|
|
657
751
|
exports.NebulaException = NebulaException;
|
|
658
752
|
exports.NebulaRateLimitException = NebulaRateLimitException;
|
|
659
|
-
exports.NebulaSDK = NebulaSDK;
|
|
660
753
|
exports.NebulaValidationException = NebulaValidationException;
|
|
661
754
|
exports.RetrievalType = RetrievalType;
|
|
662
|
-
exports.default = index_default;
|
|
663
755
|
//# sourceMappingURL=index.js.map
|
|
664
756
|
//# sourceMappingURL=index.js.map
|