mem0ai 2.0.0 → 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.
- package/README.md +3 -0
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{module-KU56J2J6.mjs → module-QI3FML2A.mjs} +5 -4
- package/dist/module-QI3FML2A.mjs.map +1 -0
- package/dist/oss/index.d.mts +78 -5
- package/dist/oss/index.d.ts +78 -5
- package/dist/oss/index.js +19 -4
- package/dist/oss/index.js.map +1 -1
- package/dist/oss/index.mjs +17 -4
- package/dist/oss/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/module-KU56J2J6.mjs.map +0 -1
package/dist/oss/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { QdrantClient } from '@qdrant/js-client-rest';
|
|
2
3
|
|
|
3
4
|
interface Message {
|
|
4
5
|
role: string;
|
|
@@ -214,6 +215,27 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
214
215
|
} | undefined;
|
|
215
216
|
}>;
|
|
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
|
+
|
|
217
239
|
declare class Memory {
|
|
218
240
|
private config;
|
|
219
241
|
private customPrompt;
|
|
@@ -225,22 +247,22 @@ declare class Memory {
|
|
|
225
247
|
private apiVersion;
|
|
226
248
|
constructor(config?: Partial<MemoryConfig>);
|
|
227
249
|
static fromConfig(configDict: Record<string, any>): Memory;
|
|
228
|
-
add(messages: string | Message[],
|
|
250
|
+
add(messages: string | Message[], config: AddMemoryOptions): Promise<SearchResult>;
|
|
229
251
|
private addToVectorStore;
|
|
230
252
|
get(memoryId: string): Promise<MemoryItem | null>;
|
|
231
|
-
search(query: string,
|
|
253
|
+
search(query: string, config: SearchMemoryOptions): Promise<SearchResult>;
|
|
232
254
|
update(memoryId: string, data: string): Promise<{
|
|
233
255
|
message: string;
|
|
234
256
|
}>;
|
|
235
257
|
delete(memoryId: string): Promise<{
|
|
236
258
|
message: string;
|
|
237
259
|
}>;
|
|
238
|
-
deleteAll(
|
|
260
|
+
deleteAll(config: DeleteAllMemoryOptions): Promise<{
|
|
239
261
|
message: string;
|
|
240
262
|
}>;
|
|
241
263
|
history(memoryId: string): Promise<any[]>;
|
|
242
264
|
reset(): Promise<void>;
|
|
243
|
-
getAll(
|
|
265
|
+
getAll(config: GetAllMemoryOptions): Promise<SearchResult>;
|
|
244
266
|
private createMemory;
|
|
245
267
|
private updateMemory;
|
|
246
268
|
private deleteMemory;
|
|
@@ -335,6 +357,57 @@ declare class MemoryVectorStore implements VectorStore {
|
|
|
335
357
|
list(filters?: SearchFilters, limit?: number): Promise<[VectorStoreResult[], number]>;
|
|
336
358
|
}
|
|
337
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
|
+
|
|
338
411
|
declare class EmbedderFactory {
|
|
339
412
|
static create(provider: string, config: EmbeddingConfig): Embedder;
|
|
340
413
|
}
|
|
@@ -345,4 +418,4 @@ declare class VectorStoreFactory {
|
|
|
345
418
|
static create(provider: string, config: VectorStoreConfig): VectorStore;
|
|
346
419
|
}
|
|
347
420
|
|
|
348
|
-
export { AnthropicLLM, type Embedder, EmbedderFactory, type EmbeddingConfig, type GraphStoreConfig, GroqLLM, type LLM, type LLMConfig, LLMFactory, type LLMResponse, Memory, type MemoryConfig, MemoryConfigSchema, type MemoryItem, MemoryVectorStore, type Message, OpenAIEmbedder, OpenAILLM, OpenAIStructuredLLM, type SearchFilters, type SearchResult, type VectorStore, type VectorStoreConfig, VectorStoreFactory, type VectorStoreResult };
|
|
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 };
|
package/dist/oss/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { QdrantClient } from '@qdrant/js-client-rest';
|
|
2
3
|
|
|
3
4
|
interface Message {
|
|
4
5
|
role: string;
|
|
@@ -214,6 +215,27 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
214
215
|
} | undefined;
|
|
215
216
|
}>;
|
|
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
|
+
|
|
217
239
|
declare class Memory {
|
|
218
240
|
private config;
|
|
219
241
|
private customPrompt;
|
|
@@ -225,22 +247,22 @@ declare class Memory {
|
|
|
225
247
|
private apiVersion;
|
|
226
248
|
constructor(config?: Partial<MemoryConfig>);
|
|
227
249
|
static fromConfig(configDict: Record<string, any>): Memory;
|
|
228
|
-
add(messages: string | Message[],
|
|
250
|
+
add(messages: string | Message[], config: AddMemoryOptions): Promise<SearchResult>;
|
|
229
251
|
private addToVectorStore;
|
|
230
252
|
get(memoryId: string): Promise<MemoryItem | null>;
|
|
231
|
-
search(query: string,
|
|
253
|
+
search(query: string, config: SearchMemoryOptions): Promise<SearchResult>;
|
|
232
254
|
update(memoryId: string, data: string): Promise<{
|
|
233
255
|
message: string;
|
|
234
256
|
}>;
|
|
235
257
|
delete(memoryId: string): Promise<{
|
|
236
258
|
message: string;
|
|
237
259
|
}>;
|
|
238
|
-
deleteAll(
|
|
260
|
+
deleteAll(config: DeleteAllMemoryOptions): Promise<{
|
|
239
261
|
message: string;
|
|
240
262
|
}>;
|
|
241
263
|
history(memoryId: string): Promise<any[]>;
|
|
242
264
|
reset(): Promise<void>;
|
|
243
|
-
getAll(
|
|
265
|
+
getAll(config: GetAllMemoryOptions): Promise<SearchResult>;
|
|
244
266
|
private createMemory;
|
|
245
267
|
private updateMemory;
|
|
246
268
|
private deleteMemory;
|
|
@@ -335,6 +357,57 @@ declare class MemoryVectorStore implements VectorStore {
|
|
|
335
357
|
list(filters?: SearchFilters, limit?: number): Promise<[VectorStoreResult[], number]>;
|
|
336
358
|
}
|
|
337
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
|
+
|
|
338
411
|
declare class EmbedderFactory {
|
|
339
412
|
static create(provider: string, config: EmbeddingConfig): Embedder;
|
|
340
413
|
}
|
|
@@ -345,4 +418,4 @@ declare class VectorStoreFactory {
|
|
|
345
418
|
static create(provider: string, config: VectorStoreConfig): VectorStore;
|
|
346
419
|
}
|
|
347
420
|
|
|
348
|
-
export { AnthropicLLM, type Embedder, EmbedderFactory, type EmbeddingConfig, type GraphStoreConfig, GroqLLM, type LLM, type LLMConfig, LLMFactory, type LLMResponse, Memory, type MemoryConfig, MemoryConfigSchema, type MemoryItem, MemoryVectorStore, type Message, OpenAIEmbedder, OpenAILLM, OpenAIStructuredLLM, type SearchFilters, type SearchResult, type VectorStore, type VectorStoreConfig, VectorStoreFactory, type VectorStoreResult };
|
|
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 };
|
package/dist/oss/index.js
CHANGED
|
@@ -40,6 +40,8 @@ __export(index_exports, {
|
|
|
40
40
|
OpenAIEmbedder: () => OpenAIEmbedder,
|
|
41
41
|
OpenAILLM: () => OpenAILLM,
|
|
42
42
|
OpenAIStructuredLLM: () => OpenAIStructuredLLM,
|
|
43
|
+
Qdrant: () => Qdrant,
|
|
44
|
+
RedisDB: () => RedisDB,
|
|
43
45
|
VectorStoreFactory: () => VectorStoreFactory
|
|
44
46
|
});
|
|
45
47
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -1377,7 +1379,15 @@ var Memory = class _Memory {
|
|
|
1377
1379
|
throw e;
|
|
1378
1380
|
}
|
|
1379
1381
|
}
|
|
1380
|
-
async add(messages,
|
|
1382
|
+
async add(messages, config) {
|
|
1383
|
+
const {
|
|
1384
|
+
userId,
|
|
1385
|
+
agentId,
|
|
1386
|
+
runId,
|
|
1387
|
+
metadata = {},
|
|
1388
|
+
filters = {},
|
|
1389
|
+
prompt
|
|
1390
|
+
} = config;
|
|
1381
1391
|
if (userId) filters.userId = metadata.userId = userId;
|
|
1382
1392
|
if (agentId) filters.agentId = metadata.agentId = agentId;
|
|
1383
1393
|
if (runId) filters.runId = metadata.runId = runId;
|
|
@@ -1520,7 +1530,8 @@ ${parsedMessages}`] : getFactRetrievalMessages(parsedMessages);
|
|
|
1520
1530
|
}
|
|
1521
1531
|
return { ...memoryItem, ...filters };
|
|
1522
1532
|
}
|
|
1523
|
-
async search(query,
|
|
1533
|
+
async search(query, config) {
|
|
1534
|
+
const { userId, agentId, runId, limit = 100, filters = {} } = config;
|
|
1524
1535
|
if (userId) filters.userId = userId;
|
|
1525
1536
|
if (agentId) filters.agentId = agentId;
|
|
1526
1537
|
if (runId) filters.runId = runId;
|
|
@@ -1567,7 +1578,8 @@ ${parsedMessages}`] : getFactRetrievalMessages(parsedMessages);
|
|
|
1567
1578
|
await this.deleteMemory(memoryId);
|
|
1568
1579
|
return { message: "Memory deleted successfully!" };
|
|
1569
1580
|
}
|
|
1570
|
-
async deleteAll(
|
|
1581
|
+
async deleteAll(config) {
|
|
1582
|
+
const { userId, agentId, runId } = config;
|
|
1571
1583
|
const filters = {};
|
|
1572
1584
|
if (userId) filters.userId = userId;
|
|
1573
1585
|
if (agentId) filters.agentId = agentId;
|
|
@@ -1594,7 +1606,8 @@ ${parsedMessages}`] : getFactRetrievalMessages(parsedMessages);
|
|
|
1594
1606
|
this.config.vectorStore.config
|
|
1595
1607
|
);
|
|
1596
1608
|
}
|
|
1597
|
-
async getAll(
|
|
1609
|
+
async getAll(config) {
|
|
1610
|
+
const { userId, agentId, runId, limit = 100 } = config;
|
|
1598
1611
|
const filters = {};
|
|
1599
1612
|
if (userId) filters.userId = userId;
|
|
1600
1613
|
if (agentId) filters.agentId = agentId;
|
|
@@ -1706,6 +1719,8 @@ ${parsedMessages}`] : getFactRetrievalMessages(parsedMessages);
|
|
|
1706
1719
|
OpenAIEmbedder,
|
|
1707
1720
|
OpenAILLM,
|
|
1708
1721
|
OpenAIStructuredLLM,
|
|
1722
|
+
Qdrant,
|
|
1723
|
+
RedisDB,
|
|
1709
1724
|
VectorStoreFactory
|
|
1710
1725
|
});
|
|
1711
1726
|
//# sourceMappingURL=index.js.map
|