mem0ai 1.0.38 → 2.0.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/README.md +22 -334
- package/dist/index.d.mts +29 -1
- package/dist/index.d.ts +29 -2
- package/dist/index.js +4482 -126
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +161 -101
- package/dist/index.mjs.map +1 -1
- package/dist/module-KU56J2J6.mjs +4313 -0
- package/dist/module-KU56J2J6.mjs.map +1 -0
- package/dist/oss/index.d.mts +348 -0
- package/dist/oss/index.d.ts +348 -0
- package/dist/oss/index.js +1711 -0
- package/dist/oss/index.js.map +1 -0
- package/dist/oss/index.mjs +1664 -0
- package/dist/oss/index.mjs.map +1 -0
- package/package.json +109 -61
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
interface Message {
|
|
4
|
+
role: string;
|
|
5
|
+
content: string;
|
|
6
|
+
}
|
|
7
|
+
interface EmbeddingConfig {
|
|
8
|
+
apiKey: string;
|
|
9
|
+
model?: string;
|
|
10
|
+
}
|
|
11
|
+
interface VectorStoreConfig {
|
|
12
|
+
collectionName: string;
|
|
13
|
+
dimension?: number;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
16
|
+
interface LLMConfig {
|
|
17
|
+
apiKey: string;
|
|
18
|
+
model?: string;
|
|
19
|
+
}
|
|
20
|
+
interface GraphStoreConfig {
|
|
21
|
+
config?: any;
|
|
22
|
+
}
|
|
23
|
+
interface MemoryConfig {
|
|
24
|
+
version?: string;
|
|
25
|
+
embedder: {
|
|
26
|
+
provider: string;
|
|
27
|
+
config: EmbeddingConfig;
|
|
28
|
+
};
|
|
29
|
+
vectorStore: {
|
|
30
|
+
provider: string;
|
|
31
|
+
config: VectorStoreConfig;
|
|
32
|
+
};
|
|
33
|
+
llm: {
|
|
34
|
+
provider: string;
|
|
35
|
+
config: LLMConfig;
|
|
36
|
+
};
|
|
37
|
+
historyDbPath?: string;
|
|
38
|
+
customPrompt?: string;
|
|
39
|
+
graphStore?: GraphStoreConfig;
|
|
40
|
+
}
|
|
41
|
+
interface MemoryItem {
|
|
42
|
+
id: string;
|
|
43
|
+
memory: string;
|
|
44
|
+
hash?: string;
|
|
45
|
+
createdAt?: string;
|
|
46
|
+
updatedAt?: string;
|
|
47
|
+
score?: number;
|
|
48
|
+
metadata?: Record<string, any>;
|
|
49
|
+
}
|
|
50
|
+
interface SearchFilters {
|
|
51
|
+
userId?: string;
|
|
52
|
+
agentId?: string;
|
|
53
|
+
runId?: string;
|
|
54
|
+
[key: string]: any;
|
|
55
|
+
}
|
|
56
|
+
interface SearchResult {
|
|
57
|
+
results: MemoryItem[];
|
|
58
|
+
relations?: any[];
|
|
59
|
+
}
|
|
60
|
+
interface VectorStoreResult {
|
|
61
|
+
id: string;
|
|
62
|
+
payload: Record<string, any>;
|
|
63
|
+
score?: number;
|
|
64
|
+
}
|
|
65
|
+
declare const MemoryConfigSchema: z.ZodObject<{
|
|
66
|
+
version: z.ZodOptional<z.ZodString>;
|
|
67
|
+
embedder: z.ZodObject<{
|
|
68
|
+
provider: z.ZodString;
|
|
69
|
+
config: z.ZodObject<{
|
|
70
|
+
apiKey: z.ZodString;
|
|
71
|
+
model: z.ZodOptional<z.ZodString>;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
apiKey: string;
|
|
74
|
+
model?: string | undefined;
|
|
75
|
+
}, {
|
|
76
|
+
apiKey: string;
|
|
77
|
+
model?: string | undefined;
|
|
78
|
+
}>;
|
|
79
|
+
}, "strip", z.ZodTypeAny, {
|
|
80
|
+
provider: string;
|
|
81
|
+
config: {
|
|
82
|
+
apiKey: string;
|
|
83
|
+
model?: string | undefined;
|
|
84
|
+
};
|
|
85
|
+
}, {
|
|
86
|
+
provider: string;
|
|
87
|
+
config: {
|
|
88
|
+
apiKey: string;
|
|
89
|
+
model?: string | undefined;
|
|
90
|
+
};
|
|
91
|
+
}>;
|
|
92
|
+
vectorStore: z.ZodObject<{
|
|
93
|
+
provider: z.ZodString;
|
|
94
|
+
config: z.ZodObject<{
|
|
95
|
+
collectionName: z.ZodString;
|
|
96
|
+
dimension: z.ZodOptional<z.ZodNumber>;
|
|
97
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
98
|
+
collectionName: z.ZodString;
|
|
99
|
+
dimension: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
101
|
+
collectionName: z.ZodString;
|
|
102
|
+
dimension: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
104
|
+
}, "strip", z.ZodTypeAny, {
|
|
105
|
+
provider: string;
|
|
106
|
+
config: {
|
|
107
|
+
collectionName: string;
|
|
108
|
+
dimension?: number | undefined;
|
|
109
|
+
} & {
|
|
110
|
+
[k: string]: unknown;
|
|
111
|
+
};
|
|
112
|
+
}, {
|
|
113
|
+
provider: string;
|
|
114
|
+
config: {
|
|
115
|
+
collectionName: string;
|
|
116
|
+
dimension?: number | undefined;
|
|
117
|
+
} & {
|
|
118
|
+
[k: string]: unknown;
|
|
119
|
+
};
|
|
120
|
+
}>;
|
|
121
|
+
llm: z.ZodObject<{
|
|
122
|
+
provider: z.ZodString;
|
|
123
|
+
config: z.ZodObject<{
|
|
124
|
+
apiKey: z.ZodString;
|
|
125
|
+
model: z.ZodOptional<z.ZodString>;
|
|
126
|
+
}, "strip", z.ZodTypeAny, {
|
|
127
|
+
apiKey: string;
|
|
128
|
+
model?: string | undefined;
|
|
129
|
+
}, {
|
|
130
|
+
apiKey: string;
|
|
131
|
+
model?: string | undefined;
|
|
132
|
+
}>;
|
|
133
|
+
}, "strip", z.ZodTypeAny, {
|
|
134
|
+
provider: string;
|
|
135
|
+
config: {
|
|
136
|
+
apiKey: string;
|
|
137
|
+
model?: string | undefined;
|
|
138
|
+
};
|
|
139
|
+
}, {
|
|
140
|
+
provider: string;
|
|
141
|
+
config: {
|
|
142
|
+
apiKey: string;
|
|
143
|
+
model?: string | undefined;
|
|
144
|
+
};
|
|
145
|
+
}>;
|
|
146
|
+
historyDbPath: z.ZodOptional<z.ZodString>;
|
|
147
|
+
customPrompt: z.ZodOptional<z.ZodString>;
|
|
148
|
+
graphStore: z.ZodOptional<z.ZodObject<{
|
|
149
|
+
config: z.ZodOptional<z.ZodAny>;
|
|
150
|
+
}, "strip", z.ZodTypeAny, {
|
|
151
|
+
config?: any;
|
|
152
|
+
}, {
|
|
153
|
+
config?: any;
|
|
154
|
+
}>>;
|
|
155
|
+
}, "strip", z.ZodTypeAny, {
|
|
156
|
+
embedder: {
|
|
157
|
+
provider: string;
|
|
158
|
+
config: {
|
|
159
|
+
apiKey: string;
|
|
160
|
+
model?: string | undefined;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
vectorStore: {
|
|
164
|
+
provider: string;
|
|
165
|
+
config: {
|
|
166
|
+
collectionName: string;
|
|
167
|
+
dimension?: number | undefined;
|
|
168
|
+
} & {
|
|
169
|
+
[k: string]: unknown;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
llm: {
|
|
173
|
+
provider: string;
|
|
174
|
+
config: {
|
|
175
|
+
apiKey: string;
|
|
176
|
+
model?: string | undefined;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
version?: string | undefined;
|
|
180
|
+
historyDbPath?: string | undefined;
|
|
181
|
+
customPrompt?: string | undefined;
|
|
182
|
+
graphStore?: {
|
|
183
|
+
config?: any;
|
|
184
|
+
} | undefined;
|
|
185
|
+
}, {
|
|
186
|
+
embedder: {
|
|
187
|
+
provider: string;
|
|
188
|
+
config: {
|
|
189
|
+
apiKey: string;
|
|
190
|
+
model?: string | undefined;
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
vectorStore: {
|
|
194
|
+
provider: string;
|
|
195
|
+
config: {
|
|
196
|
+
collectionName: string;
|
|
197
|
+
dimension?: number | undefined;
|
|
198
|
+
} & {
|
|
199
|
+
[k: string]: unknown;
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
llm: {
|
|
203
|
+
provider: string;
|
|
204
|
+
config: {
|
|
205
|
+
apiKey: string;
|
|
206
|
+
model?: string | undefined;
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
version?: string | undefined;
|
|
210
|
+
historyDbPath?: string | undefined;
|
|
211
|
+
customPrompt?: string | undefined;
|
|
212
|
+
graphStore?: {
|
|
213
|
+
config?: any;
|
|
214
|
+
} | undefined;
|
|
215
|
+
}>;
|
|
216
|
+
|
|
217
|
+
declare class Memory {
|
|
218
|
+
private config;
|
|
219
|
+
private customPrompt;
|
|
220
|
+
private embedder;
|
|
221
|
+
private vectorStore;
|
|
222
|
+
private llm;
|
|
223
|
+
private db;
|
|
224
|
+
private collectionName;
|
|
225
|
+
private apiVersion;
|
|
226
|
+
constructor(config?: Partial<MemoryConfig>);
|
|
227
|
+
static fromConfig(configDict: Record<string, any>): Memory;
|
|
228
|
+
add(messages: string | Message[], userId?: string, agentId?: string, runId?: string, metadata?: Record<string, any>, filters?: SearchFilters, prompt?: string): Promise<SearchResult>;
|
|
229
|
+
private addToVectorStore;
|
|
230
|
+
get(memoryId: string): Promise<MemoryItem | null>;
|
|
231
|
+
search(query: string, userId?: string, agentId?: string, runId?: string, limit?: number, filters?: SearchFilters): Promise<SearchResult>;
|
|
232
|
+
update(memoryId: string, data: string): Promise<{
|
|
233
|
+
message: string;
|
|
234
|
+
}>;
|
|
235
|
+
delete(memoryId: string): Promise<{
|
|
236
|
+
message: string;
|
|
237
|
+
}>;
|
|
238
|
+
deleteAll(userId?: string, agentId?: string, runId?: string): Promise<{
|
|
239
|
+
message: string;
|
|
240
|
+
}>;
|
|
241
|
+
history(memoryId: string): Promise<any[]>;
|
|
242
|
+
reset(): Promise<void>;
|
|
243
|
+
getAll(userId?: string, agentId?: string, runId?: string, limit?: number): Promise<SearchResult>;
|
|
244
|
+
private createMemory;
|
|
245
|
+
private updateMemory;
|
|
246
|
+
private deleteMemory;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
interface Embedder {
|
|
250
|
+
embed(text: string): Promise<number[]>;
|
|
251
|
+
embedBatch(texts: string[]): Promise<number[][]>;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
declare class OpenAIEmbedder implements Embedder {
|
|
255
|
+
private openai;
|
|
256
|
+
private model;
|
|
257
|
+
constructor(config: EmbeddingConfig);
|
|
258
|
+
embed(text: string): Promise<number[]>;
|
|
259
|
+
embedBatch(texts: string[]): Promise<number[][]>;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
interface LLMResponse {
|
|
263
|
+
content: string;
|
|
264
|
+
role: string;
|
|
265
|
+
}
|
|
266
|
+
interface LLM {
|
|
267
|
+
generateResponse(messages: Message[], responseFormat?: {
|
|
268
|
+
type: string;
|
|
269
|
+
}): Promise<string>;
|
|
270
|
+
generateChat(messages: Message[]): Promise<LLMResponse>;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
declare class OpenAILLM implements LLM {
|
|
274
|
+
private openai;
|
|
275
|
+
private model;
|
|
276
|
+
constructor(config: LLMConfig);
|
|
277
|
+
generateResponse(messages: Message[], responseFormat?: {
|
|
278
|
+
type: string;
|
|
279
|
+
}): Promise<string>;
|
|
280
|
+
generateChat(messages: Message[]): Promise<LLMResponse>;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
declare class OpenAIStructuredLLM implements LLM {
|
|
284
|
+
private client;
|
|
285
|
+
private model;
|
|
286
|
+
constructor(config: LLMConfig);
|
|
287
|
+
generateResponse(messages: Message[], responseFormat?: {
|
|
288
|
+
type: string;
|
|
289
|
+
}): Promise<string>;
|
|
290
|
+
generateChat(messages: Message[]): Promise<LLMResponse>;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
declare class AnthropicLLM implements LLM {
|
|
294
|
+
private client;
|
|
295
|
+
private model;
|
|
296
|
+
constructor(config: LLMConfig);
|
|
297
|
+
generateResponse(messages: Message[], responseFormat?: {
|
|
298
|
+
type: string;
|
|
299
|
+
}): Promise<string>;
|
|
300
|
+
generateChat(messages: Message[]): Promise<LLMResponse>;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
declare class GroqLLM implements LLM {
|
|
304
|
+
private client;
|
|
305
|
+
private model;
|
|
306
|
+
constructor(config: LLMConfig);
|
|
307
|
+
generateResponse(messages: Message[], responseFormat?: {
|
|
308
|
+
type: string;
|
|
309
|
+
}): Promise<string>;
|
|
310
|
+
generateChat(messages: Message[]): Promise<LLMResponse>;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
interface VectorStore {
|
|
314
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
315
|
+
search(query: number[], limit?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
316
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
317
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
318
|
+
delete(vectorId: string): Promise<void>;
|
|
319
|
+
deleteCol(): Promise<void>;
|
|
320
|
+
list(filters?: SearchFilters, limit?: number): Promise<[VectorStoreResult[], number]>;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
declare class MemoryVectorStore implements VectorStore {
|
|
324
|
+
private vectors;
|
|
325
|
+
private dimension;
|
|
326
|
+
constructor(config: VectorStoreConfig);
|
|
327
|
+
private cosineSimilarity;
|
|
328
|
+
private filterVector;
|
|
329
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
330
|
+
search(query: number[], limit?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
331
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
332
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
333
|
+
delete(vectorId: string): Promise<void>;
|
|
334
|
+
deleteCol(): Promise<void>;
|
|
335
|
+
list(filters?: SearchFilters, limit?: number): Promise<[VectorStoreResult[], number]>;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
declare class EmbedderFactory {
|
|
339
|
+
static create(provider: string, config: EmbeddingConfig): Embedder;
|
|
340
|
+
}
|
|
341
|
+
declare class LLMFactory {
|
|
342
|
+
static create(provider: string, config: LLMConfig): LLM;
|
|
343
|
+
}
|
|
344
|
+
declare class VectorStoreFactory {
|
|
345
|
+
static create(provider: string, config: VectorStoreConfig): VectorStore;
|
|
346
|
+
}
|
|
347
|
+
|
|
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 };
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
interface Message {
|
|
4
|
+
role: string;
|
|
5
|
+
content: string;
|
|
6
|
+
}
|
|
7
|
+
interface EmbeddingConfig {
|
|
8
|
+
apiKey: string;
|
|
9
|
+
model?: string;
|
|
10
|
+
}
|
|
11
|
+
interface VectorStoreConfig {
|
|
12
|
+
collectionName: string;
|
|
13
|
+
dimension?: number;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
16
|
+
interface LLMConfig {
|
|
17
|
+
apiKey: string;
|
|
18
|
+
model?: string;
|
|
19
|
+
}
|
|
20
|
+
interface GraphStoreConfig {
|
|
21
|
+
config?: any;
|
|
22
|
+
}
|
|
23
|
+
interface MemoryConfig {
|
|
24
|
+
version?: string;
|
|
25
|
+
embedder: {
|
|
26
|
+
provider: string;
|
|
27
|
+
config: EmbeddingConfig;
|
|
28
|
+
};
|
|
29
|
+
vectorStore: {
|
|
30
|
+
provider: string;
|
|
31
|
+
config: VectorStoreConfig;
|
|
32
|
+
};
|
|
33
|
+
llm: {
|
|
34
|
+
provider: string;
|
|
35
|
+
config: LLMConfig;
|
|
36
|
+
};
|
|
37
|
+
historyDbPath?: string;
|
|
38
|
+
customPrompt?: string;
|
|
39
|
+
graphStore?: GraphStoreConfig;
|
|
40
|
+
}
|
|
41
|
+
interface MemoryItem {
|
|
42
|
+
id: string;
|
|
43
|
+
memory: string;
|
|
44
|
+
hash?: string;
|
|
45
|
+
createdAt?: string;
|
|
46
|
+
updatedAt?: string;
|
|
47
|
+
score?: number;
|
|
48
|
+
metadata?: Record<string, any>;
|
|
49
|
+
}
|
|
50
|
+
interface SearchFilters {
|
|
51
|
+
userId?: string;
|
|
52
|
+
agentId?: string;
|
|
53
|
+
runId?: string;
|
|
54
|
+
[key: string]: any;
|
|
55
|
+
}
|
|
56
|
+
interface SearchResult {
|
|
57
|
+
results: MemoryItem[];
|
|
58
|
+
relations?: any[];
|
|
59
|
+
}
|
|
60
|
+
interface VectorStoreResult {
|
|
61
|
+
id: string;
|
|
62
|
+
payload: Record<string, any>;
|
|
63
|
+
score?: number;
|
|
64
|
+
}
|
|
65
|
+
declare const MemoryConfigSchema: z.ZodObject<{
|
|
66
|
+
version: z.ZodOptional<z.ZodString>;
|
|
67
|
+
embedder: z.ZodObject<{
|
|
68
|
+
provider: z.ZodString;
|
|
69
|
+
config: z.ZodObject<{
|
|
70
|
+
apiKey: z.ZodString;
|
|
71
|
+
model: z.ZodOptional<z.ZodString>;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
apiKey: string;
|
|
74
|
+
model?: string | undefined;
|
|
75
|
+
}, {
|
|
76
|
+
apiKey: string;
|
|
77
|
+
model?: string | undefined;
|
|
78
|
+
}>;
|
|
79
|
+
}, "strip", z.ZodTypeAny, {
|
|
80
|
+
provider: string;
|
|
81
|
+
config: {
|
|
82
|
+
apiKey: string;
|
|
83
|
+
model?: string | undefined;
|
|
84
|
+
};
|
|
85
|
+
}, {
|
|
86
|
+
provider: string;
|
|
87
|
+
config: {
|
|
88
|
+
apiKey: string;
|
|
89
|
+
model?: string | undefined;
|
|
90
|
+
};
|
|
91
|
+
}>;
|
|
92
|
+
vectorStore: z.ZodObject<{
|
|
93
|
+
provider: z.ZodString;
|
|
94
|
+
config: z.ZodObject<{
|
|
95
|
+
collectionName: z.ZodString;
|
|
96
|
+
dimension: z.ZodOptional<z.ZodNumber>;
|
|
97
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
98
|
+
collectionName: z.ZodString;
|
|
99
|
+
dimension: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
101
|
+
collectionName: z.ZodString;
|
|
102
|
+
dimension: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
104
|
+
}, "strip", z.ZodTypeAny, {
|
|
105
|
+
provider: string;
|
|
106
|
+
config: {
|
|
107
|
+
collectionName: string;
|
|
108
|
+
dimension?: number | undefined;
|
|
109
|
+
} & {
|
|
110
|
+
[k: string]: unknown;
|
|
111
|
+
};
|
|
112
|
+
}, {
|
|
113
|
+
provider: string;
|
|
114
|
+
config: {
|
|
115
|
+
collectionName: string;
|
|
116
|
+
dimension?: number | undefined;
|
|
117
|
+
} & {
|
|
118
|
+
[k: string]: unknown;
|
|
119
|
+
};
|
|
120
|
+
}>;
|
|
121
|
+
llm: z.ZodObject<{
|
|
122
|
+
provider: z.ZodString;
|
|
123
|
+
config: z.ZodObject<{
|
|
124
|
+
apiKey: z.ZodString;
|
|
125
|
+
model: z.ZodOptional<z.ZodString>;
|
|
126
|
+
}, "strip", z.ZodTypeAny, {
|
|
127
|
+
apiKey: string;
|
|
128
|
+
model?: string | undefined;
|
|
129
|
+
}, {
|
|
130
|
+
apiKey: string;
|
|
131
|
+
model?: string | undefined;
|
|
132
|
+
}>;
|
|
133
|
+
}, "strip", z.ZodTypeAny, {
|
|
134
|
+
provider: string;
|
|
135
|
+
config: {
|
|
136
|
+
apiKey: string;
|
|
137
|
+
model?: string | undefined;
|
|
138
|
+
};
|
|
139
|
+
}, {
|
|
140
|
+
provider: string;
|
|
141
|
+
config: {
|
|
142
|
+
apiKey: string;
|
|
143
|
+
model?: string | undefined;
|
|
144
|
+
};
|
|
145
|
+
}>;
|
|
146
|
+
historyDbPath: z.ZodOptional<z.ZodString>;
|
|
147
|
+
customPrompt: z.ZodOptional<z.ZodString>;
|
|
148
|
+
graphStore: z.ZodOptional<z.ZodObject<{
|
|
149
|
+
config: z.ZodOptional<z.ZodAny>;
|
|
150
|
+
}, "strip", z.ZodTypeAny, {
|
|
151
|
+
config?: any;
|
|
152
|
+
}, {
|
|
153
|
+
config?: any;
|
|
154
|
+
}>>;
|
|
155
|
+
}, "strip", z.ZodTypeAny, {
|
|
156
|
+
embedder: {
|
|
157
|
+
provider: string;
|
|
158
|
+
config: {
|
|
159
|
+
apiKey: string;
|
|
160
|
+
model?: string | undefined;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
vectorStore: {
|
|
164
|
+
provider: string;
|
|
165
|
+
config: {
|
|
166
|
+
collectionName: string;
|
|
167
|
+
dimension?: number | undefined;
|
|
168
|
+
} & {
|
|
169
|
+
[k: string]: unknown;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
llm: {
|
|
173
|
+
provider: string;
|
|
174
|
+
config: {
|
|
175
|
+
apiKey: string;
|
|
176
|
+
model?: string | undefined;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
version?: string | undefined;
|
|
180
|
+
historyDbPath?: string | undefined;
|
|
181
|
+
customPrompt?: string | undefined;
|
|
182
|
+
graphStore?: {
|
|
183
|
+
config?: any;
|
|
184
|
+
} | undefined;
|
|
185
|
+
}, {
|
|
186
|
+
embedder: {
|
|
187
|
+
provider: string;
|
|
188
|
+
config: {
|
|
189
|
+
apiKey: string;
|
|
190
|
+
model?: string | undefined;
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
vectorStore: {
|
|
194
|
+
provider: string;
|
|
195
|
+
config: {
|
|
196
|
+
collectionName: string;
|
|
197
|
+
dimension?: number | undefined;
|
|
198
|
+
} & {
|
|
199
|
+
[k: string]: unknown;
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
llm: {
|
|
203
|
+
provider: string;
|
|
204
|
+
config: {
|
|
205
|
+
apiKey: string;
|
|
206
|
+
model?: string | undefined;
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
version?: string | undefined;
|
|
210
|
+
historyDbPath?: string | undefined;
|
|
211
|
+
customPrompt?: string | undefined;
|
|
212
|
+
graphStore?: {
|
|
213
|
+
config?: any;
|
|
214
|
+
} | undefined;
|
|
215
|
+
}>;
|
|
216
|
+
|
|
217
|
+
declare class Memory {
|
|
218
|
+
private config;
|
|
219
|
+
private customPrompt;
|
|
220
|
+
private embedder;
|
|
221
|
+
private vectorStore;
|
|
222
|
+
private llm;
|
|
223
|
+
private db;
|
|
224
|
+
private collectionName;
|
|
225
|
+
private apiVersion;
|
|
226
|
+
constructor(config?: Partial<MemoryConfig>);
|
|
227
|
+
static fromConfig(configDict: Record<string, any>): Memory;
|
|
228
|
+
add(messages: string | Message[], userId?: string, agentId?: string, runId?: string, metadata?: Record<string, any>, filters?: SearchFilters, prompt?: string): Promise<SearchResult>;
|
|
229
|
+
private addToVectorStore;
|
|
230
|
+
get(memoryId: string): Promise<MemoryItem | null>;
|
|
231
|
+
search(query: string, userId?: string, agentId?: string, runId?: string, limit?: number, filters?: SearchFilters): Promise<SearchResult>;
|
|
232
|
+
update(memoryId: string, data: string): Promise<{
|
|
233
|
+
message: string;
|
|
234
|
+
}>;
|
|
235
|
+
delete(memoryId: string): Promise<{
|
|
236
|
+
message: string;
|
|
237
|
+
}>;
|
|
238
|
+
deleteAll(userId?: string, agentId?: string, runId?: string): Promise<{
|
|
239
|
+
message: string;
|
|
240
|
+
}>;
|
|
241
|
+
history(memoryId: string): Promise<any[]>;
|
|
242
|
+
reset(): Promise<void>;
|
|
243
|
+
getAll(userId?: string, agentId?: string, runId?: string, limit?: number): Promise<SearchResult>;
|
|
244
|
+
private createMemory;
|
|
245
|
+
private updateMemory;
|
|
246
|
+
private deleteMemory;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
interface Embedder {
|
|
250
|
+
embed(text: string): Promise<number[]>;
|
|
251
|
+
embedBatch(texts: string[]): Promise<number[][]>;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
declare class OpenAIEmbedder implements Embedder {
|
|
255
|
+
private openai;
|
|
256
|
+
private model;
|
|
257
|
+
constructor(config: EmbeddingConfig);
|
|
258
|
+
embed(text: string): Promise<number[]>;
|
|
259
|
+
embedBatch(texts: string[]): Promise<number[][]>;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
interface LLMResponse {
|
|
263
|
+
content: string;
|
|
264
|
+
role: string;
|
|
265
|
+
}
|
|
266
|
+
interface LLM {
|
|
267
|
+
generateResponse(messages: Message[], responseFormat?: {
|
|
268
|
+
type: string;
|
|
269
|
+
}): Promise<string>;
|
|
270
|
+
generateChat(messages: Message[]): Promise<LLMResponse>;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
declare class OpenAILLM implements LLM {
|
|
274
|
+
private openai;
|
|
275
|
+
private model;
|
|
276
|
+
constructor(config: LLMConfig);
|
|
277
|
+
generateResponse(messages: Message[], responseFormat?: {
|
|
278
|
+
type: string;
|
|
279
|
+
}): Promise<string>;
|
|
280
|
+
generateChat(messages: Message[]): Promise<LLMResponse>;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
declare class OpenAIStructuredLLM implements LLM {
|
|
284
|
+
private client;
|
|
285
|
+
private model;
|
|
286
|
+
constructor(config: LLMConfig);
|
|
287
|
+
generateResponse(messages: Message[], responseFormat?: {
|
|
288
|
+
type: string;
|
|
289
|
+
}): Promise<string>;
|
|
290
|
+
generateChat(messages: Message[]): Promise<LLMResponse>;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
declare class AnthropicLLM implements LLM {
|
|
294
|
+
private client;
|
|
295
|
+
private model;
|
|
296
|
+
constructor(config: LLMConfig);
|
|
297
|
+
generateResponse(messages: Message[], responseFormat?: {
|
|
298
|
+
type: string;
|
|
299
|
+
}): Promise<string>;
|
|
300
|
+
generateChat(messages: Message[]): Promise<LLMResponse>;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
declare class GroqLLM implements LLM {
|
|
304
|
+
private client;
|
|
305
|
+
private model;
|
|
306
|
+
constructor(config: LLMConfig);
|
|
307
|
+
generateResponse(messages: Message[], responseFormat?: {
|
|
308
|
+
type: string;
|
|
309
|
+
}): Promise<string>;
|
|
310
|
+
generateChat(messages: Message[]): Promise<LLMResponse>;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
interface VectorStore {
|
|
314
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
315
|
+
search(query: number[], limit?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
316
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
317
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
318
|
+
delete(vectorId: string): Promise<void>;
|
|
319
|
+
deleteCol(): Promise<void>;
|
|
320
|
+
list(filters?: SearchFilters, limit?: number): Promise<[VectorStoreResult[], number]>;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
declare class MemoryVectorStore implements VectorStore {
|
|
324
|
+
private vectors;
|
|
325
|
+
private dimension;
|
|
326
|
+
constructor(config: VectorStoreConfig);
|
|
327
|
+
private cosineSimilarity;
|
|
328
|
+
private filterVector;
|
|
329
|
+
insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
|
|
330
|
+
search(query: number[], limit?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
|
|
331
|
+
get(vectorId: string): Promise<VectorStoreResult | null>;
|
|
332
|
+
update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
|
|
333
|
+
delete(vectorId: string): Promise<void>;
|
|
334
|
+
deleteCol(): Promise<void>;
|
|
335
|
+
list(filters?: SearchFilters, limit?: number): Promise<[VectorStoreResult[], number]>;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
declare class EmbedderFactory {
|
|
339
|
+
static create(provider: string, config: EmbeddingConfig): Embedder;
|
|
340
|
+
}
|
|
341
|
+
declare class LLMFactory {
|
|
342
|
+
static create(provider: string, config: LLMConfig): LLM;
|
|
343
|
+
}
|
|
344
|
+
declare class VectorStoreFactory {
|
|
345
|
+
static create(provider: string, config: VectorStoreConfig): VectorStore;
|
|
346
|
+
}
|
|
347
|
+
|
|
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 };
|