mem0ai 1.0.39 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,421 @@
1
+ import { z } from 'zod';
2
+ import { QdrantClient } from '@qdrant/js-client-rest';
3
+
4
+ interface Message {
5
+ role: string;
6
+ content: string;
7
+ }
8
+ interface EmbeddingConfig {
9
+ apiKey: string;
10
+ model?: string;
11
+ }
12
+ interface VectorStoreConfig {
13
+ collectionName: string;
14
+ dimension?: number;
15
+ [key: string]: any;
16
+ }
17
+ interface LLMConfig {
18
+ apiKey: string;
19
+ model?: string;
20
+ }
21
+ interface GraphStoreConfig {
22
+ config?: any;
23
+ }
24
+ interface MemoryConfig {
25
+ version?: string;
26
+ embedder: {
27
+ provider: string;
28
+ config: EmbeddingConfig;
29
+ };
30
+ vectorStore: {
31
+ provider: string;
32
+ config: VectorStoreConfig;
33
+ };
34
+ llm: {
35
+ provider: string;
36
+ config: LLMConfig;
37
+ };
38
+ historyDbPath?: string;
39
+ customPrompt?: string;
40
+ graphStore?: GraphStoreConfig;
41
+ }
42
+ interface MemoryItem {
43
+ id: string;
44
+ memory: string;
45
+ hash?: string;
46
+ createdAt?: string;
47
+ updatedAt?: string;
48
+ score?: number;
49
+ metadata?: Record<string, any>;
50
+ }
51
+ interface SearchFilters {
52
+ userId?: string;
53
+ agentId?: string;
54
+ runId?: string;
55
+ [key: string]: any;
56
+ }
57
+ interface SearchResult {
58
+ results: MemoryItem[];
59
+ relations?: any[];
60
+ }
61
+ interface VectorStoreResult {
62
+ id: string;
63
+ payload: Record<string, any>;
64
+ score?: number;
65
+ }
66
+ declare const MemoryConfigSchema: z.ZodObject<{
67
+ version: z.ZodOptional<z.ZodString>;
68
+ embedder: z.ZodObject<{
69
+ provider: z.ZodString;
70
+ config: z.ZodObject<{
71
+ apiKey: z.ZodString;
72
+ model: z.ZodOptional<z.ZodString>;
73
+ }, "strip", z.ZodTypeAny, {
74
+ apiKey: string;
75
+ model?: string | undefined;
76
+ }, {
77
+ apiKey: string;
78
+ model?: string | undefined;
79
+ }>;
80
+ }, "strip", z.ZodTypeAny, {
81
+ provider: string;
82
+ config: {
83
+ apiKey: string;
84
+ model?: string | undefined;
85
+ };
86
+ }, {
87
+ provider: string;
88
+ config: {
89
+ apiKey: string;
90
+ model?: string | undefined;
91
+ };
92
+ }>;
93
+ vectorStore: z.ZodObject<{
94
+ provider: z.ZodString;
95
+ config: z.ZodObject<{
96
+ collectionName: z.ZodString;
97
+ dimension: z.ZodOptional<z.ZodNumber>;
98
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
99
+ collectionName: z.ZodString;
100
+ dimension: z.ZodOptional<z.ZodNumber>;
101
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
102
+ collectionName: z.ZodString;
103
+ dimension: z.ZodOptional<z.ZodNumber>;
104
+ }, z.ZodTypeAny, "passthrough">>;
105
+ }, "strip", z.ZodTypeAny, {
106
+ provider: string;
107
+ config: {
108
+ collectionName: string;
109
+ dimension?: number | undefined;
110
+ } & {
111
+ [k: string]: unknown;
112
+ };
113
+ }, {
114
+ provider: string;
115
+ config: {
116
+ collectionName: string;
117
+ dimension?: number | undefined;
118
+ } & {
119
+ [k: string]: unknown;
120
+ };
121
+ }>;
122
+ llm: z.ZodObject<{
123
+ provider: z.ZodString;
124
+ config: z.ZodObject<{
125
+ apiKey: z.ZodString;
126
+ model: z.ZodOptional<z.ZodString>;
127
+ }, "strip", z.ZodTypeAny, {
128
+ apiKey: string;
129
+ model?: string | undefined;
130
+ }, {
131
+ apiKey: string;
132
+ model?: string | undefined;
133
+ }>;
134
+ }, "strip", z.ZodTypeAny, {
135
+ provider: string;
136
+ config: {
137
+ apiKey: string;
138
+ model?: string | undefined;
139
+ };
140
+ }, {
141
+ provider: string;
142
+ config: {
143
+ apiKey: string;
144
+ model?: string | undefined;
145
+ };
146
+ }>;
147
+ historyDbPath: z.ZodOptional<z.ZodString>;
148
+ customPrompt: z.ZodOptional<z.ZodString>;
149
+ graphStore: z.ZodOptional<z.ZodObject<{
150
+ config: z.ZodOptional<z.ZodAny>;
151
+ }, "strip", z.ZodTypeAny, {
152
+ config?: any;
153
+ }, {
154
+ config?: any;
155
+ }>>;
156
+ }, "strip", z.ZodTypeAny, {
157
+ embedder: {
158
+ provider: string;
159
+ config: {
160
+ apiKey: string;
161
+ model?: string | undefined;
162
+ };
163
+ };
164
+ vectorStore: {
165
+ provider: string;
166
+ config: {
167
+ collectionName: string;
168
+ dimension?: number | undefined;
169
+ } & {
170
+ [k: string]: unknown;
171
+ };
172
+ };
173
+ llm: {
174
+ provider: string;
175
+ config: {
176
+ apiKey: string;
177
+ model?: string | undefined;
178
+ };
179
+ };
180
+ version?: string | undefined;
181
+ historyDbPath?: string | undefined;
182
+ customPrompt?: string | undefined;
183
+ graphStore?: {
184
+ config?: any;
185
+ } | undefined;
186
+ }, {
187
+ embedder: {
188
+ provider: string;
189
+ config: {
190
+ apiKey: string;
191
+ model?: string | undefined;
192
+ };
193
+ };
194
+ vectorStore: {
195
+ provider: string;
196
+ config: {
197
+ collectionName: string;
198
+ dimension?: number | undefined;
199
+ } & {
200
+ [k: string]: unknown;
201
+ };
202
+ };
203
+ llm: {
204
+ provider: string;
205
+ config: {
206
+ apiKey: string;
207
+ model?: string | undefined;
208
+ };
209
+ };
210
+ version?: string | undefined;
211
+ historyDbPath?: string | undefined;
212
+ customPrompt?: string | undefined;
213
+ graphStore?: {
214
+ config?: any;
215
+ } | undefined;
216
+ }>;
217
+
218
+ interface Entity {
219
+ userId?: string;
220
+ agentId?: string;
221
+ runId?: string;
222
+ }
223
+ interface AddMemoryOptions extends Entity {
224
+ metadata?: Record<string, any>;
225
+ filters?: SearchFilters;
226
+ prompt?: string;
227
+ }
228
+ interface SearchMemoryOptions extends Entity {
229
+ query: string;
230
+ limit?: number;
231
+ filters?: SearchFilters;
232
+ }
233
+ interface GetAllMemoryOptions extends Entity {
234
+ limit?: number;
235
+ }
236
+ interface DeleteAllMemoryOptions extends Entity {
237
+ }
238
+
239
+ declare class Memory {
240
+ private config;
241
+ private customPrompt;
242
+ private embedder;
243
+ private vectorStore;
244
+ private llm;
245
+ private db;
246
+ private collectionName;
247
+ private apiVersion;
248
+ constructor(config?: Partial<MemoryConfig>);
249
+ static fromConfig(configDict: Record<string, any>): Memory;
250
+ add(messages: string | Message[], config: AddMemoryOptions): Promise<SearchResult>;
251
+ private addToVectorStore;
252
+ get(memoryId: string): Promise<MemoryItem | null>;
253
+ search(query: string, config: SearchMemoryOptions): Promise<SearchResult>;
254
+ update(memoryId: string, data: string): Promise<{
255
+ message: string;
256
+ }>;
257
+ delete(memoryId: string): Promise<{
258
+ message: string;
259
+ }>;
260
+ deleteAll(config: DeleteAllMemoryOptions): Promise<{
261
+ message: string;
262
+ }>;
263
+ history(memoryId: string): Promise<any[]>;
264
+ reset(): Promise<void>;
265
+ getAll(config: GetAllMemoryOptions): Promise<SearchResult>;
266
+ private createMemory;
267
+ private updateMemory;
268
+ private deleteMemory;
269
+ }
270
+
271
+ interface Embedder {
272
+ embed(text: string): Promise<number[]>;
273
+ embedBatch(texts: string[]): Promise<number[][]>;
274
+ }
275
+
276
+ declare class OpenAIEmbedder implements Embedder {
277
+ private openai;
278
+ private model;
279
+ constructor(config: EmbeddingConfig);
280
+ embed(text: string): Promise<number[]>;
281
+ embedBatch(texts: string[]): Promise<number[][]>;
282
+ }
283
+
284
+ interface LLMResponse {
285
+ content: string;
286
+ role: string;
287
+ }
288
+ interface LLM {
289
+ generateResponse(messages: Message[], responseFormat?: {
290
+ type: string;
291
+ }): Promise<string>;
292
+ generateChat(messages: Message[]): Promise<LLMResponse>;
293
+ }
294
+
295
+ declare class OpenAILLM implements LLM {
296
+ private openai;
297
+ private model;
298
+ constructor(config: LLMConfig);
299
+ generateResponse(messages: Message[], responseFormat?: {
300
+ type: string;
301
+ }): Promise<string>;
302
+ generateChat(messages: Message[]): Promise<LLMResponse>;
303
+ }
304
+
305
+ declare class OpenAIStructuredLLM implements LLM {
306
+ private client;
307
+ private model;
308
+ constructor(config: LLMConfig);
309
+ generateResponse(messages: Message[], responseFormat?: {
310
+ type: string;
311
+ }): Promise<string>;
312
+ generateChat(messages: Message[]): Promise<LLMResponse>;
313
+ }
314
+
315
+ declare class AnthropicLLM implements LLM {
316
+ private client;
317
+ private model;
318
+ constructor(config: LLMConfig);
319
+ generateResponse(messages: Message[], responseFormat?: {
320
+ type: string;
321
+ }): Promise<string>;
322
+ generateChat(messages: Message[]): Promise<LLMResponse>;
323
+ }
324
+
325
+ declare class GroqLLM implements LLM {
326
+ private client;
327
+ private model;
328
+ constructor(config: LLMConfig);
329
+ generateResponse(messages: Message[], responseFormat?: {
330
+ type: string;
331
+ }): Promise<string>;
332
+ generateChat(messages: Message[]): Promise<LLMResponse>;
333
+ }
334
+
335
+ interface VectorStore {
336
+ insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
337
+ search(query: number[], limit?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
338
+ get(vectorId: string): Promise<VectorStoreResult | null>;
339
+ update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
340
+ delete(vectorId: string): Promise<void>;
341
+ deleteCol(): Promise<void>;
342
+ list(filters?: SearchFilters, limit?: number): Promise<[VectorStoreResult[], number]>;
343
+ }
344
+
345
+ declare class MemoryVectorStore implements VectorStore {
346
+ private vectors;
347
+ private dimension;
348
+ constructor(config: VectorStoreConfig);
349
+ private cosineSimilarity;
350
+ private filterVector;
351
+ insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
352
+ search(query: number[], limit?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
353
+ get(vectorId: string): Promise<VectorStoreResult | null>;
354
+ update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
355
+ delete(vectorId: string): Promise<void>;
356
+ deleteCol(): Promise<void>;
357
+ list(filters?: SearchFilters, limit?: number): Promise<[VectorStoreResult[], number]>;
358
+ }
359
+
360
+ interface QdrantConfig extends VectorStoreConfig {
361
+ client?: QdrantClient;
362
+ host?: string;
363
+ port?: number;
364
+ path?: string;
365
+ url?: string;
366
+ apiKey?: string;
367
+ onDisk?: boolean;
368
+ collectionName: string;
369
+ embeddingModelDims: number;
370
+ }
371
+ declare class Qdrant implements VectorStore {
372
+ private client;
373
+ private readonly collectionName;
374
+ constructor(config: QdrantConfig);
375
+ private createCol;
376
+ private createFilter;
377
+ insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
378
+ search(query: number[], limit?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
379
+ get(vectorId: string): Promise<VectorStoreResult | null>;
380
+ update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
381
+ delete(vectorId: string): Promise<void>;
382
+ deleteCol(): Promise<void>;
383
+ list(filters?: SearchFilters, limit?: number): Promise<[VectorStoreResult[], number]>;
384
+ }
385
+
386
+ interface RedisConfig extends VectorStoreConfig {
387
+ redisUrl: string;
388
+ collectionName: string;
389
+ embeddingModelDims: number;
390
+ username?: string;
391
+ password?: string;
392
+ }
393
+ declare class RedisDB implements VectorStore {
394
+ private client;
395
+ private readonly indexName;
396
+ private readonly indexPrefix;
397
+ private readonly schema;
398
+ constructor(config: RedisConfig);
399
+ private initialize;
400
+ private createIndex;
401
+ insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
402
+ search(query: number[], limit?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
403
+ get(vectorId: string): Promise<VectorStoreResult | null>;
404
+ update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
405
+ delete(vectorId: string): Promise<void>;
406
+ deleteCol(): Promise<void>;
407
+ list(filters?: SearchFilters, limit?: number): Promise<[VectorStoreResult[], number]>;
408
+ close(): Promise<void>;
409
+ }
410
+
411
+ declare class EmbedderFactory {
412
+ static create(provider: string, config: EmbeddingConfig): Embedder;
413
+ }
414
+ declare class LLMFactory {
415
+ static create(provider: string, config: LLMConfig): LLM;
416
+ }
417
+ declare class VectorStoreFactory {
418
+ static create(provider: string, config: VectorStoreConfig): VectorStore;
419
+ }
420
+
421
+ export { type AddMemoryOptions, AnthropicLLM, type DeleteAllMemoryOptions, type Embedder, EmbedderFactory, type EmbeddingConfig, type Entity, type GetAllMemoryOptions, type GraphStoreConfig, GroqLLM, type LLM, type LLMConfig, LLMFactory, type LLMResponse, Memory, type MemoryConfig, MemoryConfigSchema, type MemoryItem, MemoryVectorStore, type Message, OpenAIEmbedder, OpenAILLM, OpenAIStructuredLLM, Qdrant, RedisDB, type SearchFilters, type SearchMemoryOptions, type SearchResult, type VectorStore, type VectorStoreConfig, VectorStoreFactory, type VectorStoreResult };