mem0ai 2.1.15 → 2.1.16-patch.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.
@@ -35,6 +35,7 @@ interface LLMConfig {
35
35
  config?: Record<string, any>;
36
36
  apiKey?: string;
37
37
  model?: string;
38
+ modelProperties?: Record<string, any>;
38
39
  }
39
40
  interface Neo4jConfig {
40
41
  url: string;
@@ -153,24 +154,29 @@ declare const MemoryConfigSchema: z.ZodObject<{
153
154
  config: z.ZodObject<{
154
155
  apiKey: z.ZodString;
155
156
  model: z.ZodOptional<z.ZodString>;
157
+ modelProperties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
156
158
  }, "strip", z.ZodTypeAny, {
157
159
  apiKey: string;
158
160
  model?: string | undefined;
161
+ modelProperties?: Record<string, any> | undefined;
159
162
  }, {
160
163
  apiKey: string;
161
164
  model?: string | undefined;
165
+ modelProperties?: Record<string, any> | undefined;
162
166
  }>;
163
167
  }, "strip", z.ZodTypeAny, {
164
168
  provider: string;
165
169
  config: {
166
170
  apiKey: string;
167
171
  model?: string | undefined;
172
+ modelProperties?: Record<string, any> | undefined;
168
173
  };
169
174
  }, {
170
175
  provider: string;
171
176
  config: {
172
177
  apiKey: string;
173
178
  model?: string | undefined;
179
+ modelProperties?: Record<string, any> | undefined;
174
180
  };
175
181
  }>;
176
182
  historyDbPath: z.ZodOptional<z.ZodString>;
@@ -260,6 +266,7 @@ declare const MemoryConfigSchema: z.ZodObject<{
260
266
  config: {
261
267
  apiKey: string;
262
268
  model?: string | undefined;
269
+ modelProperties?: Record<string, any> | undefined;
263
270
  };
264
271
  };
265
272
  version?: string | undefined;
@@ -306,6 +313,7 @@ declare const MemoryConfigSchema: z.ZodObject<{
306
313
  config: {
307
314
  apiKey: string;
308
315
  model?: string | undefined;
316
+ modelProperties?: Record<string, any> | undefined;
309
317
  };
310
318
  };
311
319
  version?: string | undefined;
@@ -501,6 +509,17 @@ declare class OllamaLLM implements LLM {
501
509
  private ensureModelExists;
502
510
  }
503
511
 
512
+ declare class MistralLLM implements LLM {
513
+ private client;
514
+ private model;
515
+ constructor(config: LLMConfig);
516
+ private contentToString;
517
+ generateResponse(messages: Message[], responseFormat?: {
518
+ type: string;
519
+ }, tools?: any[]): Promise<string | LLMResponse>;
520
+ generateChat(messages: Message[]): Promise<LLMResponse>;
521
+ }
522
+
504
523
  interface VectorStore {
505
524
  insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
506
525
  search(query: number[], limit?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
@@ -615,4 +634,4 @@ declare class HistoryManagerFactory {
615
634
  static create(provider: string, config: HistoryStoreConfig): HistoryManager;
616
635
  }
617
636
 
618
- export { type AddMemoryOptions, AnthropicLLM, type DeleteAllMemoryOptions, type Embedder, EmbedderFactory, type EmbeddingConfig, type Entity, type GetAllMemoryOptions, GoogleEmbedder, GoogleLLM, type GraphStoreConfig, GroqLLM, HistoryManagerFactory, type HistoryStoreConfig, type LLM, type LLMConfig, LLMFactory, type LLMResponse, Memory, type MemoryConfig, MemoryConfigSchema, type MemoryItem, MemoryVectorStore, type Message, type MultiModalMessages, type Neo4jConfig, OllamaEmbedder, OllamaLLM, OpenAIEmbedder, OpenAILLM, OpenAIStructuredLLM, Qdrant, RedisDB, type SearchFilters, type SearchMemoryOptions, type SearchResult, type VectorStore, type VectorStoreConfig, VectorStoreFactory, type VectorStoreResult };
637
+ export { type AddMemoryOptions, AnthropicLLM, type DeleteAllMemoryOptions, type Embedder, EmbedderFactory, type EmbeddingConfig, type Entity, type GetAllMemoryOptions, GoogleEmbedder, GoogleLLM, type GraphStoreConfig, GroqLLM, HistoryManagerFactory, type HistoryStoreConfig, type LLM, type LLMConfig, LLMFactory, type LLMResponse, Memory, type MemoryConfig, MemoryConfigSchema, type MemoryItem, MemoryVectorStore, type Message, MistralLLM, type MultiModalMessages, type Neo4jConfig, OllamaEmbedder, OllamaLLM, 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,7 @@ __export(index_exports, {
40
40
  Memory: () => Memory,
41
41
  MemoryConfigSchema: () => MemoryConfigSchema,
42
42
  MemoryVectorStore: () => MemoryVectorStore,
43
+ MistralLLM: () => MistralLLM,
43
44
  OllamaEmbedder: () => OllamaEmbedder,
44
45
  OllamaLLM: () => OllamaLLM,
45
46
  OpenAIEmbedder: () => OpenAIEmbedder,
@@ -77,7 +78,8 @@ var MemoryConfigSchema = import_zod.z.object({
77
78
  provider: import_zod.z.string(),
78
79
  config: import_zod.z.object({
79
80
  apiKey: import_zod.z.string(),
80
- model: import_zod.z.string().optional()
81
+ model: import_zod.z.string().optional(),
82
+ modelProperties: import_zod.z.record(import_zod.z.string(), import_zod.z.any()).optional()
81
83
  })
82
84
  }),
83
85
  historyDbPath: import_zod.z.string().optional(),
@@ -363,6 +365,86 @@ var GroqLLM = class {
363
365
  }
364
366
  };
365
367
 
368
+ // src/oss/src/llms/mistral.ts
369
+ var import_mistralai = require("@mistralai/mistralai");
370
+ var MistralLLM = class {
371
+ constructor(config) {
372
+ if (!config.apiKey) {
373
+ throw new Error("Mistral API key is required");
374
+ }
375
+ this.client = new import_mistralai.Mistral({
376
+ apiKey: config.apiKey
377
+ });
378
+ this.model = config.model || "mistral-tiny-latest";
379
+ }
380
+ // Helper function to convert content to string
381
+ contentToString(content) {
382
+ if (typeof content === "string") {
383
+ return content;
384
+ }
385
+ if (Array.isArray(content)) {
386
+ return content.map((chunk) => {
387
+ if (chunk.type === "text") {
388
+ return chunk.text;
389
+ } else {
390
+ return JSON.stringify(chunk);
391
+ }
392
+ }).join("");
393
+ }
394
+ return String(content || "");
395
+ }
396
+ async generateResponse(messages, responseFormat, tools) {
397
+ const response = await this.client.chat.complete({
398
+ model: this.model,
399
+ messages: messages.map((msg) => ({
400
+ role: msg.role,
401
+ content: typeof msg.content === "string" ? msg.content : JSON.stringify(msg.content)
402
+ })),
403
+ ...tools && { tools },
404
+ ...responseFormat && { response_format: responseFormat }
405
+ });
406
+ if (!response || !response.choices || response.choices.length === 0) {
407
+ return "";
408
+ }
409
+ const message = response.choices[0].message;
410
+ if (!message) {
411
+ return "";
412
+ }
413
+ if (message.toolCalls && message.toolCalls.length > 0) {
414
+ return {
415
+ content: this.contentToString(message.content),
416
+ role: message.role || "assistant",
417
+ toolCalls: message.toolCalls.map((call) => ({
418
+ name: call.function.name,
419
+ arguments: typeof call.function.arguments === "string" ? call.function.arguments : JSON.stringify(call.function.arguments)
420
+ }))
421
+ };
422
+ }
423
+ return this.contentToString(message.content);
424
+ }
425
+ async generateChat(messages) {
426
+ const formattedMessages = messages.map((msg) => ({
427
+ role: msg.role,
428
+ content: typeof msg.content === "string" ? msg.content : JSON.stringify(msg.content)
429
+ }));
430
+ const response = await this.client.chat.complete({
431
+ model: this.model,
432
+ messages: formattedMessages
433
+ });
434
+ if (!response || !response.choices || response.choices.length === 0) {
435
+ return {
436
+ content: "",
437
+ role: "assistant"
438
+ };
439
+ }
440
+ const message = response.choices[0].message;
441
+ return {
442
+ content: this.contentToString(message.content),
443
+ role: message.role || "assistant"
444
+ };
445
+ }
446
+ };
447
+
366
448
  // src/oss/src/vector_stores/memory.ts
367
449
  var import_sqlite3 = __toESM(require("sqlite3"));
368
450
  var import_path = __toESM(require("path"));
@@ -1823,6 +1905,67 @@ var GoogleLLM = class {
1823
1905
  }
1824
1906
  };
1825
1907
 
1908
+ // src/oss/src/llms/azure.ts
1909
+ var import_openai4 = require("openai");
1910
+ var AzureOpenAILLM = class {
1911
+ constructor(config) {
1912
+ var _a2;
1913
+ if (!config.apiKey || !((_a2 = config.modelProperties) == null ? void 0 : _a2.endpoint)) {
1914
+ throw new Error("Azure OpenAI requires both API key and endpoint");
1915
+ }
1916
+ const { endpoint, ...rest } = config.modelProperties;
1917
+ this.client = new import_openai4.AzureOpenAI({
1918
+ apiKey: config.apiKey,
1919
+ endpoint,
1920
+ ...rest
1921
+ });
1922
+ this.model = config.model || "gpt-4";
1923
+ }
1924
+ async generateResponse(messages, responseFormat, tools) {
1925
+ const completion = await this.client.chat.completions.create({
1926
+ messages: messages.map((msg) => {
1927
+ const role = msg.role;
1928
+ return {
1929
+ role,
1930
+ content: typeof msg.content === "string" ? msg.content : JSON.stringify(msg.content)
1931
+ };
1932
+ }),
1933
+ model: this.model,
1934
+ response_format: responseFormat,
1935
+ ...tools && { tools, tool_choice: "auto" }
1936
+ });
1937
+ const response = completion.choices[0].message;
1938
+ if (response.tool_calls) {
1939
+ return {
1940
+ content: response.content || "",
1941
+ role: response.role,
1942
+ toolCalls: response.tool_calls.map((call) => ({
1943
+ name: call.function.name,
1944
+ arguments: call.function.arguments
1945
+ }))
1946
+ };
1947
+ }
1948
+ return response.content || "";
1949
+ }
1950
+ async generateChat(messages) {
1951
+ const completion = await this.client.chat.completions.create({
1952
+ messages: messages.map((msg) => {
1953
+ const role = msg.role;
1954
+ return {
1955
+ role,
1956
+ content: typeof msg.content === "string" ? msg.content : JSON.stringify(msg.content)
1957
+ };
1958
+ }),
1959
+ model: this.model
1960
+ });
1961
+ const response = completion.choices[0].message;
1962
+ return {
1963
+ content: response.content || "",
1964
+ role: response.role
1965
+ };
1966
+ }
1967
+ };
1968
+
1826
1969
  // src/oss/src/utils/factory.ts
1827
1970
  var EmbedderFactory = class {
1828
1971
  static create(provider, config) {
@@ -1853,6 +1996,10 @@ var LLMFactory = class {
1853
1996
  return new OllamaLLM(config);
1854
1997
  case "google":
1855
1998
  return new GoogleLLM(config);
1999
+ case "azure_openai":
2000
+ return new AzureOpenAILLM(config);
2001
+ case "mistral":
2002
+ return new MistralLLM(config);
1856
2003
  default:
1857
2004
  throw new Error(`Unsupported LLM provider: ${provider}`);
1858
2005
  }
@@ -2196,7 +2343,7 @@ var DEFAULT_MEMORY_CONFIG = {
2196
2343
  // src/oss/src/config/manager.ts
2197
2344
  var ConfigManager = class {
2198
2345
  static mergeConfig(userConfig = {}) {
2199
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
2346
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
2200
2347
  const mergedConfig = {
2201
2348
  version: userConfig.version || DEFAULT_MEMORY_CONFIG.version,
2202
2349
  embedder: {
@@ -2218,7 +2365,8 @@ var ConfigManager = class {
2218
2365
  provider: ((_l = userConfig.llm) == null ? void 0 : _l.provider) || DEFAULT_MEMORY_CONFIG.llm.provider,
2219
2366
  config: {
2220
2367
  apiKey: ((_n = (_m = userConfig.llm) == null ? void 0 : _m.config) == null ? void 0 : _n.apiKey) || DEFAULT_MEMORY_CONFIG.llm.config.apiKey,
2221
- model: ((_p = (_o = userConfig.llm) == null ? void 0 : _o.config) == null ? void 0 : _p.model) || DEFAULT_MEMORY_CONFIG.llm.config.model
2368
+ model: ((_p = (_o = userConfig.llm) == null ? void 0 : _o.config) == null ? void 0 : _p.model) || DEFAULT_MEMORY_CONFIG.llm.config.model,
2369
+ modelProperties: ((_r = (_q = userConfig.llm) == null ? void 0 : _q.config) == null ? void 0 : _r.modelProperties) || DEFAULT_MEMORY_CONFIG.llm.config.modelProperties
2222
2370
  }
2223
2371
  },
2224
2372
  historyDbPath: userConfig.historyDbPath || DEFAULT_MEMORY_CONFIG.historyDbPath,
@@ -2994,7 +3142,7 @@ var parse_vision_messages = async (messages) => {
2994
3142
  };
2995
3143
 
2996
3144
  // src/oss/src/utils/telemetry.ts
2997
- var version = "2.1.15";
3145
+ var version = "2.1.16";
2998
3146
  var MEM0_TELEMETRY = true;
2999
3147
  var _a;
3000
3148
  try {
@@ -3561,6 +3709,7 @@ ${parsedMessages}`] : getFactRetrievalMessages(parsedMessages);
3561
3709
  Memory,
3562
3710
  MemoryConfigSchema,
3563
3711
  MemoryVectorStore,
3712
+ MistralLLM,
3564
3713
  OllamaEmbedder,
3565
3714
  OllamaLLM,
3566
3715
  OpenAIEmbedder,