@mastra/lance 0.1.2 → 0.1.3-alpha.1
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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +24 -0
- package/dist/_tsup-dts-rollup.d.cts +10 -0
- package/dist/_tsup-dts-rollup.d.ts +10 -0
- package/dist/index.cjs +790 -153
- package/dist/index.js +757 -120
- package/package.json +2 -2
- package/src/storage/index.test.ts +1 -1
- package/src/storage/index.ts +473 -61
- package/src/vector/index.test.ts +3 -3
- package/src/vector/index.ts +316 -75
package/src/vector/index.test.ts
CHANGED
|
@@ -220,8 +220,8 @@ describe('Lance vector store tests', () => {
|
|
|
220
220
|
});
|
|
221
221
|
|
|
222
222
|
it('should throw error when no data is provided', async () => {
|
|
223
|
-
await expect(vectorDB.createTable(testTableName, [])).rejects.
|
|
224
|
-
|
|
223
|
+
await expect(vectorDB.createTable(testTableName, [])).rejects.toThrowError(
|
|
224
|
+
/At least one record or a schema needs/,
|
|
225
225
|
);
|
|
226
226
|
});
|
|
227
227
|
|
|
@@ -434,7 +434,7 @@ describe('Lance vector store tests', () => {
|
|
|
434
434
|
columns: ['id', 'vector', 'metadata'],
|
|
435
435
|
queryVector: [0.1, 0.2, 0.3],
|
|
436
436
|
}),
|
|
437
|
-
).rejects.
|
|
437
|
+
).rejects.toThrowError(new RegExp(`Table '${nonExistentTable}'`));
|
|
438
438
|
});
|
|
439
439
|
});
|
|
440
440
|
|
package/src/vector/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
UpdateVectorParams,
|
|
13
13
|
UpsertVectorParams,
|
|
14
14
|
} from '@mastra/core';
|
|
15
|
+
import { ErrorCategory, ErrorDomain, MastraError } from '@mastra/core/error';
|
|
15
16
|
|
|
16
17
|
import { MastraVector } from '@mastra/core/vector';
|
|
17
18
|
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
@@ -69,7 +70,15 @@ export class LanceVectorStore extends MastraVector {
|
|
|
69
70
|
instance.lanceClient = await connect(uri, options);
|
|
70
71
|
return instance;
|
|
71
72
|
} catch (e) {
|
|
72
|
-
throw new
|
|
73
|
+
throw new MastraError(
|
|
74
|
+
{
|
|
75
|
+
id: 'STORAGE_LANCE_VECTOR_CONNECT_FAILED',
|
|
76
|
+
domain: ErrorDomain.STORAGE,
|
|
77
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
78
|
+
details: { uri },
|
|
79
|
+
},
|
|
80
|
+
e,
|
|
81
|
+
);
|
|
73
82
|
}
|
|
74
83
|
}
|
|
75
84
|
|
|
@@ -96,16 +105,29 @@ export class LanceVectorStore extends MastraVector {
|
|
|
96
105
|
columns = [],
|
|
97
106
|
includeAllColumns = false,
|
|
98
107
|
}: LanceQueryVectorParams): Promise<QueryResult[]> {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
108
|
+
try {
|
|
109
|
+
if (!this.lanceClient) {
|
|
110
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
111
|
+
}
|
|
102
112
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
113
|
+
if (!tableName) {
|
|
114
|
+
throw new Error('tableName is required');
|
|
115
|
+
}
|
|
106
116
|
|
|
107
|
-
|
|
108
|
-
|
|
117
|
+
if (!queryVector) {
|
|
118
|
+
throw new Error('queryVector is required');
|
|
119
|
+
}
|
|
120
|
+
} catch (error) {
|
|
121
|
+
throw new MastraError(
|
|
122
|
+
{
|
|
123
|
+
id: 'STORAGE_LANCE_VECTOR_QUERY_FAILED_INVALID_ARGS',
|
|
124
|
+
domain: ErrorDomain.STORAGE,
|
|
125
|
+
category: ErrorCategory.USER,
|
|
126
|
+
text: 'LanceDB client not initialized. Use LanceVectorStore.create() to create an instance',
|
|
127
|
+
details: { tableName },
|
|
128
|
+
},
|
|
129
|
+
error,
|
|
130
|
+
);
|
|
109
131
|
}
|
|
110
132
|
|
|
111
133
|
try {
|
|
@@ -170,7 +192,15 @@ export class LanceVectorStore extends MastraVector {
|
|
|
170
192
|
};
|
|
171
193
|
});
|
|
172
194
|
} catch (error: any) {
|
|
173
|
-
throw new
|
|
195
|
+
throw new MastraError(
|
|
196
|
+
{
|
|
197
|
+
id: 'STORAGE_LANCE_VECTOR_QUERY_FAILED',
|
|
198
|
+
domain: ErrorDomain.STORAGE,
|
|
199
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
200
|
+
details: { tableName, includeVector, columnsCount: columns?.length, includeAllColumns },
|
|
201
|
+
},
|
|
202
|
+
error,
|
|
203
|
+
);
|
|
174
204
|
}
|
|
175
205
|
}
|
|
176
206
|
|
|
@@ -217,16 +247,29 @@ export class LanceVectorStore extends MastraVector {
|
|
|
217
247
|
}
|
|
218
248
|
|
|
219
249
|
async upsert({ tableName, vectors, metadata = [], ids = [] }: LanceUpsertVectorParams): Promise<string[]> {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
250
|
+
try {
|
|
251
|
+
if (!this.lanceClient) {
|
|
252
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
253
|
+
}
|
|
223
254
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
255
|
+
if (!tableName) {
|
|
256
|
+
throw new Error('tableName is required');
|
|
257
|
+
}
|
|
227
258
|
|
|
228
|
-
|
|
229
|
-
|
|
259
|
+
if (!vectors || !Array.isArray(vectors) || vectors.length === 0) {
|
|
260
|
+
throw new Error('vectors array is required and must not be empty');
|
|
261
|
+
}
|
|
262
|
+
} catch (error) {
|
|
263
|
+
throw new MastraError(
|
|
264
|
+
{
|
|
265
|
+
id: 'STORAGE_LANCE_VECTOR_UPSERT_FAILED_INVALID_ARGS',
|
|
266
|
+
domain: ErrorDomain.STORAGE,
|
|
267
|
+
category: ErrorCategory.USER,
|
|
268
|
+
text: 'LanceDB client not initialized. Use LanceVectorStore.create() to create an instance',
|
|
269
|
+
details: { tableName },
|
|
270
|
+
},
|
|
271
|
+
error,
|
|
272
|
+
);
|
|
230
273
|
}
|
|
231
274
|
|
|
232
275
|
try {
|
|
@@ -267,7 +310,15 @@ export class LanceVectorStore extends MastraVector {
|
|
|
267
310
|
|
|
268
311
|
return vectorIds;
|
|
269
312
|
} catch (error: any) {
|
|
270
|
-
throw new
|
|
313
|
+
throw new MastraError(
|
|
314
|
+
{
|
|
315
|
+
id: 'STORAGE_LANCE_VECTOR_UPSERT_FAILED',
|
|
316
|
+
domain: ErrorDomain.STORAGE,
|
|
317
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
318
|
+
details: { tableName, vectorCount: vectors.length, metadataCount: metadata.length, idsCount: ids.length },
|
|
319
|
+
},
|
|
320
|
+
error,
|
|
321
|
+
);
|
|
271
322
|
}
|
|
272
323
|
}
|
|
273
324
|
|
|
@@ -293,34 +344,84 @@ export class LanceVectorStore extends MastraVector {
|
|
|
293
344
|
options?: Partial<CreateTableOptions>,
|
|
294
345
|
): Promise<Table> {
|
|
295
346
|
if (!this.lanceClient) {
|
|
296
|
-
throw new
|
|
347
|
+
throw new MastraError({
|
|
348
|
+
id: 'STORAGE_LANCE_VECTOR_CREATE_TABLE_FAILED_INVALID_ARGS',
|
|
349
|
+
domain: ErrorDomain.STORAGE,
|
|
350
|
+
category: ErrorCategory.USER,
|
|
351
|
+
text: 'LanceDB client not initialized. Use LanceVectorStore.create() to create an instance',
|
|
352
|
+
details: { tableName },
|
|
353
|
+
});
|
|
297
354
|
}
|
|
298
355
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
356
|
+
// Flatten nested objects if data is an array of records
|
|
357
|
+
if (Array.isArray(data)) {
|
|
358
|
+
data = data.map(record => this.flattenObject(record));
|
|
359
|
+
}
|
|
304
360
|
|
|
361
|
+
try {
|
|
305
362
|
return await this.lanceClient.createTable(tableName, data, options);
|
|
306
363
|
} catch (error: any) {
|
|
307
|
-
throw new
|
|
364
|
+
throw new MastraError(
|
|
365
|
+
{
|
|
366
|
+
id: 'STORAGE_LANCE_VECTOR_CREATE_TABLE_FAILED',
|
|
367
|
+
domain: ErrorDomain.STORAGE,
|
|
368
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
369
|
+
details: { tableName },
|
|
370
|
+
},
|
|
371
|
+
error,
|
|
372
|
+
);
|
|
308
373
|
}
|
|
309
374
|
}
|
|
310
375
|
|
|
311
376
|
async listTables(): Promise<string[]> {
|
|
312
377
|
if (!this.lanceClient) {
|
|
313
|
-
throw new
|
|
378
|
+
throw new MastraError({
|
|
379
|
+
id: 'STORAGE_LANCE_VECTOR_LIST_TABLES_FAILED_INVALID_ARGS',
|
|
380
|
+
domain: ErrorDomain.STORAGE,
|
|
381
|
+
category: ErrorCategory.USER,
|
|
382
|
+
text: 'LanceDB client not initialized. Use LanceVectorStore.create() to create an instance',
|
|
383
|
+
details: { methodName: 'listTables' },
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
try {
|
|
387
|
+
return await this.lanceClient.tableNames();
|
|
388
|
+
} catch (error) {
|
|
389
|
+
throw new MastraError(
|
|
390
|
+
{
|
|
391
|
+
id: 'STORAGE_LANCE_VECTOR_LIST_TABLES_FAILED',
|
|
392
|
+
domain: ErrorDomain.STORAGE,
|
|
393
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
394
|
+
},
|
|
395
|
+
error,
|
|
396
|
+
);
|
|
314
397
|
}
|
|
315
|
-
return await this.lanceClient.tableNames();
|
|
316
398
|
}
|
|
317
399
|
|
|
318
400
|
async getTableSchema(tableName: string): Promise<any> {
|
|
319
401
|
if (!this.lanceClient) {
|
|
320
|
-
throw new
|
|
402
|
+
throw new MastraError({
|
|
403
|
+
id: 'STORAGE_LANCE_VECTOR_GET_TABLE_SCHEMA_FAILED_INVALID_ARGS',
|
|
404
|
+
domain: ErrorDomain.STORAGE,
|
|
405
|
+
category: ErrorCategory.USER,
|
|
406
|
+
text: 'LanceDB client not initialized. Use LanceVectorStore.create() to create an instance',
|
|
407
|
+
details: { tableName },
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
try {
|
|
412
|
+
const table = await this.lanceClient.openTable(tableName);
|
|
413
|
+
return await table.schema();
|
|
414
|
+
} catch (error) {
|
|
415
|
+
throw new MastraError(
|
|
416
|
+
{
|
|
417
|
+
id: 'STORAGE_LANCE_VECTOR_GET_TABLE_SCHEMA_FAILED',
|
|
418
|
+
domain: ErrorDomain.STORAGE,
|
|
419
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
420
|
+
details: { tableName },
|
|
421
|
+
},
|
|
422
|
+
error,
|
|
423
|
+
);
|
|
321
424
|
}
|
|
322
|
-
const table = await this.lanceClient.openTable(tableName);
|
|
323
|
-
return await table.schema();
|
|
324
425
|
}
|
|
325
426
|
|
|
326
427
|
/**
|
|
@@ -333,11 +434,11 @@ export class LanceVectorStore extends MastraVector {
|
|
|
333
434
|
metric = 'cosine',
|
|
334
435
|
indexConfig = {},
|
|
335
436
|
}: LanceCreateIndexParams): Promise<void> {
|
|
336
|
-
if (!this.lanceClient) {
|
|
337
|
-
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
338
|
-
}
|
|
339
|
-
|
|
340
437
|
try {
|
|
438
|
+
if (!this.lanceClient) {
|
|
439
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
440
|
+
}
|
|
441
|
+
|
|
341
442
|
if (!tableName) {
|
|
342
443
|
throw new Error('tableName is required');
|
|
343
444
|
}
|
|
@@ -349,7 +450,19 @@ export class LanceVectorStore extends MastraVector {
|
|
|
349
450
|
if (typeof dimension !== 'number' || dimension <= 0) {
|
|
350
451
|
throw new Error('dimension must be a positive number');
|
|
351
452
|
}
|
|
453
|
+
} catch (err) {
|
|
454
|
+
throw new MastraError(
|
|
455
|
+
{
|
|
456
|
+
id: 'STORAGE_LANCE_VECTOR_CREATE_INDEX_FAILED_INVALID_ARGS',
|
|
457
|
+
domain: ErrorDomain.STORAGE,
|
|
458
|
+
category: ErrorCategory.USER,
|
|
459
|
+
details: { tableName: tableName || '', indexName, dimension, metric },
|
|
460
|
+
},
|
|
461
|
+
err,
|
|
462
|
+
);
|
|
463
|
+
}
|
|
352
464
|
|
|
465
|
+
try {
|
|
353
466
|
const tables = await this.lanceClient.tableNames();
|
|
354
467
|
if (!tables.includes(tableName)) {
|
|
355
468
|
throw new Error(
|
|
@@ -390,13 +503,27 @@ export class LanceVectorStore extends MastraVector {
|
|
|
390
503
|
});
|
|
391
504
|
}
|
|
392
505
|
} catch (error: any) {
|
|
393
|
-
throw new
|
|
506
|
+
throw new MastraError(
|
|
507
|
+
{
|
|
508
|
+
id: 'STORAGE_LANCE_VECTOR_CREATE_INDEX_FAILED',
|
|
509
|
+
domain: ErrorDomain.STORAGE,
|
|
510
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
511
|
+
details: { tableName: tableName || '', indexName, dimension },
|
|
512
|
+
},
|
|
513
|
+
error,
|
|
514
|
+
);
|
|
394
515
|
}
|
|
395
516
|
}
|
|
396
517
|
|
|
397
518
|
async listIndexes(): Promise<string[]> {
|
|
398
519
|
if (!this.lanceClient) {
|
|
399
|
-
throw new
|
|
520
|
+
throw new MastraError({
|
|
521
|
+
id: 'STORAGE_LANCE_VECTOR_LIST_INDEXES_FAILED_INVALID_ARGS',
|
|
522
|
+
domain: ErrorDomain.STORAGE,
|
|
523
|
+
category: ErrorCategory.USER,
|
|
524
|
+
text: 'LanceDB client not initialized. Use LanceVectorStore.create() to create an instance',
|
|
525
|
+
details: { methodName: 'listIndexes' },
|
|
526
|
+
});
|
|
400
527
|
}
|
|
401
528
|
|
|
402
529
|
try {
|
|
@@ -411,17 +538,36 @@ export class LanceVectorStore extends MastraVector {
|
|
|
411
538
|
|
|
412
539
|
return allIndices;
|
|
413
540
|
} catch (error: any) {
|
|
414
|
-
throw new
|
|
541
|
+
throw new MastraError(
|
|
542
|
+
{
|
|
543
|
+
id: 'STORAGE_LANCE_VECTOR_LIST_INDEXES_FAILED',
|
|
544
|
+
domain: ErrorDomain.STORAGE,
|
|
545
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
546
|
+
},
|
|
547
|
+
error,
|
|
548
|
+
);
|
|
415
549
|
}
|
|
416
550
|
}
|
|
417
551
|
|
|
418
552
|
async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
553
|
+
try {
|
|
554
|
+
if (!this.lanceClient) {
|
|
555
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
556
|
+
}
|
|
422
557
|
|
|
423
|
-
|
|
424
|
-
|
|
558
|
+
if (!indexName) {
|
|
559
|
+
throw new Error('indexName is required');
|
|
560
|
+
}
|
|
561
|
+
} catch (err) {
|
|
562
|
+
throw new MastraError(
|
|
563
|
+
{
|
|
564
|
+
id: 'STORAGE_LANCE_VECTOR_DESCRIBE_INDEX_FAILED_INVALID_ARGS',
|
|
565
|
+
domain: ErrorDomain.STORAGE,
|
|
566
|
+
category: ErrorCategory.USER,
|
|
567
|
+
details: { indexName },
|
|
568
|
+
},
|
|
569
|
+
err,
|
|
570
|
+
);
|
|
425
571
|
}
|
|
426
572
|
|
|
427
573
|
try {
|
|
@@ -457,19 +603,38 @@ export class LanceVectorStore extends MastraVector {
|
|
|
457
603
|
|
|
458
604
|
throw new Error(`IndexName: ${indexName} not found`);
|
|
459
605
|
} catch (error: any) {
|
|
460
|
-
throw new
|
|
606
|
+
throw new MastraError(
|
|
607
|
+
{
|
|
608
|
+
id: 'STORAGE_LANCE_VECTOR_DESCRIBE_INDEX_FAILED',
|
|
609
|
+
domain: ErrorDomain.STORAGE,
|
|
610
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
611
|
+
details: { indexName },
|
|
612
|
+
},
|
|
613
|
+
error,
|
|
614
|
+
);
|
|
461
615
|
}
|
|
462
616
|
}
|
|
463
617
|
|
|
464
618
|
async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
619
|
+
try {
|
|
620
|
+
if (!this.lanceClient) {
|
|
621
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
622
|
+
}
|
|
468
623
|
|
|
469
|
-
|
|
470
|
-
|
|
624
|
+
if (!indexName) {
|
|
625
|
+
throw new Error('indexName is required');
|
|
626
|
+
}
|
|
627
|
+
} catch (err) {
|
|
628
|
+
throw new MastraError(
|
|
629
|
+
{
|
|
630
|
+
id: 'STORAGE_LANCE_VECTOR_DELETE_INDEX_FAILED_INVALID_ARGS',
|
|
631
|
+
domain: ErrorDomain.STORAGE,
|
|
632
|
+
category: ErrorCategory.USER,
|
|
633
|
+
details: { indexName },
|
|
634
|
+
},
|
|
635
|
+
err,
|
|
636
|
+
);
|
|
471
637
|
}
|
|
472
|
-
|
|
473
638
|
try {
|
|
474
639
|
const tables = await this.lanceClient.tableNames();
|
|
475
640
|
|
|
@@ -486,7 +651,15 @@ export class LanceVectorStore extends MastraVector {
|
|
|
486
651
|
|
|
487
652
|
throw new Error(`Index ${indexName} not found`);
|
|
488
653
|
} catch (error: any) {
|
|
489
|
-
throw new
|
|
654
|
+
throw new MastraError(
|
|
655
|
+
{
|
|
656
|
+
id: 'STORAGE_LANCE_VECTOR_DELETE_INDEX_FAILED',
|
|
657
|
+
domain: ErrorDomain.STORAGE,
|
|
658
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
659
|
+
details: { indexName },
|
|
660
|
+
},
|
|
661
|
+
error,
|
|
662
|
+
);
|
|
490
663
|
}
|
|
491
664
|
}
|
|
492
665
|
|
|
@@ -495,39 +668,79 @@ export class LanceVectorStore extends MastraVector {
|
|
|
495
668
|
*/
|
|
496
669
|
async deleteAllTables(): Promise<void> {
|
|
497
670
|
if (!this.lanceClient) {
|
|
498
|
-
throw new
|
|
671
|
+
throw new MastraError({
|
|
672
|
+
id: 'STORAGE_LANCE_VECTOR_DELETE_ALL_TABLES_FAILED_INVALID_ARGS',
|
|
673
|
+
domain: ErrorDomain.STORAGE,
|
|
674
|
+
category: ErrorCategory.USER,
|
|
675
|
+
details: { methodName: 'deleteAllTables' },
|
|
676
|
+
text: 'LanceDB client not initialized. Use LanceVectorStore.create() to create an instance',
|
|
677
|
+
});
|
|
499
678
|
}
|
|
500
|
-
|
|
501
679
|
try {
|
|
502
680
|
await this.lanceClient.dropAllTables();
|
|
503
|
-
} catch (error
|
|
504
|
-
throw new
|
|
681
|
+
} catch (error) {
|
|
682
|
+
throw new MastraError(
|
|
683
|
+
{
|
|
684
|
+
id: 'STORAGE_LANCE_VECTOR_DELETE_ALL_TABLES_FAILED',
|
|
685
|
+
domain: ErrorDomain.STORAGE,
|
|
686
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
687
|
+
details: { methodName: 'deleteAllTables' },
|
|
688
|
+
},
|
|
689
|
+
error,
|
|
690
|
+
);
|
|
505
691
|
}
|
|
506
692
|
}
|
|
507
693
|
|
|
508
694
|
async deleteTable(tableName: string): Promise<void> {
|
|
509
695
|
if (!this.lanceClient) {
|
|
510
|
-
throw new
|
|
696
|
+
throw new MastraError({
|
|
697
|
+
id: 'STORAGE_LANCE_VECTOR_DELETE_TABLE_FAILED_INVALID_ARGS',
|
|
698
|
+
domain: ErrorDomain.STORAGE,
|
|
699
|
+
category: ErrorCategory.USER,
|
|
700
|
+
details: { tableName },
|
|
701
|
+
text: 'LanceDB client not initialized. Use LanceVectorStore.create() to create an instance',
|
|
702
|
+
});
|
|
511
703
|
}
|
|
512
704
|
|
|
513
705
|
try {
|
|
514
706
|
await this.lanceClient.dropTable(tableName);
|
|
515
707
|
} catch (error: any) {
|
|
516
|
-
throw new Error(`Failed to delete tables: ${error.message}`);
|
|
708
|
+
// throw new Error(`Failed to delete tables: ${error.message}`);
|
|
709
|
+
throw new MastraError(
|
|
710
|
+
{
|
|
711
|
+
id: 'STORAGE_LANCE_VECTOR_DELETE_TABLE_FAILED',
|
|
712
|
+
domain: ErrorDomain.STORAGE,
|
|
713
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
714
|
+
details: { tableName },
|
|
715
|
+
},
|
|
716
|
+
error,
|
|
717
|
+
);
|
|
517
718
|
}
|
|
518
719
|
}
|
|
519
720
|
|
|
520
721
|
async updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void> {
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
722
|
+
try {
|
|
723
|
+
if (!this.lanceClient) {
|
|
724
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
725
|
+
}
|
|
524
726
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
727
|
+
if (!indexName) {
|
|
728
|
+
throw new Error('indexName is required');
|
|
729
|
+
}
|
|
528
730
|
|
|
529
|
-
|
|
530
|
-
|
|
731
|
+
if (!id) {
|
|
732
|
+
throw new Error('id is required');
|
|
733
|
+
}
|
|
734
|
+
} catch (err) {
|
|
735
|
+
throw new MastraError(
|
|
736
|
+
{
|
|
737
|
+
id: 'STORAGE_LANCE_VECTOR_UPDATE_VECTOR_FAILED_INVALID_ARGS',
|
|
738
|
+
domain: ErrorDomain.STORAGE,
|
|
739
|
+
category: ErrorCategory.USER,
|
|
740
|
+
details: { indexName, id },
|
|
741
|
+
},
|
|
742
|
+
err,
|
|
743
|
+
);
|
|
531
744
|
}
|
|
532
745
|
|
|
533
746
|
try {
|
|
@@ -612,21 +825,41 @@ export class LanceVectorStore extends MastraVector {
|
|
|
612
825
|
|
|
613
826
|
throw new Error(`No table found with column/index '${indexName}'`);
|
|
614
827
|
} catch (error: any) {
|
|
615
|
-
throw new
|
|
828
|
+
throw new MastraError(
|
|
829
|
+
{
|
|
830
|
+
id: 'STORAGE_LANCE_VECTOR_UPDATE_VECTOR_FAILED',
|
|
831
|
+
domain: ErrorDomain.STORAGE,
|
|
832
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
833
|
+
details: { indexName, id, hasVector: !!update.vector, hasMetadata: !!update.metadata },
|
|
834
|
+
},
|
|
835
|
+
error,
|
|
836
|
+
);
|
|
616
837
|
}
|
|
617
838
|
}
|
|
618
839
|
|
|
619
840
|
async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
841
|
+
try {
|
|
842
|
+
if (!this.lanceClient) {
|
|
843
|
+
throw new Error('LanceDB client not initialized. Use LanceVectorStore.create() to create an instance');
|
|
844
|
+
}
|
|
623
845
|
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
846
|
+
if (!indexName) {
|
|
847
|
+
throw new Error('indexName is required');
|
|
848
|
+
}
|
|
627
849
|
|
|
628
|
-
|
|
629
|
-
|
|
850
|
+
if (!id) {
|
|
851
|
+
throw new Error('id is required');
|
|
852
|
+
}
|
|
853
|
+
} catch (err) {
|
|
854
|
+
throw new MastraError(
|
|
855
|
+
{
|
|
856
|
+
id: 'STORAGE_LANCE_VECTOR_DELETE_VECTOR_FAILED_INVALID_ARGS',
|
|
857
|
+
domain: ErrorDomain.STORAGE,
|
|
858
|
+
category: ErrorCategory.USER,
|
|
859
|
+
details: { indexName, id },
|
|
860
|
+
},
|
|
861
|
+
err,
|
|
862
|
+
);
|
|
630
863
|
}
|
|
631
864
|
|
|
632
865
|
try {
|
|
@@ -657,7 +890,15 @@ export class LanceVectorStore extends MastraVector {
|
|
|
657
890
|
|
|
658
891
|
throw new Error(`No table found with column/index '${indexName}'`);
|
|
659
892
|
} catch (error: any) {
|
|
660
|
-
throw new
|
|
893
|
+
throw new MastraError(
|
|
894
|
+
{
|
|
895
|
+
id: 'STORAGE_LANCE_VECTOR_DELETE_VECTOR_FAILED',
|
|
896
|
+
domain: ErrorDomain.STORAGE,
|
|
897
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
898
|
+
details: { indexName, id },
|
|
899
|
+
},
|
|
900
|
+
error,
|
|
901
|
+
);
|
|
661
902
|
}
|
|
662
903
|
}
|
|
663
904
|
|