@mastra/qdrant 0.2.15-alpha.0 → 0.10.0
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 +50 -0
- package/dist/_tsup-dts-rollup.d.cts +12 -43
- package/dist/_tsup-dts-rollup.d.ts +12 -43
- package/dist/index.cjs +23 -83
- package/dist/index.js +23 -83
- package/package.json +7 -4
- package/src/vector/index.test.ts +0 -97
- package/src/vector/index.ts +20 -105
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/qdrant@0.
|
|
2
|
+
> @mastra/qdrant@0.10.0-alpha.1 build /home/runner/work/mastra/mastra/stores/qdrant
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.4.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 9145ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/qdrant/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/qdrant/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 9864ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
20
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m18.30 KB[39m
|
|
21
|
+
[32mCJS[39m ⚡️ Build success in 601ms
|
|
22
|
+
[32mESM[39m [1mdist/index.js [22m[32m18.24 KB[39m
|
|
23
|
+
[32mESM[39m ⚡️ Build success in 603ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,55 @@
|
|
|
1
1
|
# @mastra/qdrant
|
|
2
2
|
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 83da932: Move @mastra/core to peerdeps
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- d0ee3c6: Change all public functions and constructors in vector stores to use named args and prepare to phase out positional args
|
|
12
|
+
- a7292b0: BREAKING(@mastra/core, all vector stores): Vector store breaking changes (remove deprecated functions and positional arguments)
|
|
13
|
+
- Updated dependencies [b3a3d63]
|
|
14
|
+
- Updated dependencies [344f453]
|
|
15
|
+
- Updated dependencies [0a3ae6d]
|
|
16
|
+
- Updated dependencies [95911be]
|
|
17
|
+
- Updated dependencies [f53a6ac]
|
|
18
|
+
- Updated dependencies [5eb5a99]
|
|
19
|
+
- Updated dependencies [7e632c5]
|
|
20
|
+
- Updated dependencies [1e9fbfa]
|
|
21
|
+
- Updated dependencies [eabdcd9]
|
|
22
|
+
- Updated dependencies [90be034]
|
|
23
|
+
- Updated dependencies [99f050a]
|
|
24
|
+
- Updated dependencies [d0ee3c6]
|
|
25
|
+
- Updated dependencies [b2ae5aa]
|
|
26
|
+
- Updated dependencies [23f258c]
|
|
27
|
+
- Updated dependencies [a7292b0]
|
|
28
|
+
- Updated dependencies [0dcb9f0]
|
|
29
|
+
- Updated dependencies [2672a05]
|
|
30
|
+
- @mastra/core@0.10.0
|
|
31
|
+
|
|
32
|
+
## 0.3.0-alpha.1
|
|
33
|
+
|
|
34
|
+
### Minor Changes
|
|
35
|
+
|
|
36
|
+
- 83da932: Move @mastra/core to peerdeps
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- a7292b0: BREAKING(@mastra/core, all vector stores): Vector store breaking changes (remove deprecated functions and positional arguments)
|
|
41
|
+
- Updated dependencies [b3a3d63]
|
|
42
|
+
- Updated dependencies [344f453]
|
|
43
|
+
- Updated dependencies [0a3ae6d]
|
|
44
|
+
- Updated dependencies [95911be]
|
|
45
|
+
- Updated dependencies [5eb5a99]
|
|
46
|
+
- Updated dependencies [7e632c5]
|
|
47
|
+
- Updated dependencies [1e9fbfa]
|
|
48
|
+
- Updated dependencies [b2ae5aa]
|
|
49
|
+
- Updated dependencies [a7292b0]
|
|
50
|
+
- Updated dependencies [0dcb9f0]
|
|
51
|
+
- @mastra/core@0.10.0-alpha.1
|
|
52
|
+
|
|
3
53
|
## 0.2.15-alpha.0
|
|
4
54
|
|
|
5
55
|
### Patch Changes
|
|
@@ -7,7 +7,6 @@ import type { IndexStats } from '@mastra/core/vector';
|
|
|
7
7
|
import type { LogicalOperator } from '@mastra/core/vector/filter';
|
|
8
8
|
import { MastraVector } from '@mastra/core/vector';
|
|
9
9
|
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
10
|
-
import type { ParamsToArgs } from '@mastra/core/vector';
|
|
11
10
|
import type { QueryResult } from '@mastra/core/vector';
|
|
12
11
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
13
12
|
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
@@ -59,37 +58,31 @@ export declare class QdrantFilterTranslator extends BaseFilterTranslator {
|
|
|
59
58
|
|
|
60
59
|
declare class QdrantVector extends MastraVector {
|
|
61
60
|
private client;
|
|
62
|
-
/**
|
|
63
|
-
* @deprecated Passing url, apiKey, https as positional arguments is deprecated.
|
|
64
|
-
* Use the object parameter instead. This signature will be removed on May 20th, 2025.
|
|
65
|
-
*/
|
|
66
|
-
constructor(url: string, apiKey?: string, https?: boolean);
|
|
67
61
|
/**
|
|
68
62
|
* Creates a new QdrantVector client.
|
|
69
|
-
* @param
|
|
63
|
+
* @param url - The URL of the Qdrant server.
|
|
64
|
+
* @param apiKey - The API key for Qdrant.
|
|
65
|
+
* @param https - Whether to use HTTPS.
|
|
70
66
|
*/
|
|
71
|
-
constructor(
|
|
67
|
+
constructor({ url, apiKey, https }: {
|
|
72
68
|
url: string;
|
|
73
69
|
apiKey?: string;
|
|
74
70
|
https?: boolean;
|
|
75
71
|
});
|
|
76
|
-
upsert(
|
|
77
|
-
createIndex(
|
|
72
|
+
upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
|
|
73
|
+
createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
|
|
78
74
|
transformFilter(filter?: VectorFilter): VectorFilter;
|
|
79
|
-
query(
|
|
75
|
+
query({ indexName, queryVector, topK, filter, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
|
|
80
76
|
listIndexes(): Promise<string[]>;
|
|
81
77
|
/**
|
|
82
78
|
* Retrieves statistics about a vector index.
|
|
83
79
|
*
|
|
84
|
-
* @param
|
|
85
|
-
* @param params.indexName - The name of the index to describe
|
|
80
|
+
* @param {string} indexName - The name of the index to describe
|
|
86
81
|
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
87
82
|
*/
|
|
88
|
-
describeIndex(
|
|
89
|
-
deleteIndex(
|
|
83
|
+
describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
|
|
84
|
+
deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
90
85
|
/**
|
|
91
|
-
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
92
|
-
*
|
|
93
86
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
94
87
|
* @param indexName - The name of the index containing the vector.
|
|
95
88
|
* @param id - The ID of the vector to update.
|
|
@@ -99,31 +92,7 @@ declare class QdrantVector extends MastraVector {
|
|
|
99
92
|
* @returns A promise that resolves when the update is complete.
|
|
100
93
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
101
94
|
*/
|
|
102
|
-
|
|
103
|
-
vector?: number[];
|
|
104
|
-
metadata?: Record<string, any>;
|
|
105
|
-
}): Promise<void>;
|
|
106
|
-
/**
|
|
107
|
-
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
108
|
-
* @param indexName - The name of the index containing the vector.
|
|
109
|
-
* @param id - The ID of the vector to update.
|
|
110
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
111
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
112
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
113
|
-
* @returns A promise that resolves when the update is complete.
|
|
114
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
115
|
-
*/
|
|
116
|
-
updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
|
|
117
|
-
/**
|
|
118
|
-
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
119
|
-
*
|
|
120
|
-
* Deletes a vector by its ID.
|
|
121
|
-
* @param indexName - The name of the index containing the vector.
|
|
122
|
-
* @param id - The ID of the vector to delete.
|
|
123
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
124
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
125
|
-
*/
|
|
126
|
-
deleteIndexById(indexName: string, id: string): Promise<void>;
|
|
95
|
+
updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
|
|
127
96
|
/**
|
|
128
97
|
* Deletes a vector by its ID.
|
|
129
98
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -131,7 +100,7 @@ declare class QdrantVector extends MastraVector {
|
|
|
131
100
|
* @returns A promise that resolves when the deletion is complete.
|
|
132
101
|
* @throws Will throw an error if the deletion operation fails.
|
|
133
102
|
*/
|
|
134
|
-
deleteVector(
|
|
103
|
+
deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
|
|
135
104
|
/**
|
|
136
105
|
* Parses and converts a string ID to the appropriate type (string or number) for Qdrant point operations.
|
|
137
106
|
*
|
|
@@ -7,7 +7,6 @@ import type { IndexStats } from '@mastra/core/vector';
|
|
|
7
7
|
import type { LogicalOperator } from '@mastra/core/vector/filter';
|
|
8
8
|
import { MastraVector } from '@mastra/core/vector';
|
|
9
9
|
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
10
|
-
import type { ParamsToArgs } from '@mastra/core/vector';
|
|
11
10
|
import type { QueryResult } from '@mastra/core/vector';
|
|
12
11
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
13
12
|
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
@@ -59,37 +58,31 @@ export declare class QdrantFilterTranslator extends BaseFilterTranslator {
|
|
|
59
58
|
|
|
60
59
|
declare class QdrantVector extends MastraVector {
|
|
61
60
|
private client;
|
|
62
|
-
/**
|
|
63
|
-
* @deprecated Passing url, apiKey, https as positional arguments is deprecated.
|
|
64
|
-
* Use the object parameter instead. This signature will be removed on May 20th, 2025.
|
|
65
|
-
*/
|
|
66
|
-
constructor(url: string, apiKey?: string, https?: boolean);
|
|
67
61
|
/**
|
|
68
62
|
* Creates a new QdrantVector client.
|
|
69
|
-
* @param
|
|
63
|
+
* @param url - The URL of the Qdrant server.
|
|
64
|
+
* @param apiKey - The API key for Qdrant.
|
|
65
|
+
* @param https - Whether to use HTTPS.
|
|
70
66
|
*/
|
|
71
|
-
constructor(
|
|
67
|
+
constructor({ url, apiKey, https }: {
|
|
72
68
|
url: string;
|
|
73
69
|
apiKey?: string;
|
|
74
70
|
https?: boolean;
|
|
75
71
|
});
|
|
76
|
-
upsert(
|
|
77
|
-
createIndex(
|
|
72
|
+
upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
|
|
73
|
+
createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
|
|
78
74
|
transformFilter(filter?: VectorFilter): VectorFilter;
|
|
79
|
-
query(
|
|
75
|
+
query({ indexName, queryVector, topK, filter, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
|
|
80
76
|
listIndexes(): Promise<string[]>;
|
|
81
77
|
/**
|
|
82
78
|
* Retrieves statistics about a vector index.
|
|
83
79
|
*
|
|
84
|
-
* @param
|
|
85
|
-
* @param params.indexName - The name of the index to describe
|
|
80
|
+
* @param {string} indexName - The name of the index to describe
|
|
86
81
|
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
87
82
|
*/
|
|
88
|
-
describeIndex(
|
|
89
|
-
deleteIndex(
|
|
83
|
+
describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
|
|
84
|
+
deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
90
85
|
/**
|
|
91
|
-
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
92
|
-
*
|
|
93
86
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
94
87
|
* @param indexName - The name of the index containing the vector.
|
|
95
88
|
* @param id - The ID of the vector to update.
|
|
@@ -99,31 +92,7 @@ declare class QdrantVector extends MastraVector {
|
|
|
99
92
|
* @returns A promise that resolves when the update is complete.
|
|
100
93
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
101
94
|
*/
|
|
102
|
-
|
|
103
|
-
vector?: number[];
|
|
104
|
-
metadata?: Record<string, any>;
|
|
105
|
-
}): Promise<void>;
|
|
106
|
-
/**
|
|
107
|
-
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
108
|
-
* @param indexName - The name of the index containing the vector.
|
|
109
|
-
* @param id - The ID of the vector to update.
|
|
110
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
111
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
112
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
113
|
-
* @returns A promise that resolves when the update is complete.
|
|
114
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
115
|
-
*/
|
|
116
|
-
updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
|
|
117
|
-
/**
|
|
118
|
-
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
119
|
-
*
|
|
120
|
-
* Deletes a vector by its ID.
|
|
121
|
-
* @param indexName - The name of the index containing the vector.
|
|
122
|
-
* @param id - The ID of the vector to delete.
|
|
123
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
124
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
125
|
-
*/
|
|
126
|
-
deleteIndexById(indexName: string, id: string): Promise<void>;
|
|
95
|
+
updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
|
|
127
96
|
/**
|
|
128
97
|
* Deletes a vector by its ID.
|
|
129
98
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -131,7 +100,7 @@ declare class QdrantVector extends MastraVector {
|
|
|
131
100
|
* @returns A promise that resolves when the deletion is complete.
|
|
132
101
|
* @throws Will throw an error if the deletion operation fails.
|
|
133
102
|
*/
|
|
134
|
-
deleteVector(
|
|
103
|
+
deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
|
|
135
104
|
/**
|
|
136
105
|
* Parses and converts a string ID to the appropriate type (string or number) for Qdrant point operations.
|
|
137
106
|
*
|
package/dist/index.cjs
CHANGED
|
@@ -239,32 +239,18 @@ var DISTANCE_MAPPING = {
|
|
|
239
239
|
};
|
|
240
240
|
var QdrantVector = class extends vector.MastraVector {
|
|
241
241
|
client;
|
|
242
|
-
|
|
242
|
+
/**
|
|
243
|
+
* Creates a new QdrantVector client.
|
|
244
|
+
* @param url - The URL of the Qdrant server.
|
|
245
|
+
* @param apiKey - The API key for Qdrant.
|
|
246
|
+
* @param https - Whether to use HTTPS.
|
|
247
|
+
*/
|
|
248
|
+
constructor({ url, apiKey, https }) {
|
|
243
249
|
super();
|
|
244
|
-
let url;
|
|
245
|
-
let key;
|
|
246
|
-
let secure;
|
|
247
|
-
if (typeof paramsOrUrl === "string") {
|
|
248
|
-
if (typeof console !== "undefined" && console.warn) {
|
|
249
|
-
console.warn(
|
|
250
|
-
`Deprecation Warning: Passing url, apiKey, https as positional arguments to QdrantVector constructor is deprecated.
|
|
251
|
-
Please use an object parameter instead:
|
|
252
|
-
new QdrantVector({ url, apiKey, https })
|
|
253
|
-
This signature will be removed on May 20th, 2025.`
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
|
-
url = paramsOrUrl;
|
|
257
|
-
key = apiKey;
|
|
258
|
-
secure = https;
|
|
259
|
-
} else {
|
|
260
|
-
url = paramsOrUrl.url;
|
|
261
|
-
key = paramsOrUrl.apiKey;
|
|
262
|
-
secure = paramsOrUrl.https;
|
|
263
|
-
}
|
|
264
250
|
const baseClient = new jsClientRest.QdrantClient({
|
|
265
251
|
url,
|
|
266
|
-
apiKey
|
|
267
|
-
https
|
|
252
|
+
apiKey,
|
|
253
|
+
https
|
|
268
254
|
});
|
|
269
255
|
const telemetry = this.__getTelemetry();
|
|
270
256
|
this.client = telemetry?.traceClass(baseClient, {
|
|
@@ -274,9 +260,7 @@ This signature will be removed on May 20th, 2025.`
|
|
|
274
260
|
}
|
|
275
261
|
}) ?? baseClient;
|
|
276
262
|
}
|
|
277
|
-
async upsert(
|
|
278
|
-
const params = this.normalizeArgs("upsert", args);
|
|
279
|
-
const { indexName, vectors, metadata, ids } = params;
|
|
263
|
+
async upsert({ indexName, vectors, metadata, ids }) {
|
|
280
264
|
const pointIds = ids || vectors.map(() => crypto.randomUUID());
|
|
281
265
|
const records = vectors.map((vector, i) => ({
|
|
282
266
|
id: pointIds[i],
|
|
@@ -293,9 +277,7 @@ This signature will be removed on May 20th, 2025.`
|
|
|
293
277
|
}
|
|
294
278
|
return pointIds;
|
|
295
279
|
}
|
|
296
|
-
async createIndex(
|
|
297
|
-
const params = this.normalizeArgs("createIndex", args);
|
|
298
|
-
const { indexName, dimension, metric = "cosine" } = params;
|
|
280
|
+
async createIndex({ indexName, dimension, metric = "cosine" }) {
|
|
299
281
|
if (!Number.isInteger(dimension) || dimension <= 0) {
|
|
300
282
|
throw new Error("Dimension must be a positive integer");
|
|
301
283
|
}
|
|
@@ -321,9 +303,13 @@ This signature will be removed on May 20th, 2025.`
|
|
|
321
303
|
const translator = new QdrantFilterTranslator();
|
|
322
304
|
return translator.translate(filter);
|
|
323
305
|
}
|
|
324
|
-
async query(
|
|
325
|
-
|
|
326
|
-
|
|
306
|
+
async query({
|
|
307
|
+
indexName,
|
|
308
|
+
queryVector,
|
|
309
|
+
topK = 10,
|
|
310
|
+
filter,
|
|
311
|
+
includeVector = false
|
|
312
|
+
}) {
|
|
327
313
|
const translatedFilter = this.transformFilter(filter) ?? {};
|
|
328
314
|
const results = (await this.client.query(indexName, {
|
|
329
315
|
query: queryVector,
|
|
@@ -356,13 +342,10 @@ This signature will be removed on May 20th, 2025.`
|
|
|
356
342
|
/**
|
|
357
343
|
* Retrieves statistics about a vector index.
|
|
358
344
|
*
|
|
359
|
-
* @param
|
|
360
|
-
* @param params.indexName - The name of the index to describe
|
|
345
|
+
* @param {string} indexName - The name of the index to describe
|
|
361
346
|
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
362
347
|
*/
|
|
363
|
-
async describeIndex(
|
|
364
|
-
const params = this.normalizeArgs("describeIndex", args);
|
|
365
|
-
const { indexName } = params;
|
|
348
|
+
async describeIndex({ indexName }) {
|
|
366
349
|
const { config, points_count } = await this.client.getCollection(indexName);
|
|
367
350
|
const distance = config.params.vectors?.distance;
|
|
368
351
|
return {
|
|
@@ -372,14 +355,10 @@ This signature will be removed on May 20th, 2025.`
|
|
|
372
355
|
metric: Object.keys(DISTANCE_MAPPING).find((key) => DISTANCE_MAPPING[key] === distance)
|
|
373
356
|
};
|
|
374
357
|
}
|
|
375
|
-
async deleteIndex(
|
|
376
|
-
const params = this.normalizeArgs("deleteIndex", args);
|
|
377
|
-
const { indexName } = params;
|
|
358
|
+
async deleteIndex({ indexName }) {
|
|
378
359
|
await this.client.deleteCollection(indexName);
|
|
379
360
|
}
|
|
380
361
|
/**
|
|
381
|
-
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
382
|
-
*
|
|
383
362
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
384
363
|
* @param indexName - The name of the index containing the vector.
|
|
385
364
|
* @param id - The ID of the vector to update.
|
|
@@ -389,27 +368,7 @@ This signature will be removed on May 20th, 2025.`
|
|
|
389
368
|
* @returns A promise that resolves when the update is complete.
|
|
390
369
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
391
370
|
*/
|
|
392
|
-
async
|
|
393
|
-
this.logger.warn(
|
|
394
|
-
`Deprecation Warning: updateIndexById() is deprecated.
|
|
395
|
-
Please use updateVector() instead.
|
|
396
|
-
updateIndexById() will be removed on May 20th, 2025.`
|
|
397
|
-
);
|
|
398
|
-
await this.updateVector({ indexName, id, update });
|
|
399
|
-
}
|
|
400
|
-
/**
|
|
401
|
-
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
402
|
-
* @param indexName - The name of the index containing the vector.
|
|
403
|
-
* @param id - The ID of the vector to update.
|
|
404
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
405
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
406
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
407
|
-
* @returns A promise that resolves when the update is complete.
|
|
408
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
409
|
-
*/
|
|
410
|
-
async updateVector(...args) {
|
|
411
|
-
const params = this.normalizeArgs("updateVector", args);
|
|
412
|
-
const { indexName, id, update } = params;
|
|
371
|
+
async updateVector({ indexName, id, update }) {
|
|
413
372
|
if (!update.vector && !update.metadata) {
|
|
414
373
|
throw new Error("No updates provided");
|
|
415
374
|
}
|
|
@@ -446,23 +405,6 @@ This signature will be removed on May 20th, 2025.`
|
|
|
446
405
|
throw error;
|
|
447
406
|
}
|
|
448
407
|
}
|
|
449
|
-
/**
|
|
450
|
-
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
451
|
-
*
|
|
452
|
-
* Deletes a vector by its ID.
|
|
453
|
-
* @param indexName - The name of the index containing the vector.
|
|
454
|
-
* @param id - The ID of the vector to delete.
|
|
455
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
456
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
457
|
-
*/
|
|
458
|
-
async deleteIndexById(indexName, id) {
|
|
459
|
-
this.logger.warn(
|
|
460
|
-
`Deprecation Warning: deleteIndexById() is deprecated.
|
|
461
|
-
Please use deleteVector() instead.
|
|
462
|
-
deleteIndexById() will be removed on May 20th, 2025.`
|
|
463
|
-
);
|
|
464
|
-
await this.deleteVector({ indexName, id });
|
|
465
|
-
}
|
|
466
408
|
/**
|
|
467
409
|
* Deletes a vector by its ID.
|
|
468
410
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -470,9 +412,7 @@ This signature will be removed on May 20th, 2025.`
|
|
|
470
412
|
* @returns A promise that resolves when the deletion is complete.
|
|
471
413
|
* @throws Will throw an error if the deletion operation fails.
|
|
472
414
|
*/
|
|
473
|
-
async deleteVector(
|
|
474
|
-
const params = this.normalizeArgs("deleteVector", args);
|
|
475
|
-
const { indexName, id } = params;
|
|
415
|
+
async deleteVector({ indexName, id }) {
|
|
476
416
|
try {
|
|
477
417
|
const pointId = this.parsePointId(id);
|
|
478
418
|
await this.client.delete(indexName, {
|
package/dist/index.js
CHANGED
|
@@ -237,32 +237,18 @@ var DISTANCE_MAPPING = {
|
|
|
237
237
|
};
|
|
238
238
|
var QdrantVector = class extends MastraVector {
|
|
239
239
|
client;
|
|
240
|
-
|
|
240
|
+
/**
|
|
241
|
+
* Creates a new QdrantVector client.
|
|
242
|
+
* @param url - The URL of the Qdrant server.
|
|
243
|
+
* @param apiKey - The API key for Qdrant.
|
|
244
|
+
* @param https - Whether to use HTTPS.
|
|
245
|
+
*/
|
|
246
|
+
constructor({ url, apiKey, https }) {
|
|
241
247
|
super();
|
|
242
|
-
let url;
|
|
243
|
-
let key;
|
|
244
|
-
let secure;
|
|
245
|
-
if (typeof paramsOrUrl === "string") {
|
|
246
|
-
if (typeof console !== "undefined" && console.warn) {
|
|
247
|
-
console.warn(
|
|
248
|
-
`Deprecation Warning: Passing url, apiKey, https as positional arguments to QdrantVector constructor is deprecated.
|
|
249
|
-
Please use an object parameter instead:
|
|
250
|
-
new QdrantVector({ url, apiKey, https })
|
|
251
|
-
This signature will be removed on May 20th, 2025.`
|
|
252
|
-
);
|
|
253
|
-
}
|
|
254
|
-
url = paramsOrUrl;
|
|
255
|
-
key = apiKey;
|
|
256
|
-
secure = https;
|
|
257
|
-
} else {
|
|
258
|
-
url = paramsOrUrl.url;
|
|
259
|
-
key = paramsOrUrl.apiKey;
|
|
260
|
-
secure = paramsOrUrl.https;
|
|
261
|
-
}
|
|
262
248
|
const baseClient = new QdrantClient({
|
|
263
249
|
url,
|
|
264
|
-
apiKey
|
|
265
|
-
https
|
|
250
|
+
apiKey,
|
|
251
|
+
https
|
|
266
252
|
});
|
|
267
253
|
const telemetry = this.__getTelemetry();
|
|
268
254
|
this.client = telemetry?.traceClass(baseClient, {
|
|
@@ -272,9 +258,7 @@ This signature will be removed on May 20th, 2025.`
|
|
|
272
258
|
}
|
|
273
259
|
}) ?? baseClient;
|
|
274
260
|
}
|
|
275
|
-
async upsert(
|
|
276
|
-
const params = this.normalizeArgs("upsert", args);
|
|
277
|
-
const { indexName, vectors, metadata, ids } = params;
|
|
261
|
+
async upsert({ indexName, vectors, metadata, ids }) {
|
|
278
262
|
const pointIds = ids || vectors.map(() => crypto.randomUUID());
|
|
279
263
|
const records = vectors.map((vector, i) => ({
|
|
280
264
|
id: pointIds[i],
|
|
@@ -291,9 +275,7 @@ This signature will be removed on May 20th, 2025.`
|
|
|
291
275
|
}
|
|
292
276
|
return pointIds;
|
|
293
277
|
}
|
|
294
|
-
async createIndex(
|
|
295
|
-
const params = this.normalizeArgs("createIndex", args);
|
|
296
|
-
const { indexName, dimension, metric = "cosine" } = params;
|
|
278
|
+
async createIndex({ indexName, dimension, metric = "cosine" }) {
|
|
297
279
|
if (!Number.isInteger(dimension) || dimension <= 0) {
|
|
298
280
|
throw new Error("Dimension must be a positive integer");
|
|
299
281
|
}
|
|
@@ -319,9 +301,13 @@ This signature will be removed on May 20th, 2025.`
|
|
|
319
301
|
const translator = new QdrantFilterTranslator();
|
|
320
302
|
return translator.translate(filter);
|
|
321
303
|
}
|
|
322
|
-
async query(
|
|
323
|
-
|
|
324
|
-
|
|
304
|
+
async query({
|
|
305
|
+
indexName,
|
|
306
|
+
queryVector,
|
|
307
|
+
topK = 10,
|
|
308
|
+
filter,
|
|
309
|
+
includeVector = false
|
|
310
|
+
}) {
|
|
325
311
|
const translatedFilter = this.transformFilter(filter) ?? {};
|
|
326
312
|
const results = (await this.client.query(indexName, {
|
|
327
313
|
query: queryVector,
|
|
@@ -354,13 +340,10 @@ This signature will be removed on May 20th, 2025.`
|
|
|
354
340
|
/**
|
|
355
341
|
* Retrieves statistics about a vector index.
|
|
356
342
|
*
|
|
357
|
-
* @param
|
|
358
|
-
* @param params.indexName - The name of the index to describe
|
|
343
|
+
* @param {string} indexName - The name of the index to describe
|
|
359
344
|
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
360
345
|
*/
|
|
361
|
-
async describeIndex(
|
|
362
|
-
const params = this.normalizeArgs("describeIndex", args);
|
|
363
|
-
const { indexName } = params;
|
|
346
|
+
async describeIndex({ indexName }) {
|
|
364
347
|
const { config, points_count } = await this.client.getCollection(indexName);
|
|
365
348
|
const distance = config.params.vectors?.distance;
|
|
366
349
|
return {
|
|
@@ -370,14 +353,10 @@ This signature will be removed on May 20th, 2025.`
|
|
|
370
353
|
metric: Object.keys(DISTANCE_MAPPING).find((key) => DISTANCE_MAPPING[key] === distance)
|
|
371
354
|
};
|
|
372
355
|
}
|
|
373
|
-
async deleteIndex(
|
|
374
|
-
const params = this.normalizeArgs("deleteIndex", args);
|
|
375
|
-
const { indexName } = params;
|
|
356
|
+
async deleteIndex({ indexName }) {
|
|
376
357
|
await this.client.deleteCollection(indexName);
|
|
377
358
|
}
|
|
378
359
|
/**
|
|
379
|
-
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
380
|
-
*
|
|
381
360
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
382
361
|
* @param indexName - The name of the index containing the vector.
|
|
383
362
|
* @param id - The ID of the vector to update.
|
|
@@ -387,27 +366,7 @@ This signature will be removed on May 20th, 2025.`
|
|
|
387
366
|
* @returns A promise that resolves when the update is complete.
|
|
388
367
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
389
368
|
*/
|
|
390
|
-
async
|
|
391
|
-
this.logger.warn(
|
|
392
|
-
`Deprecation Warning: updateIndexById() is deprecated.
|
|
393
|
-
Please use updateVector() instead.
|
|
394
|
-
updateIndexById() will be removed on May 20th, 2025.`
|
|
395
|
-
);
|
|
396
|
-
await this.updateVector({ indexName, id, update });
|
|
397
|
-
}
|
|
398
|
-
/**
|
|
399
|
-
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
400
|
-
* @param indexName - The name of the index containing the vector.
|
|
401
|
-
* @param id - The ID of the vector to update.
|
|
402
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
403
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
404
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
405
|
-
* @returns A promise that resolves when the update is complete.
|
|
406
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
407
|
-
*/
|
|
408
|
-
async updateVector(...args) {
|
|
409
|
-
const params = this.normalizeArgs("updateVector", args);
|
|
410
|
-
const { indexName, id, update } = params;
|
|
369
|
+
async updateVector({ indexName, id, update }) {
|
|
411
370
|
if (!update.vector && !update.metadata) {
|
|
412
371
|
throw new Error("No updates provided");
|
|
413
372
|
}
|
|
@@ -444,23 +403,6 @@ This signature will be removed on May 20th, 2025.`
|
|
|
444
403
|
throw error;
|
|
445
404
|
}
|
|
446
405
|
}
|
|
447
|
-
/**
|
|
448
|
-
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
449
|
-
*
|
|
450
|
-
* Deletes a vector by its ID.
|
|
451
|
-
* @param indexName - The name of the index containing the vector.
|
|
452
|
-
* @param id - The ID of the vector to delete.
|
|
453
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
454
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
455
|
-
*/
|
|
456
|
-
async deleteIndexById(indexName, id) {
|
|
457
|
-
this.logger.warn(
|
|
458
|
-
`Deprecation Warning: deleteIndexById() is deprecated.
|
|
459
|
-
Please use deleteVector() instead.
|
|
460
|
-
deleteIndexById() will be removed on May 20th, 2025.`
|
|
461
|
-
);
|
|
462
|
-
await this.deleteVector({ indexName, id });
|
|
463
|
-
}
|
|
464
406
|
/**
|
|
465
407
|
* Deletes a vector by its ID.
|
|
466
408
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -468,9 +410,7 @@ This signature will be removed on May 20th, 2025.`
|
|
|
468
410
|
* @returns A promise that resolves when the deletion is complete.
|
|
469
411
|
* @throws Will throw an error if the deletion operation fails.
|
|
470
412
|
*/
|
|
471
|
-
async deleteVector(
|
|
472
|
-
const params = this.normalizeArgs("deleteVector", args);
|
|
473
|
-
const { indexName, id } = params;
|
|
413
|
+
async deleteVector({ indexName, id }) {
|
|
474
414
|
try {
|
|
475
415
|
const pointId = this.parsePointId(id);
|
|
476
416
|
await this.client.delete(indexName, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/qdrant",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Qdrant vector store provider for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@qdrant/js-client-rest": "^1.13.0"
|
|
24
|
-
"@mastra/core": "^0.9.5-alpha.0"
|
|
23
|
+
"@qdrant/js-client-rest": "^1.13.0"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
|
27
26
|
"@microsoft/api-extractor": "^7.52.5",
|
|
@@ -30,7 +29,11 @@
|
|
|
30
29
|
"tsup": "^8.4.0",
|
|
31
30
|
"typescript": "^5.8.2",
|
|
32
31
|
"vitest": "^3.1.2",
|
|
33
|
-
"@internal/lint": "0.0.
|
|
32
|
+
"@internal/lint": "0.0.6",
|
|
33
|
+
"@mastra/core": "0.10.0"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@mastra/core": "^0.10.0"
|
|
34
37
|
},
|
|
35
38
|
"scripts": {
|
|
36
39
|
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|
package/src/vector/index.test.ts
CHANGED
|
@@ -949,101 +949,4 @@ describe('QdrantVector', () => {
|
|
|
949
949
|
console.log(`${numQueries} concurrent queries took ${duration}ms`);
|
|
950
950
|
}, 50000);
|
|
951
951
|
});
|
|
952
|
-
describe('Deprecation Warnings', () => {
|
|
953
|
-
const indexName = 'testdeprecationwarnings';
|
|
954
|
-
|
|
955
|
-
const indexName2 = 'testdeprecationwarnings2';
|
|
956
|
-
|
|
957
|
-
let warnSpy;
|
|
958
|
-
|
|
959
|
-
beforeAll(async () => {
|
|
960
|
-
await qdrant.createIndex({ indexName, dimension: 3 });
|
|
961
|
-
});
|
|
962
|
-
|
|
963
|
-
afterAll(async () => {
|
|
964
|
-
await qdrant.deleteIndex({ indexName });
|
|
965
|
-
await qdrant.deleteIndex({ indexName: indexName2 });
|
|
966
|
-
});
|
|
967
|
-
|
|
968
|
-
beforeEach(async () => {
|
|
969
|
-
warnSpy = vi.spyOn(qdrant['logger'], 'warn');
|
|
970
|
-
});
|
|
971
|
-
|
|
972
|
-
afterEach(async () => {
|
|
973
|
-
warnSpy.mockRestore();
|
|
974
|
-
await qdrant.deleteIndex({ indexName: indexName2 });
|
|
975
|
-
});
|
|
976
|
-
|
|
977
|
-
it('should show deprecation warning when using individual args for createIndex', async () => {
|
|
978
|
-
await qdrant.createIndex(indexName2, 3, 'cosine');
|
|
979
|
-
|
|
980
|
-
expect(warnSpy).toHaveBeenCalledWith(
|
|
981
|
-
expect.stringContaining('Deprecation Warning: Passing individual arguments to createIndex() is deprecated'),
|
|
982
|
-
);
|
|
983
|
-
});
|
|
984
|
-
|
|
985
|
-
it('should show deprecation warning when using individual args for upsert', async () => {
|
|
986
|
-
await qdrant.upsert(indexName, [[1, 2, 3]], [{ test: 'data' }]);
|
|
987
|
-
|
|
988
|
-
expect(warnSpy).toHaveBeenCalledWith(
|
|
989
|
-
expect.stringContaining('Deprecation Warning: Passing individual arguments to upsert() is deprecated'),
|
|
990
|
-
);
|
|
991
|
-
});
|
|
992
|
-
|
|
993
|
-
it('should show deprecation warning when using individual args for query', async () => {
|
|
994
|
-
await qdrant.query(indexName, [1, 2, 3], 5);
|
|
995
|
-
|
|
996
|
-
expect(warnSpy).toHaveBeenCalledWith(
|
|
997
|
-
expect.stringContaining('Deprecation Warning: Passing individual arguments to query() is deprecated'),
|
|
998
|
-
);
|
|
999
|
-
});
|
|
1000
|
-
|
|
1001
|
-
it('should not show deprecation warning when using object param for query', async () => {
|
|
1002
|
-
await qdrant.query({
|
|
1003
|
-
indexName,
|
|
1004
|
-
queryVector: [1, 2, 3],
|
|
1005
|
-
topK: 5,
|
|
1006
|
-
});
|
|
1007
|
-
|
|
1008
|
-
expect(warnSpy).not.toHaveBeenCalled();
|
|
1009
|
-
});
|
|
1010
|
-
|
|
1011
|
-
it('should not show deprecation warning when using object param for createIndex', async () => {
|
|
1012
|
-
await qdrant.createIndex({
|
|
1013
|
-
indexName: indexName2,
|
|
1014
|
-
dimension: 3,
|
|
1015
|
-
metric: 'cosine',
|
|
1016
|
-
});
|
|
1017
|
-
|
|
1018
|
-
expect(warnSpy).not.toHaveBeenCalled();
|
|
1019
|
-
});
|
|
1020
|
-
|
|
1021
|
-
it('should not show deprecation warning when using object param for upsert', async () => {
|
|
1022
|
-
await qdrant.upsert({
|
|
1023
|
-
indexName,
|
|
1024
|
-
vectors: [[1, 2, 3]],
|
|
1025
|
-
metadata: [{ test: 'data' }],
|
|
1026
|
-
});
|
|
1027
|
-
|
|
1028
|
-
expect(warnSpy).not.toHaveBeenCalled();
|
|
1029
|
-
});
|
|
1030
|
-
|
|
1031
|
-
it('should maintain backward compatibility with individual args', async () => {
|
|
1032
|
-
// Query
|
|
1033
|
-
const queryResults = await qdrant.query(indexName, [1, 2, 3], 5);
|
|
1034
|
-
expect(Array.isArray(queryResults)).toBe(true);
|
|
1035
|
-
|
|
1036
|
-
// CreateIndex
|
|
1037
|
-
await expect(qdrant.createIndex(indexName2, 3, 'cosine')).resolves.not.toThrow();
|
|
1038
|
-
|
|
1039
|
-
// Upsert
|
|
1040
|
-
const upsertResults = await qdrant.upsert({
|
|
1041
|
-
indexName,
|
|
1042
|
-
vectors: [[1, 2, 3]],
|
|
1043
|
-
metadata: [{ test: 'data' }],
|
|
1044
|
-
});
|
|
1045
|
-
expect(Array.isArray(upsertResults)).toBe(true);
|
|
1046
|
-
expect(upsertResults).toHaveLength(1);
|
|
1047
|
-
});
|
|
1048
|
-
});
|
|
1049
952
|
});
|
package/src/vector/index.ts
CHANGED
|
@@ -5,7 +5,6 @@ import type {
|
|
|
5
5
|
CreateIndexParams,
|
|
6
6
|
UpsertVectorParams,
|
|
7
7
|
QueryVectorParams,
|
|
8
|
-
ParamsToArgs,
|
|
9
8
|
DescribeIndexParams,
|
|
10
9
|
DeleteIndexParams,
|
|
11
10
|
DeleteVectorParams,
|
|
@@ -27,44 +26,18 @@ const DISTANCE_MAPPING: Record<string, Schemas['Distance']> = {
|
|
|
27
26
|
export class QdrantVector extends MastraVector {
|
|
28
27
|
private client: QdrantClient;
|
|
29
28
|
|
|
30
|
-
/**
|
|
31
|
-
* @deprecated Passing url, apiKey, https as positional arguments is deprecated.
|
|
32
|
-
* Use the object parameter instead. This signature will be removed on May 20th, 2025.
|
|
33
|
-
*/
|
|
34
|
-
constructor(url: string, apiKey?: string, https?: boolean);
|
|
35
29
|
/**
|
|
36
30
|
* Creates a new QdrantVector client.
|
|
37
|
-
* @param
|
|
31
|
+
* @param url - The URL of the Qdrant server.
|
|
32
|
+
* @param apiKey - The API key for Qdrant.
|
|
33
|
+
* @param https - Whether to use HTTPS.
|
|
38
34
|
*/
|
|
39
|
-
constructor(
|
|
40
|
-
constructor(
|
|
41
|
-
paramsOrUrl: { url: string; apiKey?: string; https?: boolean } | string,
|
|
42
|
-
apiKey?: string,
|
|
43
|
-
https?: boolean,
|
|
44
|
-
) {
|
|
35
|
+
constructor({ url, apiKey, https }: { url: string; apiKey?: string; https?: boolean }) {
|
|
45
36
|
super();
|
|
46
|
-
let url: string;
|
|
47
|
-
let key: string | undefined;
|
|
48
|
-
let secure: boolean | undefined;
|
|
49
|
-
if (typeof paramsOrUrl === 'string') {
|
|
50
|
-
// DEPRECATION WARNING
|
|
51
|
-
if (typeof console !== 'undefined' && console.warn) {
|
|
52
|
-
console.warn(
|
|
53
|
-
`Deprecation Warning: Passing url, apiKey, https as positional arguments to QdrantVector constructor is deprecated.\nPlease use an object parameter instead:\n new QdrantVector({ url, apiKey, https })\nThis signature will be removed on May 20th, 2025.`,
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
url = paramsOrUrl;
|
|
57
|
-
key = apiKey;
|
|
58
|
-
secure = https;
|
|
59
|
-
} else {
|
|
60
|
-
url = paramsOrUrl.url;
|
|
61
|
-
key = paramsOrUrl.apiKey;
|
|
62
|
-
secure = paramsOrUrl.https;
|
|
63
|
-
}
|
|
64
37
|
const baseClient = new QdrantClient({
|
|
65
38
|
url,
|
|
66
|
-
apiKey
|
|
67
|
-
https
|
|
39
|
+
apiKey,
|
|
40
|
+
https,
|
|
68
41
|
});
|
|
69
42
|
const telemetry = this.__getTelemetry();
|
|
70
43
|
this.client =
|
|
@@ -76,11 +49,7 @@ export class QdrantVector extends MastraVector {
|
|
|
76
49
|
}) ?? baseClient;
|
|
77
50
|
}
|
|
78
51
|
|
|
79
|
-
async upsert(
|
|
80
|
-
const params = this.normalizeArgs<UpsertVectorParams>('upsert', args);
|
|
81
|
-
|
|
82
|
-
const { indexName, vectors, metadata, ids } = params;
|
|
83
|
-
|
|
52
|
+
async upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]> {
|
|
84
53
|
const pointIds = ids || vectors.map(() => crypto.randomUUID());
|
|
85
54
|
|
|
86
55
|
const records = vectors.map((vector, i) => ({
|
|
@@ -101,11 +70,7 @@ export class QdrantVector extends MastraVector {
|
|
|
101
70
|
return pointIds;
|
|
102
71
|
}
|
|
103
72
|
|
|
104
|
-
async createIndex(
|
|
105
|
-
const params = this.normalizeArgs<CreateIndexParams>('createIndex', args);
|
|
106
|
-
|
|
107
|
-
const { indexName, dimension, metric = 'cosine' } = params;
|
|
108
|
-
|
|
73
|
+
async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {
|
|
109
74
|
if (!Number.isInteger(dimension) || dimension <= 0) {
|
|
110
75
|
throw new Error('Dimension must be a positive integer');
|
|
111
76
|
}
|
|
@@ -135,11 +100,13 @@ export class QdrantVector extends MastraVector {
|
|
|
135
100
|
return translator.translate(filter);
|
|
136
101
|
}
|
|
137
102
|
|
|
138
|
-
async query(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
103
|
+
async query({
|
|
104
|
+
indexName,
|
|
105
|
+
queryVector,
|
|
106
|
+
topK = 10,
|
|
107
|
+
filter,
|
|
108
|
+
includeVector = false,
|
|
109
|
+
}: QueryVectorParams): Promise<QueryResult[]> {
|
|
143
110
|
const translatedFilter = this.transformFilter(filter) ?? {};
|
|
144
111
|
|
|
145
112
|
const results = (
|
|
@@ -181,13 +148,10 @@ export class QdrantVector extends MastraVector {
|
|
|
181
148
|
/**
|
|
182
149
|
* Retrieves statistics about a vector index.
|
|
183
150
|
*
|
|
184
|
-
* @param
|
|
185
|
-
* @param params.indexName - The name of the index to describe
|
|
151
|
+
* @param {string} indexName - The name of the index to describe
|
|
186
152
|
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
187
153
|
*/
|
|
188
|
-
async describeIndex(
|
|
189
|
-
const params = this.normalizeArgs<DescribeIndexParams>('describeIndex', args);
|
|
190
|
-
const { indexName } = params;
|
|
154
|
+
async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {
|
|
191
155
|
const { config, points_count } = await this.client.getCollection(indexName);
|
|
192
156
|
|
|
193
157
|
const distance = config.params.vectors?.distance as Schemas['Distance'];
|
|
@@ -199,15 +163,11 @@ export class QdrantVector extends MastraVector {
|
|
|
199
163
|
};
|
|
200
164
|
}
|
|
201
165
|
|
|
202
|
-
async deleteIndex(
|
|
203
|
-
const params = this.normalizeArgs<DeleteIndexParams>('deleteIndex', args);
|
|
204
|
-
const { indexName } = params;
|
|
166
|
+
async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {
|
|
205
167
|
await this.client.deleteCollection(indexName);
|
|
206
168
|
}
|
|
207
169
|
|
|
208
170
|
/**
|
|
209
|
-
* @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
|
|
210
|
-
*
|
|
211
171
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
212
172
|
* @param indexName - The name of the index containing the vector.
|
|
213
173
|
* @param id - The ID of the vector to update.
|
|
@@ -217,32 +177,7 @@ export class QdrantVector extends MastraVector {
|
|
|
217
177
|
* @returns A promise that resolves when the update is complete.
|
|
218
178
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
219
179
|
*/
|
|
220
|
-
async
|
|
221
|
-
indexName: string,
|
|
222
|
-
id: string,
|
|
223
|
-
update: { vector?: number[]; metadata?: Record<string, any> },
|
|
224
|
-
): Promise<void> {
|
|
225
|
-
this.logger.warn(
|
|
226
|
-
`Deprecation Warning: updateIndexById() is deprecated.
|
|
227
|
-
Please use updateVector() instead.
|
|
228
|
-
updateIndexById() will be removed on May 20th, 2025.`,
|
|
229
|
-
);
|
|
230
|
-
await this.updateVector({ indexName, id, update });
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
235
|
-
* @param indexName - The name of the index containing the vector.
|
|
236
|
-
* @param id - The ID of the vector to update.
|
|
237
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
238
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
239
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
240
|
-
* @returns A promise that resolves when the update is complete.
|
|
241
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
242
|
-
*/
|
|
243
|
-
async updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void> {
|
|
244
|
-
const params = this.normalizeArgs<UpdateVectorParams>('updateVector', args);
|
|
245
|
-
const { indexName, id, update } = params;
|
|
180
|
+
async updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void> {
|
|
246
181
|
if (!update.vector && !update.metadata) {
|
|
247
182
|
throw new Error('No updates provided');
|
|
248
183
|
}
|
|
@@ -289,24 +224,6 @@ export class QdrantVector extends MastraVector {
|
|
|
289
224
|
}
|
|
290
225
|
}
|
|
291
226
|
|
|
292
|
-
/**
|
|
293
|
-
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
294
|
-
*
|
|
295
|
-
* Deletes a vector by its ID.
|
|
296
|
-
* @param indexName - The name of the index containing the vector.
|
|
297
|
-
* @param id - The ID of the vector to delete.
|
|
298
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
299
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
300
|
-
*/
|
|
301
|
-
async deleteIndexById(indexName: string, id: string): Promise<void> {
|
|
302
|
-
this.logger.warn(
|
|
303
|
-
`Deprecation Warning: deleteIndexById() is deprecated.
|
|
304
|
-
Please use deleteVector() instead.
|
|
305
|
-
deleteIndexById() will be removed on May 20th, 2025.`,
|
|
306
|
-
);
|
|
307
|
-
await this.deleteVector({ indexName, id });
|
|
308
|
-
}
|
|
309
|
-
|
|
310
227
|
/**
|
|
311
228
|
* Deletes a vector by its ID.
|
|
312
229
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -314,9 +231,7 @@ export class QdrantVector extends MastraVector {
|
|
|
314
231
|
* @returns A promise that resolves when the deletion is complete.
|
|
315
232
|
* @throws Will throw an error if the deletion operation fails.
|
|
316
233
|
*/
|
|
317
|
-
async deleteVector(
|
|
318
|
-
const params = this.normalizeArgs<DeleteVectorParams>('deleteVector', args);
|
|
319
|
-
const { indexName, id } = params;
|
|
234
|
+
async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {
|
|
320
235
|
try {
|
|
321
236
|
// Parse the ID - Qdrant supports both string and numeric IDs
|
|
322
237
|
const pointId = this.parsePointId(id);
|