mem0ai 3.0.13 → 3.1.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/dist/index.js +12 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -7
- package/dist/index.mjs.map +1 -1
- package/dist/oss/index.d.mts +1448 -65
- package/dist/oss/index.d.ts +1448 -65
- package/dist/oss/index.js +12018 -3466
- package/dist/oss/index.js.map +1 -1
- package/dist/oss/index.mjs +11985 -3462
- package/dist/oss/index.mjs.map +1 -1
- package/package.json +101 -4
package/dist/oss/index.d.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { MochowClient } from '@mochow/mochow-sdk-node';
|
|
2
3
|
import { QdrantClient } from '@qdrant/js-client-rest';
|
|
3
4
|
import { VectorStore as VectorStore$1 } from '@langchain/core/vectorstores';
|
|
4
5
|
import { ClientConfig } from 'pg';
|
|
5
6
|
|
|
7
|
+
interface ValkeyConfig extends VectorStoreConfig {
|
|
8
|
+
valkeyUrl: string;
|
|
9
|
+
collectionName: string;
|
|
10
|
+
embeddingModelDims: number;
|
|
11
|
+
timezone?: string;
|
|
12
|
+
indexType?: "hnsw" | "flat";
|
|
13
|
+
hnswM?: number;
|
|
14
|
+
hnswEfConstruction?: number;
|
|
15
|
+
hnswEfRuntime?: number;
|
|
16
|
+
clusterMode?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
6
19
|
interface MultiModalMessages {
|
|
7
20
|
type: "image_url";
|
|
8
21
|
image_url: {
|
|
@@ -20,7 +33,18 @@ interface EmbeddingConfig {
|
|
|
20
33
|
url?: string;
|
|
21
34
|
embeddingDims?: number;
|
|
22
35
|
modelProperties?: Record<string, any>;
|
|
36
|
+
huggingfaceBaseUrl?: string;
|
|
23
37
|
}
|
|
38
|
+
interface VertexAIConfig extends EmbeddingConfig {
|
|
39
|
+
vertexCredentialsJson?: string;
|
|
40
|
+
googleServiceAccountJson?: string | Record<string, any>;
|
|
41
|
+
googleProjectId?: string;
|
|
42
|
+
location?: string;
|
|
43
|
+
memoryAddEmbeddingType?: string;
|
|
44
|
+
memoryUpdateEmbeddingType?: string;
|
|
45
|
+
memorySearchEmbeddingType?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
24
48
|
interface VectorStoreConfig {
|
|
25
49
|
collectionName?: string;
|
|
26
50
|
dimension?: number;
|
|
@@ -41,6 +65,8 @@ interface HistoryStoreConfig {
|
|
|
41
65
|
interface LLMConfig {
|
|
42
66
|
provider?: string;
|
|
43
67
|
baseURL?: string;
|
|
68
|
+
vllmBaseURL?: string;
|
|
69
|
+
vllm_base_url?: string;
|
|
44
70
|
url?: string;
|
|
45
71
|
config?: Record<string, any>;
|
|
46
72
|
apiKey?: string;
|
|
@@ -50,6 +76,57 @@ interface LLMConfig {
|
|
|
50
76
|
temperature?: number;
|
|
51
77
|
topP?: number;
|
|
52
78
|
maxTokens?: number;
|
|
79
|
+
awsRegion?: string;
|
|
80
|
+
awsAccessKeyId?: string;
|
|
81
|
+
awsSecretAccessKey?: string;
|
|
82
|
+
awsSessionToken?: string;
|
|
83
|
+
client?: any;
|
|
84
|
+
}
|
|
85
|
+
interface RerankerConfig {
|
|
86
|
+
apiKey?: string;
|
|
87
|
+
/** The reranker model to use. Default varies by provider. */
|
|
88
|
+
model?: string;
|
|
89
|
+
/** Maximum number of documents to return after reranking. Default: unset (return all). */
|
|
90
|
+
topK?: number;
|
|
91
|
+
/** `cohere` only. Return document texts in the response. Default: `false`. */
|
|
92
|
+
returnDocuments?: boolean;
|
|
93
|
+
/** `cohere` only. Maximum number of chunks per document. Default: unset. */
|
|
94
|
+
maxChunksPerDoc?: number;
|
|
95
|
+
/**
|
|
96
|
+
* `sentence_transformer` / `huggingface` only. Transformers.js device, e.g.
|
|
97
|
+
* `"cpu"`, `"wasm"`, `"webgpu"`. Default: unset (auto-detect).
|
|
98
|
+
*/
|
|
99
|
+
device?: string;
|
|
100
|
+
/** `huggingface` only. Max token length per query-document pair. Default: `512`. */
|
|
101
|
+
maxLength?: number;
|
|
102
|
+
/**
|
|
103
|
+
* `sentence_transformer` / `huggingface` only. Sigmoid-normalize raw logits
|
|
104
|
+
* to `[0, 1]`. Default: `true`; set `false` to surface raw logits.
|
|
105
|
+
*/
|
|
106
|
+
normalize?: boolean;
|
|
107
|
+
/** No-op: a search reranks a small candidate set in one forward pass. */
|
|
108
|
+
batchSize?: number;
|
|
109
|
+
/** No-op in this runtime. */
|
|
110
|
+
showProgressBar?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* `llm_reranker` only. LLM provider used to build the scoring LLM when
|
|
113
|
+
* `llm` is not set. Default: `"openai"`.
|
|
114
|
+
*/
|
|
115
|
+
provider?: string;
|
|
116
|
+
/** `llm_reranker` only. Temperature for LLM generation. Default: `0.0`. */
|
|
117
|
+
temperature?: number;
|
|
118
|
+
/** `llm_reranker` only. Maximum tokens for the LLM response. Default: `100`. */
|
|
119
|
+
maxTokens?: number;
|
|
120
|
+
/**
|
|
121
|
+
* `llm_reranker` only. Nested LLM configuration. When set, it overrides the
|
|
122
|
+
* top-level `provider`/`model`/`temperature`/`maxTokens`/`apiKey`, which
|
|
123
|
+
* then only act as defaults for fields missing from `llm.config`.
|
|
124
|
+
*/
|
|
125
|
+
llm?: {
|
|
126
|
+
provider: string;
|
|
127
|
+
config: LLMConfig;
|
|
128
|
+
};
|
|
129
|
+
[key: string]: any;
|
|
53
130
|
}
|
|
54
131
|
interface MemoryConfig {
|
|
55
132
|
version?: string;
|
|
@@ -65,6 +142,10 @@ interface MemoryConfig {
|
|
|
65
142
|
provider: string;
|
|
66
143
|
config: LLMConfig;
|
|
67
144
|
};
|
|
145
|
+
reranker?: {
|
|
146
|
+
provider: string;
|
|
147
|
+
config: RerankerConfig;
|
|
148
|
+
};
|
|
68
149
|
historyStore?: HistoryStoreConfig;
|
|
69
150
|
disableHistory?: boolean;
|
|
70
151
|
historyDbPath?: string;
|
|
@@ -77,6 +158,8 @@ interface MemoryItem {
|
|
|
77
158
|
createdAt?: string;
|
|
78
159
|
updatedAt?: string;
|
|
79
160
|
score?: number;
|
|
161
|
+
/** Relevance score added by the reranker, alongside (not replacing) `score`. */
|
|
162
|
+
rerankScore?: number;
|
|
80
163
|
metadata?: Record<string, any>;
|
|
81
164
|
attributedTo?: string;
|
|
82
165
|
}
|
|
@@ -105,17 +188,38 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
105
188
|
baseURL: z.ZodOptional<z.ZodString>;
|
|
106
189
|
embeddingDims: z.ZodOptional<z.ZodNumber>;
|
|
107
190
|
url: z.ZodOptional<z.ZodString>;
|
|
191
|
+
vertexCredentialsJson: z.ZodOptional<z.ZodString>;
|
|
192
|
+
googleServiceAccountJson: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
|
|
193
|
+
googleProjectId: z.ZodOptional<z.ZodString>;
|
|
194
|
+
location: z.ZodOptional<z.ZodString>;
|
|
195
|
+
memoryAddEmbeddingType: z.ZodOptional<z.ZodString>;
|
|
196
|
+
memoryUpdateEmbeddingType: z.ZodOptional<z.ZodString>;
|
|
197
|
+
memorySearchEmbeddingType: z.ZodOptional<z.ZodString>;
|
|
108
198
|
}, "strip", z.ZodTypeAny, {
|
|
109
|
-
|
|
199
|
+
vertexCredentialsJson?: string | undefined;
|
|
200
|
+
googleServiceAccountJson?: string | Record<string, any> | undefined;
|
|
201
|
+
googleProjectId?: string | undefined;
|
|
202
|
+
location?: string | undefined;
|
|
203
|
+
memoryAddEmbeddingType?: string | undefined;
|
|
204
|
+
memoryUpdateEmbeddingType?: string | undefined;
|
|
205
|
+
memorySearchEmbeddingType?: string | undefined;
|
|
110
206
|
apiKey?: string | undefined;
|
|
111
207
|
model?: any;
|
|
208
|
+
modelProperties?: Record<string, any> | undefined;
|
|
112
209
|
baseURL?: string | undefined;
|
|
113
210
|
embeddingDims?: number | undefined;
|
|
114
211
|
url?: string | undefined;
|
|
115
212
|
}, {
|
|
116
|
-
|
|
213
|
+
vertexCredentialsJson?: string | undefined;
|
|
214
|
+
googleServiceAccountJson?: string | Record<string, any> | undefined;
|
|
215
|
+
googleProjectId?: string | undefined;
|
|
216
|
+
location?: string | undefined;
|
|
217
|
+
memoryAddEmbeddingType?: string | undefined;
|
|
218
|
+
memoryUpdateEmbeddingType?: string | undefined;
|
|
219
|
+
memorySearchEmbeddingType?: string | undefined;
|
|
117
220
|
apiKey?: string | undefined;
|
|
118
221
|
model?: any;
|
|
222
|
+
modelProperties?: Record<string, any> | undefined;
|
|
119
223
|
baseURL?: string | undefined;
|
|
120
224
|
embeddingDims?: number | undefined;
|
|
121
225
|
url?: string | undefined;
|
|
@@ -123,9 +227,16 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
123
227
|
}, "strip", z.ZodTypeAny, {
|
|
124
228
|
provider: string;
|
|
125
229
|
config: {
|
|
126
|
-
|
|
230
|
+
vertexCredentialsJson?: string | undefined;
|
|
231
|
+
googleServiceAccountJson?: string | Record<string, any> | undefined;
|
|
232
|
+
googleProjectId?: string | undefined;
|
|
233
|
+
location?: string | undefined;
|
|
234
|
+
memoryAddEmbeddingType?: string | undefined;
|
|
235
|
+
memoryUpdateEmbeddingType?: string | undefined;
|
|
236
|
+
memorySearchEmbeddingType?: string | undefined;
|
|
127
237
|
apiKey?: string | undefined;
|
|
128
238
|
model?: any;
|
|
239
|
+
modelProperties?: Record<string, any> | undefined;
|
|
129
240
|
baseURL?: string | undefined;
|
|
130
241
|
embeddingDims?: number | undefined;
|
|
131
242
|
url?: string | undefined;
|
|
@@ -133,9 +244,16 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
133
244
|
}, {
|
|
134
245
|
provider: string;
|
|
135
246
|
config: {
|
|
136
|
-
|
|
247
|
+
vertexCredentialsJson?: string | undefined;
|
|
248
|
+
googleServiceAccountJson?: string | Record<string, any> | undefined;
|
|
249
|
+
googleProjectId?: string | undefined;
|
|
250
|
+
location?: string | undefined;
|
|
251
|
+
memoryAddEmbeddingType?: string | undefined;
|
|
252
|
+
memoryUpdateEmbeddingType?: string | undefined;
|
|
253
|
+
memorySearchEmbeddingType?: string | undefined;
|
|
137
254
|
apiKey?: string | undefined;
|
|
138
255
|
model?: any;
|
|
256
|
+
modelProperties?: Record<string, any> | undefined;
|
|
139
257
|
baseURL?: string | undefined;
|
|
140
258
|
embeddingDims?: number | undefined;
|
|
141
259
|
url?: string | undefined;
|
|
@@ -187,57 +305,96 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
187
305
|
model: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodAny]>>;
|
|
188
306
|
modelProperties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
189
307
|
baseURL: z.ZodOptional<z.ZodString>;
|
|
308
|
+
vllmBaseURL: z.ZodOptional<z.ZodString>;
|
|
309
|
+
vllm_base_url: z.ZodOptional<z.ZodString>;
|
|
190
310
|
url: z.ZodOptional<z.ZodString>;
|
|
191
311
|
timeout: z.ZodOptional<z.ZodNumber>;
|
|
192
312
|
temperature: z.ZodOptional<z.ZodNumber>;
|
|
193
313
|
topP: z.ZodOptional<z.ZodNumber>;
|
|
194
314
|
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
195
|
-
|
|
196
|
-
|
|
315
|
+
awsRegion: z.ZodOptional<z.ZodString>;
|
|
316
|
+
awsAccessKeyId: z.ZodOptional<z.ZodString>;
|
|
317
|
+
awsSecretAccessKey: z.ZodOptional<z.ZodString>;
|
|
318
|
+
awsSessionToken: z.ZodOptional<z.ZodString>;
|
|
319
|
+
client: z.ZodOptional<z.ZodAny>;
|
|
320
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
321
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
322
|
+
model: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodAny]>>;
|
|
323
|
+
modelProperties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
324
|
+
baseURL: z.ZodOptional<z.ZodString>;
|
|
325
|
+
vllmBaseURL: z.ZodOptional<z.ZodString>;
|
|
326
|
+
vllm_base_url: z.ZodOptional<z.ZodString>;
|
|
327
|
+
url: z.ZodOptional<z.ZodString>;
|
|
328
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
329
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
330
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
331
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
332
|
+
awsRegion: z.ZodOptional<z.ZodString>;
|
|
333
|
+
awsAccessKeyId: z.ZodOptional<z.ZodString>;
|
|
334
|
+
awsSecretAccessKey: z.ZodOptional<z.ZodString>;
|
|
335
|
+
awsSessionToken: z.ZodOptional<z.ZodString>;
|
|
336
|
+
client: z.ZodOptional<z.ZodAny>;
|
|
337
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
338
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
339
|
+
model: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodAny]>>;
|
|
340
|
+
modelProperties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
341
|
+
baseURL: z.ZodOptional<z.ZodString>;
|
|
342
|
+
vllmBaseURL: z.ZodOptional<z.ZodString>;
|
|
343
|
+
vllm_base_url: z.ZodOptional<z.ZodString>;
|
|
344
|
+
url: z.ZodOptional<z.ZodString>;
|
|
345
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
346
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
347
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
348
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
349
|
+
awsRegion: z.ZodOptional<z.ZodString>;
|
|
350
|
+
awsAccessKeyId: z.ZodOptional<z.ZodString>;
|
|
351
|
+
awsSecretAccessKey: z.ZodOptional<z.ZodString>;
|
|
352
|
+
awsSessionToken: z.ZodOptional<z.ZodString>;
|
|
353
|
+
client: z.ZodOptional<z.ZodAny>;
|
|
354
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
355
|
+
}, "strip", z.ZodTypeAny, {
|
|
356
|
+
provider: string;
|
|
357
|
+
config: {
|
|
358
|
+
client?: any;
|
|
197
359
|
apiKey?: string | undefined;
|
|
198
360
|
model?: any;
|
|
199
|
-
baseURL?: string | undefined;
|
|
200
|
-
url?: string | undefined;
|
|
201
|
-
timeout?: number | undefined;
|
|
202
361
|
temperature?: number | undefined;
|
|
203
|
-
topP?: number | undefined;
|
|
204
362
|
maxTokens?: number | undefined;
|
|
205
|
-
}, {
|
|
206
363
|
modelProperties?: Record<string, any> | undefined;
|
|
207
|
-
apiKey?: string | undefined;
|
|
208
|
-
model?: any;
|
|
209
364
|
baseURL?: string | undefined;
|
|
210
365
|
url?: string | undefined;
|
|
366
|
+
vllmBaseURL?: string | undefined;
|
|
367
|
+
vllm_base_url?: string | undefined;
|
|
211
368
|
timeout?: number | undefined;
|
|
212
|
-
temperature?: number | undefined;
|
|
213
369
|
topP?: number | undefined;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
370
|
+
awsRegion?: string | undefined;
|
|
371
|
+
awsAccessKeyId?: string | undefined;
|
|
372
|
+
awsSecretAccessKey?: string | undefined;
|
|
373
|
+
awsSessionToken?: string | undefined;
|
|
374
|
+
} & {
|
|
375
|
+
[k: string]: unknown;
|
|
376
|
+
};
|
|
377
|
+
}, {
|
|
217
378
|
provider: string;
|
|
218
379
|
config: {
|
|
219
|
-
|
|
380
|
+
client?: any;
|
|
220
381
|
apiKey?: string | undefined;
|
|
221
382
|
model?: any;
|
|
222
|
-
baseURL?: string | undefined;
|
|
223
|
-
url?: string | undefined;
|
|
224
|
-
timeout?: number | undefined;
|
|
225
383
|
temperature?: number | undefined;
|
|
226
|
-
topP?: number | undefined;
|
|
227
384
|
maxTokens?: number | undefined;
|
|
228
|
-
};
|
|
229
|
-
}, {
|
|
230
|
-
provider: string;
|
|
231
|
-
config: {
|
|
232
385
|
modelProperties?: Record<string, any> | undefined;
|
|
233
|
-
apiKey?: string | undefined;
|
|
234
|
-
model?: any;
|
|
235
386
|
baseURL?: string | undefined;
|
|
236
387
|
url?: string | undefined;
|
|
388
|
+
vllmBaseURL?: string | undefined;
|
|
389
|
+
vllm_base_url?: string | undefined;
|
|
237
390
|
timeout?: number | undefined;
|
|
238
|
-
temperature?: number | undefined;
|
|
239
391
|
topP?: number | undefined;
|
|
240
|
-
|
|
392
|
+
awsRegion?: string | undefined;
|
|
393
|
+
awsAccessKeyId?: string | undefined;
|
|
394
|
+
awsSecretAccessKey?: string | undefined;
|
|
395
|
+
awsSessionToken?: string | undefined;
|
|
396
|
+
} & {
|
|
397
|
+
[k: string]: unknown;
|
|
241
398
|
};
|
|
242
399
|
}>;
|
|
243
400
|
historyDbPath: z.ZodOptional<z.ZodString>;
|
|
@@ -252,14 +409,54 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
252
409
|
provider: string;
|
|
253
410
|
config: Record<string, any>;
|
|
254
411
|
}>>;
|
|
412
|
+
reranker: z.ZodOptional<z.ZodObject<{
|
|
413
|
+
provider: z.ZodString;
|
|
414
|
+
config: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
415
|
+
}, "strip", z.ZodTypeAny, {
|
|
416
|
+
provider: string;
|
|
417
|
+
config: Record<string, any>;
|
|
418
|
+
}, {
|
|
419
|
+
provider: string;
|
|
420
|
+
config: Record<string, any>;
|
|
421
|
+
}>>;
|
|
255
422
|
disableHistory: z.ZodOptional<z.ZodBoolean>;
|
|
256
423
|
}, "strip", z.ZodTypeAny, {
|
|
257
|
-
|
|
424
|
+
llm: {
|
|
258
425
|
provider: string;
|
|
259
426
|
config: {
|
|
427
|
+
client?: any;
|
|
428
|
+
apiKey?: string | undefined;
|
|
429
|
+
model?: any;
|
|
430
|
+
temperature?: number | undefined;
|
|
431
|
+
maxTokens?: number | undefined;
|
|
260
432
|
modelProperties?: Record<string, any> | undefined;
|
|
433
|
+
baseURL?: string | undefined;
|
|
434
|
+
url?: string | undefined;
|
|
435
|
+
vllmBaseURL?: string | undefined;
|
|
436
|
+
vllm_base_url?: string | undefined;
|
|
437
|
+
timeout?: number | undefined;
|
|
438
|
+
topP?: number | undefined;
|
|
439
|
+
awsRegion?: string | undefined;
|
|
440
|
+
awsAccessKeyId?: string | undefined;
|
|
441
|
+
awsSecretAccessKey?: string | undefined;
|
|
442
|
+
awsSessionToken?: string | undefined;
|
|
443
|
+
} & {
|
|
444
|
+
[k: string]: unknown;
|
|
445
|
+
};
|
|
446
|
+
};
|
|
447
|
+
embedder: {
|
|
448
|
+
provider: string;
|
|
449
|
+
config: {
|
|
450
|
+
vertexCredentialsJson?: string | undefined;
|
|
451
|
+
googleServiceAccountJson?: string | Record<string, any> | undefined;
|
|
452
|
+
googleProjectId?: string | undefined;
|
|
453
|
+
location?: string | undefined;
|
|
454
|
+
memoryAddEmbeddingType?: string | undefined;
|
|
455
|
+
memoryUpdateEmbeddingType?: string | undefined;
|
|
456
|
+
memorySearchEmbeddingType?: string | undefined;
|
|
261
457
|
apiKey?: string | undefined;
|
|
262
458
|
model?: any;
|
|
459
|
+
modelProperties?: Record<string, any> | undefined;
|
|
263
460
|
baseURL?: string | undefined;
|
|
264
461
|
embeddingDims?: number | undefined;
|
|
265
462
|
url?: string | undefined;
|
|
@@ -276,35 +473,55 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
276
473
|
[k: string]: unknown;
|
|
277
474
|
};
|
|
278
475
|
};
|
|
476
|
+
version?: string | undefined;
|
|
477
|
+
historyDbPath?: string | undefined;
|
|
478
|
+
customInstructions?: string | undefined;
|
|
479
|
+
historyStore?: {
|
|
480
|
+
provider: string;
|
|
481
|
+
config: Record<string, any>;
|
|
482
|
+
} | undefined;
|
|
483
|
+
reranker?: {
|
|
484
|
+
provider: string;
|
|
485
|
+
config: Record<string, any>;
|
|
486
|
+
} | undefined;
|
|
487
|
+
disableHistory?: boolean | undefined;
|
|
488
|
+
}, {
|
|
279
489
|
llm: {
|
|
280
490
|
provider: string;
|
|
281
491
|
config: {
|
|
282
|
-
|
|
492
|
+
client?: any;
|
|
283
493
|
apiKey?: string | undefined;
|
|
284
494
|
model?: any;
|
|
495
|
+
temperature?: number | undefined;
|
|
496
|
+
maxTokens?: number | undefined;
|
|
497
|
+
modelProperties?: Record<string, any> | undefined;
|
|
285
498
|
baseURL?: string | undefined;
|
|
286
499
|
url?: string | undefined;
|
|
500
|
+
vllmBaseURL?: string | undefined;
|
|
501
|
+
vllm_base_url?: string | undefined;
|
|
287
502
|
timeout?: number | undefined;
|
|
288
|
-
temperature?: number | undefined;
|
|
289
503
|
topP?: number | undefined;
|
|
290
|
-
|
|
504
|
+
awsRegion?: string | undefined;
|
|
505
|
+
awsAccessKeyId?: string | undefined;
|
|
506
|
+
awsSecretAccessKey?: string | undefined;
|
|
507
|
+
awsSessionToken?: string | undefined;
|
|
508
|
+
} & {
|
|
509
|
+
[k: string]: unknown;
|
|
291
510
|
};
|
|
292
511
|
};
|
|
293
|
-
version?: string | undefined;
|
|
294
|
-
historyDbPath?: string | undefined;
|
|
295
|
-
customInstructions?: string | undefined;
|
|
296
|
-
historyStore?: {
|
|
297
|
-
provider: string;
|
|
298
|
-
config: Record<string, any>;
|
|
299
|
-
} | undefined;
|
|
300
|
-
disableHistory?: boolean | undefined;
|
|
301
|
-
}, {
|
|
302
512
|
embedder: {
|
|
303
513
|
provider: string;
|
|
304
514
|
config: {
|
|
305
|
-
|
|
515
|
+
vertexCredentialsJson?: string | undefined;
|
|
516
|
+
googleServiceAccountJson?: string | Record<string, any> | undefined;
|
|
517
|
+
googleProjectId?: string | undefined;
|
|
518
|
+
location?: string | undefined;
|
|
519
|
+
memoryAddEmbeddingType?: string | undefined;
|
|
520
|
+
memoryUpdateEmbeddingType?: string | undefined;
|
|
521
|
+
memorySearchEmbeddingType?: string | undefined;
|
|
306
522
|
apiKey?: string | undefined;
|
|
307
523
|
model?: any;
|
|
524
|
+
modelProperties?: Record<string, any> | undefined;
|
|
308
525
|
baseURL?: string | undefined;
|
|
309
526
|
embeddingDims?: number | undefined;
|
|
310
527
|
url?: string | undefined;
|
|
@@ -321,20 +538,6 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
321
538
|
[k: string]: unknown;
|
|
322
539
|
};
|
|
323
540
|
};
|
|
324
|
-
llm: {
|
|
325
|
-
provider: string;
|
|
326
|
-
config: {
|
|
327
|
-
modelProperties?: Record<string, any> | undefined;
|
|
328
|
-
apiKey?: string | undefined;
|
|
329
|
-
model?: any;
|
|
330
|
-
baseURL?: string | undefined;
|
|
331
|
-
url?: string | undefined;
|
|
332
|
-
timeout?: number | undefined;
|
|
333
|
-
temperature?: number | undefined;
|
|
334
|
-
topP?: number | undefined;
|
|
335
|
-
maxTokens?: number | undefined;
|
|
336
|
-
};
|
|
337
|
-
};
|
|
338
541
|
version?: string | undefined;
|
|
339
542
|
historyDbPath?: string | undefined;
|
|
340
543
|
customInstructions?: string | undefined;
|
|
@@ -342,6 +545,10 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
342
545
|
provider: string;
|
|
343
546
|
config: Record<string, any>;
|
|
344
547
|
} | undefined;
|
|
548
|
+
reranker?: {
|
|
549
|
+
provider: string;
|
|
550
|
+
config: Record<string, any>;
|
|
551
|
+
} | undefined;
|
|
345
552
|
disableHistory?: boolean | undefined;
|
|
346
553
|
}>;
|
|
347
554
|
|
|
@@ -355,6 +562,21 @@ interface AddMemoryOptions extends Entity {
|
|
|
355
562
|
filters?: SearchFilters;
|
|
356
563
|
infer?: boolean;
|
|
357
564
|
timestamp?: number | string | Date | null;
|
|
565
|
+
/** Date (YYYY-MM-DD) after which the memory is considered expired. */
|
|
566
|
+
expirationDate?: string | null;
|
|
567
|
+
}
|
|
568
|
+
interface UpdateMemoryOptions {
|
|
569
|
+
/** New content to update the memory with. */
|
|
570
|
+
text?: string;
|
|
571
|
+
/**
|
|
572
|
+
* New content to update the memory with.
|
|
573
|
+
* @deprecated Use `text` instead. Will be removed in the next major release.
|
|
574
|
+
*/
|
|
575
|
+
data?: string;
|
|
576
|
+
/** Metadata merged into the memory's existing metadata. */
|
|
577
|
+
metadata?: Record<string, any>;
|
|
578
|
+
/** Date (YYYY-MM-DD) after which the memory expires, or `null` to clear it. */
|
|
579
|
+
expirationDate?: string | null;
|
|
358
580
|
}
|
|
359
581
|
interface SearchMemoryOptions {
|
|
360
582
|
topK?: number;
|
|
@@ -362,10 +584,19 @@ interface SearchMemoryOptions {
|
|
|
362
584
|
threshold?: number;
|
|
363
585
|
explain?: boolean;
|
|
364
586
|
referenceDate?: number | string | Date | null;
|
|
587
|
+
/**
|
|
588
|
+
* Re-rank the results with the configured reranker before returning. No-op
|
|
589
|
+
* when no `reranker` is configured on the Memory.
|
|
590
|
+
*/
|
|
591
|
+
rerank?: boolean;
|
|
592
|
+
/** Include expired memories in the results. Defaults to false. */
|
|
593
|
+
showExpired?: boolean;
|
|
365
594
|
}
|
|
366
595
|
interface GetAllMemoryOptions {
|
|
367
596
|
topK?: number;
|
|
368
597
|
filters?: SearchFilters;
|
|
598
|
+
/** Include expired memories in the results. Defaults to false. */
|
|
599
|
+
showExpired?: boolean;
|
|
369
600
|
}
|
|
370
601
|
interface DeleteAllMemoryOptions extends Entity {
|
|
371
602
|
}
|
|
@@ -374,12 +605,19 @@ interface UpdateProjectOptions {
|
|
|
374
605
|
[key: string]: any;
|
|
375
606
|
}
|
|
376
607
|
|
|
608
|
+
declare class LLMError extends Error {
|
|
609
|
+
readonly cause?: unknown;
|
|
610
|
+
constructor(message: string, options?: {
|
|
611
|
+
cause?: unknown;
|
|
612
|
+
});
|
|
613
|
+
}
|
|
377
614
|
declare class Memory {
|
|
378
615
|
private config;
|
|
379
616
|
private customInstructions;
|
|
380
617
|
private embedder;
|
|
381
618
|
private vectorStore;
|
|
382
619
|
private llm;
|
|
620
|
+
private reranker;
|
|
383
621
|
private db;
|
|
384
622
|
private collectionName;
|
|
385
623
|
private apiVersion;
|
|
@@ -441,7 +679,7 @@ declare class Memory {
|
|
|
441
679
|
private addToVectorStore;
|
|
442
680
|
get(memoryId: string): Promise<MemoryItem | null>;
|
|
443
681
|
search(query: string, config: SearchMemoryOptions): Promise<SearchResult>;
|
|
444
|
-
update(memoryId: string,
|
|
682
|
+
update(memoryId: string, config: string | UpdateMemoryOptions): Promise<{
|
|
445
683
|
message: string;
|
|
446
684
|
}>;
|
|
447
685
|
delete(memoryId: string): Promise<{
|
|
@@ -468,6 +706,27 @@ declare class Memory {
|
|
|
468
706
|
}
|
|
469
707
|
|
|
470
708
|
interface Embedder {
|
|
709
|
+
embed(text: string, memoryAction?: "add" | "update" | "search"): Promise<number[]>;
|
|
710
|
+
embedBatch(texts: string[], memoryAction?: "add" | "update" | "search"): Promise<number[][]>;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* HuggingFace embedding provider (hosted inference mode).
|
|
715
|
+
*
|
|
716
|
+
* Mirrors the `huggingface_base_url` branch of the Python provider
|
|
717
|
+
* (`mem0/embeddings/huggingface.py`): a HuggingFace Text Embeddings Inference
|
|
718
|
+
* (TEI) server, or any HuggingFace OpenAI-compatible inference endpoint,
|
|
719
|
+
* exposes a `/v1/embeddings` route, so this embedder reuses the existing
|
|
720
|
+
* `openai` client pointed at that base URL. No new dependency is required.
|
|
721
|
+
*
|
|
722
|
+
* A base URL is required. The Python provider's alternative local
|
|
723
|
+
* `sentence-transformers` path has no lightweight TypeScript equivalent, so
|
|
724
|
+
* hosted inference is the supported TS mode.
|
|
725
|
+
*/
|
|
726
|
+
declare class HuggingFaceEmbedder implements Embedder {
|
|
727
|
+
private openai;
|
|
728
|
+
private model;
|
|
729
|
+
constructor(config: EmbeddingConfig);
|
|
471
730
|
embed(text: string): Promise<number[]>;
|
|
472
731
|
embedBatch(texts: string[]): Promise<number[][]>;
|
|
473
732
|
}
|
|
@@ -501,6 +760,10 @@ declare class LMStudioEmbedder implements Embedder {
|
|
|
501
760
|
embedBatch(texts: string[]): Promise<number[][]>;
|
|
502
761
|
}
|
|
503
762
|
|
|
763
|
+
declare class TogetherEmbedder extends OpenAIEmbedder {
|
|
764
|
+
constructor(config: EmbeddingConfig);
|
|
765
|
+
}
|
|
766
|
+
|
|
504
767
|
declare class GoogleEmbedder implements Embedder {
|
|
505
768
|
private google;
|
|
506
769
|
private model;
|
|
@@ -527,6 +790,40 @@ declare class LangchainEmbedder implements Embedder {
|
|
|
527
790
|
embedBatch(texts: string[]): Promise<number[][]>;
|
|
528
791
|
}
|
|
529
792
|
|
|
793
|
+
declare class VertexAIEmbedder implements Embedder {
|
|
794
|
+
private client;
|
|
795
|
+
private helpers;
|
|
796
|
+
private initPromise;
|
|
797
|
+
private clientOptions;
|
|
798
|
+
private model;
|
|
799
|
+
private embeddingDims;
|
|
800
|
+
private location;
|
|
801
|
+
private projectId;
|
|
802
|
+
private embeddingTypes;
|
|
803
|
+
constructor(config: VertexAIConfig);
|
|
804
|
+
private initClient;
|
|
805
|
+
private createClient;
|
|
806
|
+
private endpoint;
|
|
807
|
+
private formatInstance;
|
|
808
|
+
embed(text: string, memoryAction?: "add" | "update" | "search"): Promise<number[]>;
|
|
809
|
+
embedBatch(texts: string[], memoryAction?: "add" | "update" | "search"): Promise<number[][]>;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
declare class FastEmbedEmbedder implements Embedder {
|
|
813
|
+
private readonly modelName;
|
|
814
|
+
private embeddingModel?;
|
|
815
|
+
constructor(config: EmbeddingConfig);
|
|
816
|
+
private getEmbeddingModel;
|
|
817
|
+
/**
|
|
818
|
+
* Lazily import the optional `fastembed` peer and initialize the model, so
|
|
819
|
+
* consumers that never touch FastEmbed don't need it installed.
|
|
820
|
+
*/
|
|
821
|
+
private initEmbeddingModel;
|
|
822
|
+
private normalizeInput;
|
|
823
|
+
embed(text: string): Promise<number[]>;
|
|
824
|
+
embedBatch(texts: string[]): Promise<number[][]>;
|
|
825
|
+
}
|
|
826
|
+
|
|
530
827
|
interface LLMResponse {
|
|
531
828
|
content: string;
|
|
532
829
|
role: string;
|
|
@@ -648,6 +945,71 @@ declare class LiteLLM extends OpenAILLM {
|
|
|
648
945
|
generateChat(messages: Message[]): Promise<LLMResponse>;
|
|
649
946
|
}
|
|
650
947
|
|
|
948
|
+
declare class VllmLLM extends OpenAILLM {
|
|
949
|
+
constructor(config: LLMConfig);
|
|
950
|
+
generateResponse(messages: Message[], responseFormat?: {
|
|
951
|
+
type: string;
|
|
952
|
+
}, tools?: any[]): Promise<string | LLMResponse>;
|
|
953
|
+
generateChat(messages: Message[]): Promise<LLMResponse>;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* Extract the model-family provider from a Bedrock model id
|
|
958
|
+
* (e.g. `anthropic.claude-3-sonnet-...` -> `anthropic`).
|
|
959
|
+
*/
|
|
960
|
+
declare function extractProvider(model: string): string;
|
|
961
|
+
/**
|
|
962
|
+
* AWS Bedrock fields (awsRegion / awsAccessKeyId / awsSecretAccessKey /
|
|
963
|
+
* awsSessionToken / client) now live on the shared `LLMConfig`, so the
|
|
964
|
+
* provider is configurable through the standard typed `Memory` config path.
|
|
965
|
+
*/
|
|
966
|
+
type AWSBedrockConfig = LLMConfig;
|
|
967
|
+
declare class AWSBedrockLLM implements LLM {
|
|
968
|
+
private model;
|
|
969
|
+
private provider;
|
|
970
|
+
private temperature;
|
|
971
|
+
private maxTokens;
|
|
972
|
+
private topP?;
|
|
973
|
+
private clientConfig;
|
|
974
|
+
private clientOverride?;
|
|
975
|
+
private sdkPromise?;
|
|
976
|
+
private clientPromise?;
|
|
977
|
+
constructor(config?: AWSBedrockConfig);
|
|
978
|
+
/**
|
|
979
|
+
* Load the optional AWS SDK on first use.
|
|
980
|
+
*
|
|
981
|
+
* This MUST be a dynamic `import()`, never `require()`: tsup/esbuild rewrite
|
|
982
|
+
* `require()` in the published ESM bundle (`dist/oss/index.mjs`) into a
|
|
983
|
+
* `__require` shim that throws `Dynamic require of "..." is not supported`,
|
|
984
|
+
* so every ESM consumer would hit a dead provider even with the SDK installed.
|
|
985
|
+
*/
|
|
986
|
+
private getSDK;
|
|
987
|
+
/** Memoized Bedrock client; an injected `config.client` short-circuits the SDK. */
|
|
988
|
+
private getClient;
|
|
989
|
+
/**
|
|
990
|
+
* Split messages into a top-level `system` block (Converse passes system
|
|
991
|
+
* prompts separately) and role-tagged content blocks for everything else.
|
|
992
|
+
*/
|
|
993
|
+
private formatMessages;
|
|
994
|
+
/**
|
|
995
|
+
* Build the Converse `inferenceConfig`. Anthropic and MiniMax reasoning
|
|
996
|
+
* models reject requests carrying both `temperature` and `topP`, so `topP`
|
|
997
|
+
* is omitted for those families (mirrors the Python `_build_inference_config`).
|
|
998
|
+
*/
|
|
999
|
+
private buildInferenceConfig;
|
|
1000
|
+
/** Convert OpenAI-style tools to the Converse `toolConfig` shape. */
|
|
1001
|
+
private convertToolsToConverse;
|
|
1002
|
+
private converse;
|
|
1003
|
+
/** Pull the first text block out of a Converse response. */
|
|
1004
|
+
private parseText;
|
|
1005
|
+
/** Collect any toolUse blocks out of a Converse response. */
|
|
1006
|
+
private parseToolCalls;
|
|
1007
|
+
generateResponse(messages: Message[], _responseFormat?: {
|
|
1008
|
+
type: string;
|
|
1009
|
+
}, tools?: any[]): Promise<string | LLMResponse>;
|
|
1010
|
+
generateChat(messages: Message[]): Promise<LLMResponse>;
|
|
1011
|
+
}
|
|
1012
|
+
|
|
651
1013
|
interface VectorStore {
|
|
652
1014
|
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
653
1015
|
search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
@@ -695,6 +1057,54 @@ declare class MemoryVectorStore implements VectorStore {
|
|
|
695
1057
|
initialize(): Promise<void>;
|
|
696
1058
|
}
|
|
697
1059
|
|
|
1060
|
+
interface BaiduConfig extends VectorStoreConfig {
|
|
1061
|
+
endpoint: string;
|
|
1062
|
+
account: string;
|
|
1063
|
+
apiKey: string;
|
|
1064
|
+
databaseName: string;
|
|
1065
|
+
tableName: string;
|
|
1066
|
+
embeddingModelDims: number;
|
|
1067
|
+
metricType?: "L2" | "IP" | "COSINE";
|
|
1068
|
+
client?: MochowClient;
|
|
1069
|
+
}
|
|
1070
|
+
declare class BaiduDB implements VectorStore {
|
|
1071
|
+
private client;
|
|
1072
|
+
private sdk;
|
|
1073
|
+
private readonly endpoint;
|
|
1074
|
+
private readonly account;
|
|
1075
|
+
private readonly apiKey;
|
|
1076
|
+
private readonly databaseName;
|
|
1077
|
+
private readonly tableName;
|
|
1078
|
+
private readonly embeddingModelDims;
|
|
1079
|
+
private readonly metricType;
|
|
1080
|
+
private supportsKeywordSearch;
|
|
1081
|
+
private storeUserId;
|
|
1082
|
+
private _initPromise?;
|
|
1083
|
+
constructor(config: BaiduConfig);
|
|
1084
|
+
private get ns();
|
|
1085
|
+
private loadSdk;
|
|
1086
|
+
private ensureClient;
|
|
1087
|
+
private ready;
|
|
1088
|
+
private buildSchema;
|
|
1089
|
+
private buildFilter;
|
|
1090
|
+
private filterOf;
|
|
1091
|
+
private pollTable;
|
|
1092
|
+
private ensureTable;
|
|
1093
|
+
private applySchema;
|
|
1094
|
+
initialize(): Promise<void>;
|
|
1095
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
1096
|
+
search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
1097
|
+
keywordSearch(query: string, topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[] | null>;
|
|
1098
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
1099
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
1100
|
+
delete(vectorId: string): Promise<void>;
|
|
1101
|
+
deleteCol(): Promise<void>;
|
|
1102
|
+
reset(): Promise<void>;
|
|
1103
|
+
list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
|
|
1104
|
+
getUserId(): Promise<string>;
|
|
1105
|
+
setUserId(userId: string): Promise<void>;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
698
1108
|
interface QdrantConfig extends VectorStoreConfig {
|
|
699
1109
|
/**
|
|
700
1110
|
* Pre-configured QdrantClient instance. If using Qdrant Cloud, you must pass
|
|
@@ -783,11 +1193,46 @@ declare class RedisDB implements VectorStore {
|
|
|
783
1193
|
setUserId(userId: string): Promise<void>;
|
|
784
1194
|
}
|
|
785
1195
|
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
1196
|
+
declare class ValkeyDB implements VectorStore {
|
|
1197
|
+
private client;
|
|
1198
|
+
private readonly collectionName;
|
|
1199
|
+
private readonly indexPrefix;
|
|
1200
|
+
private readonly embeddingModelDims;
|
|
1201
|
+
private readonly timezone;
|
|
1202
|
+
private readonly indexType;
|
|
1203
|
+
private readonly hnswM;
|
|
1204
|
+
private readonly hnswEfConstruction;
|
|
1205
|
+
private readonly hnswEfRuntime;
|
|
1206
|
+
private readonly clusterMode;
|
|
1207
|
+
private readonly valkeyUrl;
|
|
1208
|
+
private _initPromise?;
|
|
1209
|
+
constructor(config: ValkeyConfig);
|
|
1210
|
+
private buildIndexCreateCommand;
|
|
1211
|
+
private ensureSearchModule;
|
|
1212
|
+
private createIndex;
|
|
1213
|
+
private connectClient;
|
|
1214
|
+
initialize(): Promise<void>;
|
|
1215
|
+
private _doInitialize;
|
|
1216
|
+
private buildSearchQuery;
|
|
1217
|
+
private docToResult;
|
|
1218
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
1219
|
+
keywordSearch(): Promise<null>;
|
|
1220
|
+
search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
1221
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
1222
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
1223
|
+
delete(vectorId: string): Promise<void>;
|
|
1224
|
+
deleteCol(): Promise<void>;
|
|
1225
|
+
list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
|
|
1226
|
+
close(): Promise<void>;
|
|
1227
|
+
getUserId(): Promise<string>;
|
|
1228
|
+
setUserId(userId: string): Promise<void>;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
interface SupabaseConfig extends VectorStoreConfig {
|
|
1232
|
+
supabaseUrl: string;
|
|
1233
|
+
supabaseKey: string;
|
|
1234
|
+
tableName: string;
|
|
1235
|
+
embeddingColumnName?: string;
|
|
791
1236
|
metadataColumnName?: string;
|
|
792
1237
|
}
|
|
793
1238
|
declare class SupabaseDB implements VectorStore {
|
|
@@ -1051,6 +1496,940 @@ declare class PGVector implements VectorStore {
|
|
|
1051
1496
|
setUserId(userId: string): Promise<void>;
|
|
1052
1497
|
}
|
|
1053
1498
|
|
|
1499
|
+
interface DatabricksConfig extends VectorStoreConfig {
|
|
1500
|
+
workspaceUrl?: string;
|
|
1501
|
+
host?: string;
|
|
1502
|
+
httpPath: string;
|
|
1503
|
+
accessToken?: string;
|
|
1504
|
+
clientId?: string;
|
|
1505
|
+
clientSecret?: string;
|
|
1506
|
+
endpointName?: string;
|
|
1507
|
+
endpointType?: "STANDARD" | "STORAGE_OPTIMIZED";
|
|
1508
|
+
pipelineType?: "TRIGGERED" | "CONTINUOUS";
|
|
1509
|
+
queryType?: "ANN" | "HYBRID";
|
|
1510
|
+
catalog?: string;
|
|
1511
|
+
schema?: string;
|
|
1512
|
+
tableName?: string;
|
|
1513
|
+
embeddingModelDims?: number;
|
|
1514
|
+
syncPollIntervalMs?: number;
|
|
1515
|
+
syncTimeoutMs?: number;
|
|
1516
|
+
sqlClient?: DatabricksSqlClientLike;
|
|
1517
|
+
httpClient?: DatabricksHttpClientLike;
|
|
1518
|
+
}
|
|
1519
|
+
interface DatabricksSqlClientLike {
|
|
1520
|
+
connect(options: Record<string, any>): Promise<DatabricksSqlClientLike>;
|
|
1521
|
+
openSession(): Promise<DatabricksSqlSessionLike>;
|
|
1522
|
+
close?(): Promise<any>;
|
|
1523
|
+
}
|
|
1524
|
+
interface DatabricksSqlSessionLike {
|
|
1525
|
+
executeStatement(statement: string): Promise<DatabricksSqlOperationLike>;
|
|
1526
|
+
close?(): Promise<any>;
|
|
1527
|
+
}
|
|
1528
|
+
interface DatabricksSqlOperationLike {
|
|
1529
|
+
fetchAll(): Promise<Array<Record<string, any>>>;
|
|
1530
|
+
close?(): Promise<any>;
|
|
1531
|
+
}
|
|
1532
|
+
interface DatabricksHttpClientLike {
|
|
1533
|
+
get(url: string, config?: Record<string, any>): Promise<{
|
|
1534
|
+
data: any;
|
|
1535
|
+
}>;
|
|
1536
|
+
post(url: string, data?: any, config?: Record<string, any>): Promise<{
|
|
1537
|
+
data: any;
|
|
1538
|
+
}>;
|
|
1539
|
+
delete(url: string, config?: Record<string, any>): Promise<{
|
|
1540
|
+
data: any;
|
|
1541
|
+
}>;
|
|
1542
|
+
}
|
|
1543
|
+
declare class DatabricksVectorStore implements VectorStore {
|
|
1544
|
+
private readonly host;
|
|
1545
|
+
private readonly workspaceUrl;
|
|
1546
|
+
private readonly httpPath;
|
|
1547
|
+
private readonly accessToken?;
|
|
1548
|
+
private readonly clientId?;
|
|
1549
|
+
private readonly clientSecret?;
|
|
1550
|
+
private readonly endpointName;
|
|
1551
|
+
private readonly endpointType;
|
|
1552
|
+
private readonly pipelineType;
|
|
1553
|
+
private readonly queryType;
|
|
1554
|
+
private readonly dimension;
|
|
1555
|
+
private readonly catalog;
|
|
1556
|
+
private readonly schema;
|
|
1557
|
+
private readonly tableName;
|
|
1558
|
+
private readonly indexName;
|
|
1559
|
+
private readonly fullTableName;
|
|
1560
|
+
private readonly fullIndexName;
|
|
1561
|
+
private readonly syncPollIntervalMs;
|
|
1562
|
+
private readonly syncTimeoutMs;
|
|
1563
|
+
private sqlClient;
|
|
1564
|
+
private readonly httpClient;
|
|
1565
|
+
private session?;
|
|
1566
|
+
private _sessionPromise?;
|
|
1567
|
+
private _initPromise?;
|
|
1568
|
+
private sqlModulePromise?;
|
|
1569
|
+
private indexSyncWait;
|
|
1570
|
+
private indexSyncRunning;
|
|
1571
|
+
private indexSyncQueued;
|
|
1572
|
+
private indexSyncError;
|
|
1573
|
+
private readonly oauthTokens;
|
|
1574
|
+
constructor(config: DatabricksConfig);
|
|
1575
|
+
initialize(): Promise<void>;
|
|
1576
|
+
private _doInitialize;
|
|
1577
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
1578
|
+
search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
1579
|
+
keywordSearch(query: string, topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[] | null>;
|
|
1580
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
1581
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
1582
|
+
delete(vectorId: string): Promise<void>;
|
|
1583
|
+
deleteCol(): Promise<void>;
|
|
1584
|
+
list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
|
|
1585
|
+
getUserId(): Promise<string>;
|
|
1586
|
+
setUserId(userId: string): Promise<void>;
|
|
1587
|
+
private ensureEndpointExists;
|
|
1588
|
+
private ensureIndexExists;
|
|
1589
|
+
private ensureChangeDataFeedEnabled;
|
|
1590
|
+
private createHttpClient;
|
|
1591
|
+
private withOAuthHeaders;
|
|
1592
|
+
private getOAuthAuthorizationDetails;
|
|
1593
|
+
private getOAuthAccessToken;
|
|
1594
|
+
private getSession;
|
|
1595
|
+
/**
|
|
1596
|
+
* `@databricks/sql` is an OPTIONAL peer, and `index.ts` re-exports this module eagerly, so a
|
|
1597
|
+
* top-level `import` makes `import "mem0ai/oss"` throw MODULE_NOT_FOUND for every user who
|
|
1598
|
+
* never installed the driver -- including everyone who uses a different vector store. Load it
|
|
1599
|
+
* on the first SQL call instead, the way milvus.ts and baidu.ts load theirs.
|
|
1600
|
+
*
|
|
1601
|
+
* This MUST be a dynamic `import()`, never `require()`: tsup/esbuild rewrite `require()` in
|
|
1602
|
+
* the published ESM bundle (`dist/oss/index.mjs`) into a `__require` shim that throws
|
|
1603
|
+
* `Dynamic require of "..." is not supported`, so every ESM consumer would hit a dead
|
|
1604
|
+
* provider even with the driver installed.
|
|
1605
|
+
*/
|
|
1606
|
+
private getSqlModule;
|
|
1607
|
+
private getSqlClient;
|
|
1608
|
+
private openSession;
|
|
1609
|
+
private buildSqlConnectionOptions;
|
|
1610
|
+
/**
|
|
1611
|
+
* Drop the cached session/session-promise so the next `getSession()` opens a fresh one.
|
|
1612
|
+
* Called after any SQL failure below -- a stale session (expired token, dropped socket)
|
|
1613
|
+
* would otherwise keep being handed out and keep failing forever.
|
|
1614
|
+
*/
|
|
1615
|
+
private resetSession;
|
|
1616
|
+
private executeSql;
|
|
1617
|
+
/**
|
|
1618
|
+
* A TRIGGERED pipeline only ingests new rows when it is explicitly synced, so every write
|
|
1619
|
+
* must request one. Writers fire the sync and return; only readers wait for it to land.
|
|
1620
|
+
* A sync already in flight absorbs later writes -- deleteAll()'s N sequential deletes
|
|
1621
|
+
* collapse into far fewer than N pipeline runs.
|
|
1622
|
+
*/
|
|
1623
|
+
private requestIndexSync;
|
|
1624
|
+
private drainIndexSync;
|
|
1625
|
+
private awaitIndexSync;
|
|
1626
|
+
private waitForEndpointReadiness;
|
|
1627
|
+
private waitForIndexReadiness;
|
|
1628
|
+
private shouldPaginateForLocalFiltering;
|
|
1629
|
+
private extractNextPageToken;
|
|
1630
|
+
private queryIndex;
|
|
1631
|
+
private normalizeQueryResults;
|
|
1632
|
+
private rowToObject;
|
|
1633
|
+
private parsePayload;
|
|
1634
|
+
private extractSessionValues;
|
|
1635
|
+
private assertVectorDimension;
|
|
1636
|
+
private matchFieldCondition;
|
|
1637
|
+
private filterVector;
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
/**
|
|
1641
|
+
* The `@aws-sdk/client-neptune-graph` dependency is loaded on first use via dynamic
|
|
1642
|
+
* `import()` so the package stays optional (mirrors `aws_bedrock.ts`).
|
|
1643
|
+
*/
|
|
1644
|
+
interface NeptuneAnalyticsConfig extends VectorStoreConfig {
|
|
1645
|
+
graphIdentifier?: string;
|
|
1646
|
+
endpoint?: string;
|
|
1647
|
+
collectionName: string;
|
|
1648
|
+
dimension?: number;
|
|
1649
|
+
client?: NeptuneGraphClientLike;
|
|
1650
|
+
}
|
|
1651
|
+
interface NeptuneGraphClientLike {
|
|
1652
|
+
send(command: any): Promise<NeptuneExecuteQueryOutput>;
|
|
1653
|
+
}
|
|
1654
|
+
interface NeptuneExecuteQueryOutput {
|
|
1655
|
+
payload?: {
|
|
1656
|
+
transformToString(encoding?: string): Promise<string>;
|
|
1657
|
+
};
|
|
1658
|
+
}
|
|
1659
|
+
declare class NeptuneAnalyticsVectorStore implements VectorStore {
|
|
1660
|
+
private clientConfig;
|
|
1661
|
+
private clientOverride?;
|
|
1662
|
+
private sdkPromise?;
|
|
1663
|
+
private clientPromise?;
|
|
1664
|
+
private readonly graphIdentifier;
|
|
1665
|
+
private readonly collectionName;
|
|
1666
|
+
private readonly collectionLabel;
|
|
1667
|
+
private readonly collectionLabelExpr;
|
|
1668
|
+
private readonly userLabel;
|
|
1669
|
+
private readonly userLabelExpr;
|
|
1670
|
+
private readonly userNodeId;
|
|
1671
|
+
private readonly dimension;
|
|
1672
|
+
private _initPromise?;
|
|
1673
|
+
private cachedUserId?;
|
|
1674
|
+
constructor(config: NeptuneAnalyticsConfig);
|
|
1675
|
+
initialize(): Promise<void>;
|
|
1676
|
+
private _doInitialize;
|
|
1677
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
1678
|
+
keywordSearch(): Promise<null>;
|
|
1679
|
+
search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
1680
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
1681
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
1682
|
+
delete(vectorId: string): Promise<void>;
|
|
1683
|
+
deleteCol(): Promise<void>;
|
|
1684
|
+
list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
|
|
1685
|
+
getUserId(): Promise<string>;
|
|
1686
|
+
setUserId(userId: string): Promise<void>;
|
|
1687
|
+
private findExistingIds;
|
|
1688
|
+
private cleanupFailedInsert;
|
|
1689
|
+
private resolveGraphIdentifier;
|
|
1690
|
+
private buildClientConfig;
|
|
1691
|
+
private escapeLabel;
|
|
1692
|
+
private buildStoredPayload;
|
|
1693
|
+
private buildVertexFilter;
|
|
1694
|
+
private buildMetadataVertexFilter;
|
|
1695
|
+
private combineVertexFilters;
|
|
1696
|
+
private buildFieldVertexFilter;
|
|
1697
|
+
private buildSingleVertexFilter;
|
|
1698
|
+
private negateVertexFilter;
|
|
1699
|
+
private buildWhereClause;
|
|
1700
|
+
private buildFieldWhereClauses;
|
|
1701
|
+
private escapeProperty;
|
|
1702
|
+
private serializeAlgorithmInput;
|
|
1703
|
+
private serializeAlgorithmKey;
|
|
1704
|
+
private assertVectorDimension;
|
|
1705
|
+
private assertBatchDimensions;
|
|
1706
|
+
private normalizeNodeResult;
|
|
1707
|
+
private normalizeSearchResult;
|
|
1708
|
+
private extractNode;
|
|
1709
|
+
private extractPayload;
|
|
1710
|
+
private extractId;
|
|
1711
|
+
private extractUserId;
|
|
1712
|
+
private normalizePayload;
|
|
1713
|
+
private normalizeScore;
|
|
1714
|
+
private assertSuccessfulResults;
|
|
1715
|
+
/**
|
|
1716
|
+
* Load the optional AWS SDK on first use.
|
|
1717
|
+
*
|
|
1718
|
+
* This MUST be a dynamic `import()`, never `require()`: tsup/esbuild rewrite
|
|
1719
|
+
* `require()` in the published ESM bundle (`dist/oss/index.mjs`) into a
|
|
1720
|
+
* `__require` shim that throws `Dynamic require of "..." is not supported`,
|
|
1721
|
+
* so every ESM consumer would hit a dead provider even with the SDK installed.
|
|
1722
|
+
*/
|
|
1723
|
+
private getSDK;
|
|
1724
|
+
/** Memoized Neptune client; an injected `config.client` short-circuits the SDK. */
|
|
1725
|
+
private getClient;
|
|
1726
|
+
private executeQuery;
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
interface ElasticsearchConfig extends VectorStoreConfig {
|
|
1730
|
+
/** Pre-configured Elasticsearch client instance (typed as `any` to keep the
|
|
1731
|
+
* optional driver's types out of the published type declarations). */
|
|
1732
|
+
client?: any;
|
|
1733
|
+
host?: string;
|
|
1734
|
+
port?: number;
|
|
1735
|
+
cloudId?: string;
|
|
1736
|
+
apiKey?: string;
|
|
1737
|
+
username?: string;
|
|
1738
|
+
password?: string;
|
|
1739
|
+
collectionName: string;
|
|
1740
|
+
embeddingModelDims: number;
|
|
1741
|
+
dimension?: number;
|
|
1742
|
+
useSsl?: boolean;
|
|
1743
|
+
caCerts?: string;
|
|
1744
|
+
verifyCerts?: boolean;
|
|
1745
|
+
autoCreateIndex?: boolean;
|
|
1746
|
+
headers?: Record<string, string>;
|
|
1747
|
+
}
|
|
1748
|
+
declare class ElasticsearchDB implements VectorStore {
|
|
1749
|
+
private client;
|
|
1750
|
+
private readonly config;
|
|
1751
|
+
private readonly collectionName;
|
|
1752
|
+
private readonly dimension;
|
|
1753
|
+
private readonly autoCreateIndex;
|
|
1754
|
+
private _initPromise?;
|
|
1755
|
+
constructor(config: ElasticsearchConfig);
|
|
1756
|
+
private ensureClient;
|
|
1757
|
+
initialize(): Promise<void>;
|
|
1758
|
+
private _doInitialize;
|
|
1759
|
+
private ensureIndex;
|
|
1760
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
1761
|
+
search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
1762
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
1763
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
1764
|
+
delete(vectorId: string): Promise<void>;
|
|
1765
|
+
deleteCol(): Promise<void>;
|
|
1766
|
+
list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
|
|
1767
|
+
private generateUUID;
|
|
1768
|
+
getUserId(): Promise<string>;
|
|
1769
|
+
setUserId(userId: string): Promise<void>;
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
interface UpstashVectorConfig extends VectorStoreConfig {
|
|
1773
|
+
collectionName: string;
|
|
1774
|
+
url?: string;
|
|
1775
|
+
token?: string;
|
|
1776
|
+
/** Pre-configured Upstash Vector client instance (typed as `any` to keep
|
|
1777
|
+
* the optional driver's types out of the published type declarations). */
|
|
1778
|
+
client?: any;
|
|
1779
|
+
}
|
|
1780
|
+
declare class UpstashVector implements VectorStore {
|
|
1781
|
+
private client;
|
|
1782
|
+
private readonly config;
|
|
1783
|
+
private readonly collectionName;
|
|
1784
|
+
constructor(config: UpstashVectorConfig);
|
|
1785
|
+
/**
|
|
1786
|
+
* Lazily construct (or reuse) the Upstash Vector client, importing the
|
|
1787
|
+
* optional `@upstash/vector` peer only when the store is first used so
|
|
1788
|
+
* consumers that never touch Upstash Vector don't need it installed.
|
|
1789
|
+
*/
|
|
1790
|
+
private ensureClient;
|
|
1791
|
+
initialize(): Promise<void>;
|
|
1792
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
1793
|
+
search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
1794
|
+
keywordSearch(query: string, topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[] | null>;
|
|
1795
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
1796
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
1797
|
+
delete(vectorId: string): Promise<void>;
|
|
1798
|
+
deleteCol(): Promise<void>;
|
|
1799
|
+
list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
|
|
1800
|
+
getUserId(): Promise<string>;
|
|
1801
|
+
setUserId(): Promise<void>;
|
|
1802
|
+
reset(): Promise<void>;
|
|
1803
|
+
private parseResult;
|
|
1804
|
+
private stringifyFilterValue;
|
|
1805
|
+
private convertFilters;
|
|
1806
|
+
private matchesFilters;
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
interface AzureMySQLConfig extends VectorStoreConfig {
|
|
1810
|
+
host: string;
|
|
1811
|
+
port?: number;
|
|
1812
|
+
user: string;
|
|
1813
|
+
password?: string;
|
|
1814
|
+
database: string;
|
|
1815
|
+
collectionName: string;
|
|
1816
|
+
embeddingModelDims: number;
|
|
1817
|
+
useAzureCredential?: boolean;
|
|
1818
|
+
sslCa?: string;
|
|
1819
|
+
sslDisabled?: boolean;
|
|
1820
|
+
maxConn?: number;
|
|
1821
|
+
}
|
|
1822
|
+
declare class AzureMySQLDB implements VectorStore {
|
|
1823
|
+
private pool?;
|
|
1824
|
+
private readonly collectionName;
|
|
1825
|
+
private readonly config;
|
|
1826
|
+
private _initPromise?;
|
|
1827
|
+
constructor(config: AzureMySQLConfig);
|
|
1828
|
+
private col;
|
|
1829
|
+
initialize(): Promise<void>;
|
|
1830
|
+
private _doInitialize;
|
|
1831
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
1832
|
+
search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
1833
|
+
keywordSearch(query: string, topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[] | null>;
|
|
1834
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
1835
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
1836
|
+
delete(vectorId: string): Promise<void>;
|
|
1837
|
+
deleteCol(): Promise<void>;
|
|
1838
|
+
list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
|
|
1839
|
+
getUserId(): Promise<string>;
|
|
1840
|
+
setUserId(userId: string): Promise<void>;
|
|
1841
|
+
close(): Promise<void>;
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
interface CassandraConfig extends VectorStoreConfig {
|
|
1845
|
+
contactPoints?: string[];
|
|
1846
|
+
port?: number;
|
|
1847
|
+
username?: string;
|
|
1848
|
+
password?: string;
|
|
1849
|
+
keyspace?: string;
|
|
1850
|
+
collectionName?: string;
|
|
1851
|
+
embeddingModelDims?: number;
|
|
1852
|
+
secureConnectBundle?: string;
|
|
1853
|
+
localDataCenter?: string;
|
|
1854
|
+
protocolVersion?: number;
|
|
1855
|
+
loadBalancingPolicy?: any;
|
|
1856
|
+
client?: CassandraClientLike;
|
|
1857
|
+
/** Pre-configured Cassandra driver module (typed as `any` to keep the
|
|
1858
|
+
* optional driver's types out of the published type declarations). */
|
|
1859
|
+
driver?: any;
|
|
1860
|
+
}
|
|
1861
|
+
interface CassandraClientLike {
|
|
1862
|
+
connect?(): Promise<void>;
|
|
1863
|
+
execute(query: string, params?: any[], options?: Record<string, any>): Promise<{
|
|
1864
|
+
rows?: any[];
|
|
1865
|
+
pageState?: string | null;
|
|
1866
|
+
}>;
|
|
1867
|
+
}
|
|
1868
|
+
declare class CassandraDB implements VectorStore {
|
|
1869
|
+
private static readonly PAGE_SIZE;
|
|
1870
|
+
private readonly driver?;
|
|
1871
|
+
private readonly contactPoints?;
|
|
1872
|
+
private readonly port;
|
|
1873
|
+
private readonly username?;
|
|
1874
|
+
private readonly password?;
|
|
1875
|
+
private readonly keyspace;
|
|
1876
|
+
private readonly collectionName;
|
|
1877
|
+
private readonly dimension;
|
|
1878
|
+
private readonly secureConnectBundle?;
|
|
1879
|
+
private readonly localDataCenter?;
|
|
1880
|
+
private readonly protocolVersion?;
|
|
1881
|
+
private readonly loadBalancingPolicy?;
|
|
1882
|
+
private client?;
|
|
1883
|
+
private _initPromise?;
|
|
1884
|
+
constructor(config: CassandraConfig);
|
|
1885
|
+
initialize(): Promise<void>;
|
|
1886
|
+
private _doInitialize;
|
|
1887
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
1888
|
+
keywordSearch(): Promise<null>;
|
|
1889
|
+
search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
1890
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
1891
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
1892
|
+
delete(vectorId: string): Promise<void>;
|
|
1893
|
+
deleteCol(): Promise<void>;
|
|
1894
|
+
list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
|
|
1895
|
+
getUserId(): Promise<string>;
|
|
1896
|
+
setUserId(userId: string): Promise<void>;
|
|
1897
|
+
private createClient;
|
|
1898
|
+
private loadDriver;
|
|
1899
|
+
private validateIdentifier;
|
|
1900
|
+
private cosineSimilarity;
|
|
1901
|
+
private normalizeVector;
|
|
1902
|
+
private parsePayload;
|
|
1903
|
+
private matchFieldCondition;
|
|
1904
|
+
private filterVector;
|
|
1905
|
+
private assertVectorDimension;
|
|
1906
|
+
private assertBatchDimensions;
|
|
1907
|
+
private scanRows;
|
|
1908
|
+
private pushTopResult;
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
interface S3VectorsConfig extends VectorStoreConfig {
|
|
1912
|
+
vectorBucketName: string;
|
|
1913
|
+
collectionName: string;
|
|
1914
|
+
embeddingModelDims?: number;
|
|
1915
|
+
dimension?: number;
|
|
1916
|
+
distanceMetric?: "cosine" | "euclidean";
|
|
1917
|
+
region?: string;
|
|
1918
|
+
regionName?: string;
|
|
1919
|
+
client?: S3VectorsClientLike;
|
|
1920
|
+
/** Pre-configured S3 Vectors client options (typed as `any` to keep the
|
|
1921
|
+
* optional SDK's types out of the published type declarations). */
|
|
1922
|
+
clientConfig?: any;
|
|
1923
|
+
}
|
|
1924
|
+
interface S3VectorsClientLike {
|
|
1925
|
+
send(command: any): Promise<any>;
|
|
1926
|
+
}
|
|
1927
|
+
declare class S3Vectors implements VectorStore {
|
|
1928
|
+
private readonly config;
|
|
1929
|
+
private readonly vectorBucketName;
|
|
1930
|
+
private readonly collectionName;
|
|
1931
|
+
private readonly dimension;
|
|
1932
|
+
private readonly distanceMetric;
|
|
1933
|
+
private client?;
|
|
1934
|
+
private clientPromise?;
|
|
1935
|
+
private sdkPromise?;
|
|
1936
|
+
private _initPromise?;
|
|
1937
|
+
private cachedUserId?;
|
|
1938
|
+
constructor(config: S3VectorsConfig);
|
|
1939
|
+
/**
|
|
1940
|
+
* Lazily import the optional `@aws-sdk/client-s3vectors` peer so consumers
|
|
1941
|
+
* who never use the S3 Vectors store don't need it installed.
|
|
1942
|
+
*/
|
|
1943
|
+
private getSdk;
|
|
1944
|
+
/** Lazily construct (or reuse) the S3 Vectors client. */
|
|
1945
|
+
private getClient;
|
|
1946
|
+
private createClient;
|
|
1947
|
+
initialize(): Promise<void>;
|
|
1948
|
+
private _doInitialize;
|
|
1949
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
1950
|
+
keywordSearch(): Promise<null>;
|
|
1951
|
+
search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
1952
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
1953
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
1954
|
+
delete(vectorId: string): Promise<void>;
|
|
1955
|
+
deleteCol(): Promise<void>;
|
|
1956
|
+
list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
|
|
1957
|
+
getUserId(): Promise<string>;
|
|
1958
|
+
setUserId(userId: string): Promise<void>;
|
|
1959
|
+
private ensureBucketExists;
|
|
1960
|
+
private ensureIndexExists;
|
|
1961
|
+
private ensureMigrationIndex;
|
|
1962
|
+
private fetchStoredVector;
|
|
1963
|
+
private convertFilters;
|
|
1964
|
+
private convertFilterNode;
|
|
1965
|
+
private convertFieldFilter;
|
|
1966
|
+
private negateFilter;
|
|
1967
|
+
private matchesFilter;
|
|
1968
|
+
private matchesFieldFilter;
|
|
1969
|
+
private evaluateOperator;
|
|
1970
|
+
private toVectorData;
|
|
1971
|
+
private fromVectorData;
|
|
1972
|
+
private normalizeMetadata;
|
|
1973
|
+
private normalizeQueryVector;
|
|
1974
|
+
private normalizeStoredVector;
|
|
1975
|
+
private normalizeListedVector;
|
|
1976
|
+
private normalizeScore;
|
|
1977
|
+
private assertVectorDimension;
|
|
1978
|
+
private assertBatchDimensions;
|
|
1979
|
+
private isNotFound;
|
|
1980
|
+
private isConflict;
|
|
1981
|
+
private isAlwaysFalseFilter;
|
|
1982
|
+
private isNoOpFilter;
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
interface GoogleMatchingEngineConfig extends VectorStoreConfig {
|
|
1986
|
+
projectId: string;
|
|
1987
|
+
projectNumber: string;
|
|
1988
|
+
region: string;
|
|
1989
|
+
endpointId: string;
|
|
1990
|
+
indexId: string;
|
|
1991
|
+
deploymentIndexId: string;
|
|
1992
|
+
collectionName?: string;
|
|
1993
|
+
credentialsPath?: string;
|
|
1994
|
+
serviceAccountJson?: Record<string, any>;
|
|
1995
|
+
vectorSearchApiEndpoint?: string;
|
|
1996
|
+
}
|
|
1997
|
+
declare class VertexAIVectorSearch implements VectorStore {
|
|
1998
|
+
private config;
|
|
1999
|
+
private matchClient;
|
|
2000
|
+
private indexClient;
|
|
2001
|
+
private _initPromise?;
|
|
2002
|
+
constructor(config: GoogleMatchingEngineConfig);
|
|
2003
|
+
initialize(): Promise<void>;
|
|
2004
|
+
private _doInitialize;
|
|
2005
|
+
private _createRestriction;
|
|
2006
|
+
private _createDatapoint;
|
|
2007
|
+
private get indexPath();
|
|
2008
|
+
private get indexEndpointPath();
|
|
2009
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
2010
|
+
search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
2011
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
2012
|
+
keywordSearch(query: string, topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[] | null>;
|
|
2013
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
2014
|
+
delete(vectorId: string): Promise<void>;
|
|
2015
|
+
deleteCol(): Promise<void>;
|
|
2016
|
+
list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
|
|
2017
|
+
getUserId(): Promise<string>;
|
|
2018
|
+
setUserId(userId: string): Promise<void>;
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
interface PineconeDBConfig extends VectorStoreConfig {
|
|
2022
|
+
collectionName: string;
|
|
2023
|
+
embeddingModelDims: number;
|
|
2024
|
+
/** Pre-configured Pinecone client instance (typed as `any` to keep the
|
|
2025
|
+
* optional driver's types out of the published type declarations). */
|
|
2026
|
+
client?: any;
|
|
2027
|
+
apiKey?: string;
|
|
2028
|
+
serverlessConfig?: {
|
|
2029
|
+
cloud: string;
|
|
2030
|
+
region: string;
|
|
2031
|
+
};
|
|
2032
|
+
podConfig?: {
|
|
2033
|
+
environment: string;
|
|
2034
|
+
podType?: string;
|
|
2035
|
+
pods?: number;
|
|
2036
|
+
replicas?: number;
|
|
2037
|
+
shards?: number;
|
|
2038
|
+
};
|
|
2039
|
+
metric?: "cosine" | "dotproduct" | "euclidean";
|
|
2040
|
+
batchSize?: number;
|
|
2041
|
+
namespace?: string;
|
|
2042
|
+
extraParams?: Record<string, any>;
|
|
2043
|
+
}
|
|
2044
|
+
declare class PineconeDB implements VectorStore {
|
|
2045
|
+
private client;
|
|
2046
|
+
private readonly config;
|
|
2047
|
+
private readonly collectionName;
|
|
2048
|
+
private readonly dimension;
|
|
2049
|
+
private readonly metric;
|
|
2050
|
+
private readonly batchSize;
|
|
2051
|
+
private readonly namespace;
|
|
2052
|
+
private readonly serverlessConfig?;
|
|
2053
|
+
private readonly podConfig?;
|
|
2054
|
+
private readonly extraParams;
|
|
2055
|
+
private _index?;
|
|
2056
|
+
private _initPromise?;
|
|
2057
|
+
constructor(config: PineconeDBConfig);
|
|
2058
|
+
/**
|
|
2059
|
+
* Lazily construct (or reuse) the Pinecone client, importing the optional
|
|
2060
|
+
* `@pinecone-database/pinecone` peer only when the store is first used so
|
|
2061
|
+
* consumers that never touch Pinecone don't need it installed.
|
|
2062
|
+
*/
|
|
2063
|
+
private ensureClient;
|
|
2064
|
+
initialize(): Promise<void>;
|
|
2065
|
+
private _doInitialize;
|
|
2066
|
+
private _ensureIndex;
|
|
2067
|
+
private index;
|
|
2068
|
+
private namespacedIndex;
|
|
2069
|
+
private migrationsIndex;
|
|
2070
|
+
private createFilter;
|
|
2071
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
2072
|
+
keywordSearch(_query: string, _topK?: number, _filters?: SearchFilters): Promise<VectorStoreResult[] | null>;
|
|
2073
|
+
search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
2074
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
2075
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
2076
|
+
delete(vectorId: string): Promise<void>;
|
|
2077
|
+
deleteCol(): Promise<void>;
|
|
2078
|
+
list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
|
|
2079
|
+
getUserId(): Promise<string>;
|
|
2080
|
+
setUserId(userId: string): Promise<void>;
|
|
2081
|
+
}
|
|
2082
|
+
|
|
2083
|
+
interface TurbopufferConfig extends VectorStoreConfig {
|
|
2084
|
+
apiKey?: string;
|
|
2085
|
+
region?: string;
|
|
2086
|
+
collectionName: string;
|
|
2087
|
+
distanceMetric?: string;
|
|
2088
|
+
batchSize?: number;
|
|
2089
|
+
}
|
|
2090
|
+
declare class TurbopufferDB implements VectorStore {
|
|
2091
|
+
private clientInstance?;
|
|
2092
|
+
private clientPromise?;
|
|
2093
|
+
private readonly apiKey;
|
|
2094
|
+
private readonly region;
|
|
2095
|
+
private readonly collectionName;
|
|
2096
|
+
private readonly distanceMetric;
|
|
2097
|
+
private readonly batchSize;
|
|
2098
|
+
constructor(config: TurbopufferConfig);
|
|
2099
|
+
/**
|
|
2100
|
+
* Lazily construct (or reuse) the Turbopuffer client, importing the optional
|
|
2101
|
+
* `@turbopuffer/turbopuffer` peer only when the store is first used so
|
|
2102
|
+
* consumers that never touch Turbopuffer don't need it installed.
|
|
2103
|
+
*/
|
|
2104
|
+
private getClient;
|
|
2105
|
+
private createClient;
|
|
2106
|
+
private getNs;
|
|
2107
|
+
private getMigrationsNs;
|
|
2108
|
+
initialize(): Promise<void>;
|
|
2109
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
2110
|
+
search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
2111
|
+
keywordSearch(): Promise<null>;
|
|
2112
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
2113
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
2114
|
+
delete(vectorId: string): Promise<void>;
|
|
2115
|
+
deleteCol(): Promise<void>;
|
|
2116
|
+
list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
|
|
2117
|
+
getUserId(): Promise<string>;
|
|
2118
|
+
setUserId(userId: string): Promise<void>;
|
|
2119
|
+
private convertFilters;
|
|
2120
|
+
private parseRows;
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2123
|
+
/**
|
|
2124
|
+
* Supported Milvus metric types. Mirrors the Python provider
|
|
2125
|
+
* (`mem0/configs/vector_stores/milvus.py`).
|
|
2126
|
+
*/
|
|
2127
|
+
type MilvusMetricType = "L2" | "IP" | "COSINE" | "HAMMING" | "JACCARD";
|
|
2128
|
+
interface MilvusConfig extends VectorStoreConfig {
|
|
2129
|
+
/**
|
|
2130
|
+
* Full URL/address for the Milvus or Zilliz server.
|
|
2131
|
+
* Defaults to `http://localhost:19530`.
|
|
2132
|
+
*/
|
|
2133
|
+
url?: string;
|
|
2134
|
+
/** Token / API key for Zilliz Cloud. Optional for a local setup. */
|
|
2135
|
+
token?: string;
|
|
2136
|
+
/** Name of the database. Optional (Milvus default database when empty). */
|
|
2137
|
+
dbName?: string;
|
|
2138
|
+
/** Collection name. Defaults to `mem0`. */
|
|
2139
|
+
collectionName?: string;
|
|
2140
|
+
/** Embedding dimensionality. Defaults to 1536 (OpenAI). */
|
|
2141
|
+
embeddingModelDims?: number;
|
|
2142
|
+
dimension?: number;
|
|
2143
|
+
/** Similarity metric. Defaults to `L2` (matches the Python provider). */
|
|
2144
|
+
metricType?: MilvusMetricType;
|
|
2145
|
+
/**
|
|
2146
|
+
* Pre-constructed `MilvusClient` instance. When provided, `url`/`token`/`dbName`
|
|
2147
|
+
* are ignored. Primarily useful for dependency injection in tests.
|
|
2148
|
+
*/
|
|
2149
|
+
client?: any;
|
|
2150
|
+
}
|
|
2151
|
+
/**
|
|
2152
|
+
* Milvus vector store provider for the TypeScript OSS SDK.
|
|
2153
|
+
*
|
|
2154
|
+
* Mirrors the Python provider in `mem0/vector_stores/milvus.py`: dense-vector
|
|
2155
|
+
* CRUD (insert / search / get / update / delete / list + user-id helpers) plus
|
|
2156
|
+
* BM25 hybrid keyword search. New collections are created with a `text` +
|
|
2157
|
+
* `sparse` field pair and a BM25 function so `keywordSearch` can run full-text
|
|
2158
|
+
* search; collections created before BM25 support keep working with it disabled.
|
|
2159
|
+
*
|
|
2160
|
+
* The `@zilliz/milvus2-sdk-node` dependency is lazily required so the package
|
|
2161
|
+
* remains optional. Importing this module never forces the SDK to be installed
|
|
2162
|
+
* until a Milvus store is actually constructed.
|
|
2163
|
+
*/
|
|
2164
|
+
declare class Milvus implements VectorStore {
|
|
2165
|
+
private client;
|
|
2166
|
+
private readonly collectionName;
|
|
2167
|
+
private readonly dimension;
|
|
2168
|
+
private readonly metricType;
|
|
2169
|
+
private _initPromise?;
|
|
2170
|
+
private DataType;
|
|
2171
|
+
private FunctionType;
|
|
2172
|
+
private hasBm25Schema;
|
|
2173
|
+
constructor(config: MilvusConfig);
|
|
2174
|
+
initialize(): Promise<void>;
|
|
2175
|
+
/**
|
|
2176
|
+
* Create the collection if it does not already exist, with an AUTOINDEX
|
|
2177
|
+
* dense-vector index plus a BM25 `text` -> `sparse` full-text index. Idempotent
|
|
2178
|
+
* (mirrors the Python `create_col`). When the collection already exists, detect
|
|
2179
|
+
* whether the BM25 `text`/`sparse` fields are present so keyword search
|
|
2180
|
+
* degrades gracefully on collections created before BM25 support.
|
|
2181
|
+
*/
|
|
2182
|
+
private createCol;
|
|
2183
|
+
/**
|
|
2184
|
+
* Filter keys are interpolated straight into the expression, so restrict them
|
|
2185
|
+
* to safe identifiers (same rule as the Python provider) to block injection.
|
|
2186
|
+
*/
|
|
2187
|
+
private static readonly SAFE_FILTER_KEY;
|
|
2188
|
+
/**
|
|
2189
|
+
* Build a Milvus boolean filter expression from a flat filters object.
|
|
2190
|
+
* Mirrors the Python `_create_filter` (equality only, AND-combined): validate
|
|
2191
|
+
* each key, escape string values (backslash first, then double-quote), and
|
|
2192
|
+
* reject value types Milvus can't compare against a scalar field.
|
|
2193
|
+
*/
|
|
2194
|
+
private createFilter;
|
|
2195
|
+
/**
|
|
2196
|
+
* Text fed to the BM25 sparse index for a payload. Prefers the lemmatized
|
|
2197
|
+
* text, falls back to the raw memory `data`, and truncates to the VarChar
|
|
2198
|
+
* limit (mirrors the Python provider).
|
|
2199
|
+
*/
|
|
2200
|
+
private bm25Text;
|
|
2201
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
2202
|
+
/**
|
|
2203
|
+
* Map raw Milvus search hits to VectorStoreResult. For the L2 metric,
|
|
2204
|
+
* distances are unbounded and smaller-is-better, so normalise them to a 0..1
|
|
2205
|
+
* similarity; every other metric passes the raw score through. Shared by
|
|
2206
|
+
* search and keywordSearch so both match the Python provider's `_parse_output`
|
|
2207
|
+
* (which likewise normalises by metric type regardless of dense vs BM25 score).
|
|
2208
|
+
*/
|
|
2209
|
+
private parseHits;
|
|
2210
|
+
search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
2211
|
+
/**
|
|
2212
|
+
* BM25 full-text keyword search over the sparse field. Milvus tokenizes the
|
|
2213
|
+
* raw query string via the collection's BM25 function. Returns null when the
|
|
2214
|
+
* collection has no BM25 schema so callers fall back to dense search only
|
|
2215
|
+
* (mirrors the Python provider).
|
|
2216
|
+
*/
|
|
2217
|
+
keywordSearch(query: string, topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[] | null>;
|
|
2218
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
2219
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
2220
|
+
delete(vectorId: string): Promise<void>;
|
|
2221
|
+
deleteCol(): Promise<void>;
|
|
2222
|
+
list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
|
|
2223
|
+
private generateUUID;
|
|
2224
|
+
private ensureMigrationsCol;
|
|
2225
|
+
getUserId(): Promise<string>;
|
|
2226
|
+
setUserId(userId: string): Promise<void>;
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2229
|
+
interface MongoDBConfig extends VectorStoreConfig {
|
|
2230
|
+
url?: string;
|
|
2231
|
+
dbName?: string;
|
|
2232
|
+
collectionName?: string;
|
|
2233
|
+
embeddingModelDims?: number;
|
|
2234
|
+
dimension?: number;
|
|
2235
|
+
/** Pre-configured MongoDB client instance (typed as `any` to keep the
|
|
2236
|
+
* optional driver's types out of the published type declarations). */
|
|
2237
|
+
client?: any;
|
|
2238
|
+
}
|
|
2239
|
+
declare class MongoDB implements VectorStore {
|
|
2240
|
+
private client;
|
|
2241
|
+
private db;
|
|
2242
|
+
private collection;
|
|
2243
|
+
private readonly config;
|
|
2244
|
+
private readonly collectionName;
|
|
2245
|
+
private readonly dbName;
|
|
2246
|
+
private readonly embeddingModelDims;
|
|
2247
|
+
private readonly indexName;
|
|
2248
|
+
private _initPromise?;
|
|
2249
|
+
constructor(config: MongoDBConfig);
|
|
2250
|
+
private ensureClient;
|
|
2251
|
+
initialize(): Promise<void>;
|
|
2252
|
+
private _doInitialize;
|
|
2253
|
+
private validateFilterValue;
|
|
2254
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
2255
|
+
search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
2256
|
+
keywordSearch(query: string, topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[] | null>;
|
|
2257
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
2258
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
2259
|
+
delete(vectorId: string): Promise<void>;
|
|
2260
|
+
deleteCol(): Promise<void>;
|
|
2261
|
+
list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
|
|
2262
|
+
getUserId(): Promise<string>;
|
|
2263
|
+
setUserId(userId: string): Promise<void>;
|
|
2264
|
+
close(): Promise<void>;
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
type OpenSearchAuth = {
|
|
2268
|
+
username?: string;
|
|
2269
|
+
password?: string;
|
|
2270
|
+
} | {
|
|
2271
|
+
user?: string;
|
|
2272
|
+
password?: string;
|
|
2273
|
+
} | Record<string, any>;
|
|
2274
|
+
interface OpenSearchConfig extends VectorStoreConfig {
|
|
2275
|
+
/** Pre-configured OpenSearch client instance (typed as `any` to keep the
|
|
2276
|
+
* optional driver's types out of the published type declarations). */
|
|
2277
|
+
client?: any;
|
|
2278
|
+
host?: string;
|
|
2279
|
+
port?: number;
|
|
2280
|
+
httpAuth?: OpenSearchAuth | [string, string];
|
|
2281
|
+
user?: string;
|
|
2282
|
+
password?: string;
|
|
2283
|
+
useSSL?: boolean;
|
|
2284
|
+
verifyCerts?: boolean;
|
|
2285
|
+
collectionName: string;
|
|
2286
|
+
embeddingModelDims: number;
|
|
2287
|
+
autoRefresh?: boolean;
|
|
2288
|
+
}
|
|
2289
|
+
declare class OpenSearchDB implements VectorStore {
|
|
2290
|
+
private client;
|
|
2291
|
+
private readonly config;
|
|
2292
|
+
private readonly collectionName;
|
|
2293
|
+
private readonly embeddingModelDims;
|
|
2294
|
+
private readonly autoRefresh;
|
|
2295
|
+
private _initPromise?;
|
|
2296
|
+
constructor(config: OpenSearchConfig);
|
|
2297
|
+
private ensureClient;
|
|
2298
|
+
initialize(): Promise<void>;
|
|
2299
|
+
private _doInitialize;
|
|
2300
|
+
private normalizeAuth;
|
|
2301
|
+
private indexExists;
|
|
2302
|
+
private createCol;
|
|
2303
|
+
private ensureMigrationIndex;
|
|
2304
|
+
private validateVector;
|
|
2305
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
2306
|
+
keywordSearch(query: string, topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[] | null>;
|
|
2307
|
+
search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
2308
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
2309
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
2310
|
+
delete(vectorId: string): Promise<void>;
|
|
2311
|
+
deleteCol(): Promise<void>;
|
|
2312
|
+
list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
|
|
2313
|
+
reset(): Promise<void>;
|
|
2314
|
+
getUserId(): Promise<string>;
|
|
2315
|
+
setUserId(userId: string): Promise<void>;
|
|
2316
|
+
private hitToResult;
|
|
2317
|
+
private buildFilterClauses;
|
|
2318
|
+
private buildFilterClause;
|
|
2319
|
+
private buildOperatorClause;
|
|
2320
|
+
private payloadField;
|
|
2321
|
+
private assertScalarValue;
|
|
2322
|
+
private assertScalarArray;
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2325
|
+
interface WeaviateConfig extends VectorStoreConfig {
|
|
2326
|
+
/** Pre-configured Weaviate client instance (typed as `any` to keep the
|
|
2327
|
+
* optional driver's types out of the published type declarations). */
|
|
2328
|
+
client?: any;
|
|
2329
|
+
clusterUrl?: string;
|
|
2330
|
+
apiKey?: string;
|
|
2331
|
+
additionalHeaders?: Record<string, string>;
|
|
2332
|
+
collectionName: string;
|
|
2333
|
+
embeddingModelDims: number;
|
|
2334
|
+
}
|
|
2335
|
+
declare class WeaviateDB implements VectorStore {
|
|
2336
|
+
private _config;
|
|
2337
|
+
private _client;
|
|
2338
|
+
private _sdk;
|
|
2339
|
+
private _col;
|
|
2340
|
+
private _userId;
|
|
2341
|
+
private _initPromise?;
|
|
2342
|
+
constructor(config: WeaviateConfig);
|
|
2343
|
+
initialize(): Promise<void>;
|
|
2344
|
+
private ensureClient;
|
|
2345
|
+
private _doInitialize;
|
|
2346
|
+
private _buildFilters;
|
|
2347
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
2348
|
+
search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
2349
|
+
keywordSearch(query: string, topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[] | null>;
|
|
2350
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
2351
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
2352
|
+
delete(vectorId: string): Promise<void>;
|
|
2353
|
+
deleteCol(): Promise<void>;
|
|
2354
|
+
list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
|
|
2355
|
+
getUserId(): Promise<string>;
|
|
2356
|
+
setUserId(userId: string): Promise<void>;
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
interface RerankResult {
|
|
2360
|
+
/** Index into the input `documents` array. */
|
|
2361
|
+
index: number;
|
|
2362
|
+
/** Relevance of the document to the query, 0..1, higher = more relevant. */
|
|
2363
|
+
rerankScore: number;
|
|
2364
|
+
}
|
|
2365
|
+
interface Reranker {
|
|
2366
|
+
/**
|
|
2367
|
+
* Rank `documents` by relevance to `query`.
|
|
2368
|
+
*
|
|
2369
|
+
* Returns results sorted by descending relevance. When `topK` is given, at
|
|
2370
|
+
* most that many results are returned. Each result's `index` points back into
|
|
2371
|
+
* the input `documents` array so callers can recover the original item.
|
|
2372
|
+
*/
|
|
2373
|
+
rerank(query: string, documents: string[], topK?: number): Promise<RerankResult[]>;
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
declare class CohereReranker implements Reranker {
|
|
2377
|
+
private clientInstance?;
|
|
2378
|
+
private clientPromise?;
|
|
2379
|
+
private readonly apiKey;
|
|
2380
|
+
private model;
|
|
2381
|
+
private topK?;
|
|
2382
|
+
private returnDocuments;
|
|
2383
|
+
private maxChunksPerDoc?;
|
|
2384
|
+
constructor(config: RerankerConfig);
|
|
2385
|
+
/**
|
|
2386
|
+
* Lazily construct (or reuse) the Cohere client, importing the optional
|
|
2387
|
+
* `cohere-ai` peer only when the reranker is first used so consumers that
|
|
2388
|
+
* never touch Cohere don't need it installed.
|
|
2389
|
+
*/
|
|
2390
|
+
private getClient;
|
|
2391
|
+
private createClient;
|
|
2392
|
+
rerank(query: string, documents: string[], topK?: number): Promise<RerankResult[]>;
|
|
2393
|
+
}
|
|
2394
|
+
|
|
2395
|
+
declare class LLMReranker implements Reranker {
|
|
2396
|
+
private llm;
|
|
2397
|
+
private topK?;
|
|
2398
|
+
constructor(config: RerankerConfig, llm: LLM);
|
|
2399
|
+
rerank(query: string, documents: string[], topK?: number): Promise<RerankResult[]>;
|
|
2400
|
+
private score;
|
|
2401
|
+
private extractScore;
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
declare class ZeroEntropyReranker implements Reranker {
|
|
2405
|
+
private clientInstance?;
|
|
2406
|
+
private clientPromise?;
|
|
2407
|
+
private readonly apiKey;
|
|
2408
|
+
private model;
|
|
2409
|
+
private topK?;
|
|
2410
|
+
constructor(config: RerankerConfig);
|
|
2411
|
+
/**
|
|
2412
|
+
* Lazily construct (or reuse) the ZeroEntropy client, importing the
|
|
2413
|
+
* optional `zeroentropy` peer only when the reranker is first used so
|
|
2414
|
+
* consumers that never touch ZeroEntropy don't need it installed.
|
|
2415
|
+
*/
|
|
2416
|
+
private getClient;
|
|
2417
|
+
private createClient;
|
|
2418
|
+
rerank(query: string, documents: string[], topK?: number): Promise<RerankResult[]>;
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2421
|
+
declare class CrossEncoderReranker implements Reranker {
|
|
2422
|
+
private modelId;
|
|
2423
|
+
private device?;
|
|
2424
|
+
private maxLength?;
|
|
2425
|
+
private normalize;
|
|
2426
|
+
private topK?;
|
|
2427
|
+
private loaded?;
|
|
2428
|
+
constructor(config: RerankerConfig, defaultModel: string, defaultMaxLength?: number);
|
|
2429
|
+
private load;
|
|
2430
|
+
rerank(query: string, documents: string[], topK?: number): Promise<RerankResult[]>;
|
|
2431
|
+
}
|
|
2432
|
+
|
|
1054
2433
|
interface HistoryManager {
|
|
1055
2434
|
addHistory(memoryId: string, previousValue: string | null, newValue: string | null, action: string, createdAt?: string, updatedAt?: string, isDeleted?: number): Promise<void>;
|
|
1056
2435
|
getHistory(memoryId: string): Promise<any[]>;
|
|
@@ -1087,8 +2466,12 @@ declare class LLMFactory {
|
|
|
1087
2466
|
declare class VectorStoreFactory {
|
|
1088
2467
|
static create(provider: string, config: VectorStoreConfig): VectorStore;
|
|
1089
2468
|
}
|
|
2469
|
+
declare class RerankerFactory {
|
|
2470
|
+
static create(provider: string, config: RerankerConfig): Reranker;
|
|
2471
|
+
private static buildLLMRerankerLLM;
|
|
2472
|
+
}
|
|
1090
2473
|
declare class HistoryManagerFactory {
|
|
1091
2474
|
static create(provider: string, config: HistoryStoreConfig): HistoryManager;
|
|
1092
2475
|
}
|
|
1093
2476
|
|
|
1094
|
-
export { type AddMemoryOptions, AnthropicLLM, AzureAISearch, AzureOpenAIEmbedder, type DeleteAllMemoryOptions, type Embedder, EmbedderFactory, type EmbeddingConfig, type Entity, type GetAllMemoryOptions, GoogleEmbedder, GoogleLLM, GroqLLM, HistoryManagerFactory, type HistoryStoreConfig, type LLM, type LLMConfig, LLMFactory, type LLMResponse, LMStudioEmbedder, LMStudioLLM, LangchainEmbedder, LangchainLLM, LangchainVectorStore, LiteLLM, Memory, type MemoryConfig, MemoryConfigSchema, type MemoryItem, MemoryVectorStore, type Message, MistralLLM, type MultiModalMessages, OllamaEmbedder, OllamaLLM, OpenAIEmbedder, OpenAILLM, OpenAIStructuredLLM, PGVector, Qdrant, RedisDB, type SearchFilters, type SearchMemoryOptions, type SearchResult, SupabaseDB, type UpdateProjectOptions, type VectorStore, type VectorStoreConfig, VectorStoreFactory, type VectorStoreResult, VectorizeDB, buildFilterConditions };
|
|
2477
|
+
export { AWSBedrockLLM, type AddMemoryOptions, AnthropicLLM, AzureAISearch, AzureMySQLDB, AzureOpenAIEmbedder, type BaiduConfig, BaiduDB, CassandraDB, CohereReranker, CrossEncoderReranker, DatabricksVectorStore, type DeleteAllMemoryOptions, ElasticsearchDB, type Embedder, EmbedderFactory, type EmbeddingConfig, type Entity, FastEmbedEmbedder, type GetAllMemoryOptions, GoogleEmbedder, GoogleLLM, type GoogleMatchingEngineConfig, GroqLLM, HistoryManagerFactory, type HistoryStoreConfig, HuggingFaceEmbedder, type LLM, type LLMConfig, LLMError, LLMFactory, LLMReranker, type LLMResponse, LMStudioEmbedder, LMStudioLLM, LangchainEmbedder, LangchainLLM, LangchainVectorStore, LiteLLM, Memory, type MemoryConfig, MemoryConfigSchema, type MemoryItem, MemoryVectorStore, type Message, Milvus, type MilvusConfig, type MilvusMetricType, MistralLLM, MongoDB, type MongoDBConfig, type MultiModalMessages, NeptuneAnalyticsVectorStore, OllamaEmbedder, OllamaLLM, OpenAIEmbedder, OpenAILLM, OpenAIStructuredLLM, OpenSearchDB, PGVector, PineconeDB, Qdrant, RedisDB, type RerankResult, type Reranker, type RerankerConfig, RerankerFactory, S3Vectors, type SearchFilters, type SearchMemoryOptions, type SearchResult, SupabaseDB, TogetherEmbedder, TurbopufferDB, type UpdateMemoryOptions, type UpdateProjectOptions, UpstashVector, type ValkeyConfig, ValkeyDB, type VectorStore, type VectorStoreConfig, VectorStoreFactory, type VectorStoreResult, VectorizeDB, type VertexAIConfig, VertexAIEmbedder, VertexAIVectorSearch, VllmLLM, WeaviateDB, ZeroEntropyReranker, buildFilterConditions, extractProvider };
|