mem0ai 3.0.1 → 3.0.2
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 +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/oss/index.d.mts +8 -0
- package/dist/oss/index.d.ts +8 -0
- package/dist/oss/index.js +101 -7
- package/dist/oss/index.js.map +1 -1
- package/dist/oss/index.mjs +101 -7
- package/dist/oss/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/oss/index.d.mts
CHANGED
|
@@ -45,6 +45,7 @@ interface LLMConfig {
|
|
|
45
45
|
apiKey?: string;
|
|
46
46
|
model?: string | any;
|
|
47
47
|
modelProperties?: Record<string, any>;
|
|
48
|
+
timeout?: number;
|
|
48
49
|
}
|
|
49
50
|
interface MemoryConfig {
|
|
50
51
|
version?: string;
|
|
@@ -182,18 +183,21 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
182
183
|
modelProperties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
183
184
|
baseURL: z.ZodOptional<z.ZodString>;
|
|
184
185
|
url: z.ZodOptional<z.ZodString>;
|
|
186
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
185
187
|
}, "strip", z.ZodTypeAny, {
|
|
186
188
|
modelProperties?: Record<string, any> | undefined;
|
|
187
189
|
apiKey?: string | undefined;
|
|
188
190
|
model?: any;
|
|
189
191
|
baseURL?: string | undefined;
|
|
190
192
|
url?: string | undefined;
|
|
193
|
+
timeout?: number | undefined;
|
|
191
194
|
}, {
|
|
192
195
|
modelProperties?: Record<string, any> | undefined;
|
|
193
196
|
apiKey?: string | undefined;
|
|
194
197
|
model?: any;
|
|
195
198
|
baseURL?: string | undefined;
|
|
196
199
|
url?: string | undefined;
|
|
200
|
+
timeout?: number | undefined;
|
|
197
201
|
}>;
|
|
198
202
|
}, "strip", z.ZodTypeAny, {
|
|
199
203
|
provider: string;
|
|
@@ -203,6 +207,7 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
203
207
|
model?: any;
|
|
204
208
|
baseURL?: string | undefined;
|
|
205
209
|
url?: string | undefined;
|
|
210
|
+
timeout?: number | undefined;
|
|
206
211
|
};
|
|
207
212
|
}, {
|
|
208
213
|
provider: string;
|
|
@@ -212,6 +217,7 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
212
217
|
model?: any;
|
|
213
218
|
baseURL?: string | undefined;
|
|
214
219
|
url?: string | undefined;
|
|
220
|
+
timeout?: number | undefined;
|
|
215
221
|
};
|
|
216
222
|
}>;
|
|
217
223
|
historyDbPath: z.ZodOptional<z.ZodString>;
|
|
@@ -258,6 +264,7 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
258
264
|
model?: any;
|
|
259
265
|
baseURL?: string | undefined;
|
|
260
266
|
url?: string | undefined;
|
|
267
|
+
timeout?: number | undefined;
|
|
261
268
|
};
|
|
262
269
|
};
|
|
263
270
|
version?: string | undefined;
|
|
@@ -299,6 +306,7 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
299
306
|
model?: any;
|
|
300
307
|
baseURL?: string | undefined;
|
|
301
308
|
url?: string | undefined;
|
|
309
|
+
timeout?: number | undefined;
|
|
302
310
|
};
|
|
303
311
|
};
|
|
304
312
|
version?: string | undefined;
|
package/dist/oss/index.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ interface LLMConfig {
|
|
|
45
45
|
apiKey?: string;
|
|
46
46
|
model?: string | any;
|
|
47
47
|
modelProperties?: Record<string, any>;
|
|
48
|
+
timeout?: number;
|
|
48
49
|
}
|
|
49
50
|
interface MemoryConfig {
|
|
50
51
|
version?: string;
|
|
@@ -182,18 +183,21 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
182
183
|
modelProperties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
183
184
|
baseURL: z.ZodOptional<z.ZodString>;
|
|
184
185
|
url: z.ZodOptional<z.ZodString>;
|
|
186
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
185
187
|
}, "strip", z.ZodTypeAny, {
|
|
186
188
|
modelProperties?: Record<string, any> | undefined;
|
|
187
189
|
apiKey?: string | undefined;
|
|
188
190
|
model?: any;
|
|
189
191
|
baseURL?: string | undefined;
|
|
190
192
|
url?: string | undefined;
|
|
193
|
+
timeout?: number | undefined;
|
|
191
194
|
}, {
|
|
192
195
|
modelProperties?: Record<string, any> | undefined;
|
|
193
196
|
apiKey?: string | undefined;
|
|
194
197
|
model?: any;
|
|
195
198
|
baseURL?: string | undefined;
|
|
196
199
|
url?: string | undefined;
|
|
200
|
+
timeout?: number | undefined;
|
|
197
201
|
}>;
|
|
198
202
|
}, "strip", z.ZodTypeAny, {
|
|
199
203
|
provider: string;
|
|
@@ -203,6 +207,7 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
203
207
|
model?: any;
|
|
204
208
|
baseURL?: string | undefined;
|
|
205
209
|
url?: string | undefined;
|
|
210
|
+
timeout?: number | undefined;
|
|
206
211
|
};
|
|
207
212
|
}, {
|
|
208
213
|
provider: string;
|
|
@@ -212,6 +217,7 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
212
217
|
model?: any;
|
|
213
218
|
baseURL?: string | undefined;
|
|
214
219
|
url?: string | undefined;
|
|
220
|
+
timeout?: number | undefined;
|
|
215
221
|
};
|
|
216
222
|
}>;
|
|
217
223
|
historyDbPath: z.ZodOptional<z.ZodString>;
|
|
@@ -258,6 +264,7 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
258
264
|
model?: any;
|
|
259
265
|
baseURL?: string | undefined;
|
|
260
266
|
url?: string | undefined;
|
|
267
|
+
timeout?: number | undefined;
|
|
261
268
|
};
|
|
262
269
|
};
|
|
263
270
|
version?: string | undefined;
|
|
@@ -299,6 +306,7 @@ declare const MemoryConfigSchema: z.ZodObject<{
|
|
|
299
306
|
model?: any;
|
|
300
307
|
baseURL?: string | undefined;
|
|
301
308
|
url?: string | undefined;
|
|
309
|
+
timeout?: number | undefined;
|
|
302
310
|
};
|
|
303
311
|
};
|
|
304
312
|
version?: string | undefined;
|
package/dist/oss/index.js
CHANGED
|
@@ -97,7 +97,8 @@ var MemoryConfigSchema = import_zod.z.object({
|
|
|
97
97
|
model: import_zod.z.union([import_zod.z.string(), import_zod.z.any()]).optional(),
|
|
98
98
|
modelProperties: import_zod.z.record(import_zod.z.string(), import_zod.z.any()).optional(),
|
|
99
99
|
baseURL: import_zod.z.string().optional(),
|
|
100
|
-
url: import_zod.z.string().optional()
|
|
100
|
+
url: import_zod.z.string().optional(),
|
|
101
|
+
timeout: import_zod.z.number().optional()
|
|
101
102
|
})
|
|
102
103
|
}),
|
|
103
104
|
historyDbPath: import_zod.z.string().optional(),
|
|
@@ -268,7 +269,8 @@ var OpenAILLM = class {
|
|
|
268
269
|
constructor(config) {
|
|
269
270
|
this.openai = new import_openai3.default({
|
|
270
271
|
apiKey: config.apiKey,
|
|
271
|
-
baseURL: config.baseURL
|
|
272
|
+
baseURL: config.baseURL,
|
|
273
|
+
...config.timeout != null && { timeout: config.timeout }
|
|
272
274
|
});
|
|
273
275
|
this.model = config.model || "gpt-5-mini";
|
|
274
276
|
}
|
|
@@ -321,7 +323,11 @@ var OpenAILLM = class {
|
|
|
321
323
|
var import_openai4 = __toESM(require("openai"));
|
|
322
324
|
var OpenAIStructuredLLM = class {
|
|
323
325
|
constructor(config) {
|
|
324
|
-
this.openai = new import_openai4.default({
|
|
326
|
+
this.openai = new import_openai4.default({
|
|
327
|
+
apiKey: config.apiKey,
|
|
328
|
+
baseURL: config.baseURL,
|
|
329
|
+
...config.timeout != null && { timeout: config.timeout }
|
|
330
|
+
});
|
|
325
331
|
this.model = config.model || "gpt-5-mini";
|
|
326
332
|
}
|
|
327
333
|
async generateResponse(messages, responseFormat, tools) {
|
|
@@ -3542,17 +3548,105 @@ function removeCodeBlocks(text) {
|
|
|
3542
3548
|
return stripped.replace(/<think>[\s\S]*?<\/think>/g, "").trim();
|
|
3543
3549
|
}
|
|
3544
3550
|
function extractJson(text) {
|
|
3545
|
-
|
|
3551
|
+
let cleaned = text.replace(/<\|end_of_text\|>/g, "").replace(/<\|eot_id\|>/g, "").replace(/<\|im_end\|>/g, "").replace(/<\|im_start\|>/g, "").replace(/<\|endoftext\|>/g, "");
|
|
3552
|
+
cleaned = removeCodeBlocks(cleaned);
|
|
3546
3553
|
const trimmed = cleaned.trim();
|
|
3554
|
+
if (!trimmed) return "";
|
|
3555
|
+
const braceIndices = [];
|
|
3556
|
+
for (let i = 0; i < trimmed.length; i++) {
|
|
3557
|
+
if (trimmed[i] === "{") braceIndices.push(i);
|
|
3558
|
+
}
|
|
3559
|
+
for (const start of braceIndices) {
|
|
3560
|
+
let depth = 0;
|
|
3561
|
+
let inString = false;
|
|
3562
|
+
let escapeNext = false;
|
|
3563
|
+
for (let i = start; i < trimmed.length; i++) {
|
|
3564
|
+
const char = trimmed[i];
|
|
3565
|
+
if (escapeNext) {
|
|
3566
|
+
escapeNext = false;
|
|
3567
|
+
continue;
|
|
3568
|
+
}
|
|
3569
|
+
if (char === "\\") {
|
|
3570
|
+
escapeNext = true;
|
|
3571
|
+
continue;
|
|
3572
|
+
}
|
|
3573
|
+
if (char === '"' && !escapeNext) {
|
|
3574
|
+
inString = !inString;
|
|
3575
|
+
continue;
|
|
3576
|
+
}
|
|
3577
|
+
if (inString) continue;
|
|
3578
|
+
if (char === "{") depth++;
|
|
3579
|
+
else if (char === "}") {
|
|
3580
|
+
depth--;
|
|
3581
|
+
if (depth === 0) {
|
|
3582
|
+
const candidate = trimmed.substring(start, i + 1);
|
|
3583
|
+
try {
|
|
3584
|
+
JSON.parse(candidate);
|
|
3585
|
+
return candidate;
|
|
3586
|
+
} catch (e) {
|
|
3587
|
+
break;
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3547
3593
|
const firstBrace = trimmed.indexOf("{");
|
|
3548
3594
|
const lastBrace = trimmed.lastIndexOf("}");
|
|
3549
3595
|
if (firstBrace !== -1 && lastBrace > firstBrace) {
|
|
3550
|
-
|
|
3596
|
+
const candidate = trimmed.substring(firstBrace, lastBrace + 1);
|
|
3597
|
+
try {
|
|
3598
|
+
JSON.parse(candidate);
|
|
3599
|
+
return candidate;
|
|
3600
|
+
} catch (e) {
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
const bracketIndices = [];
|
|
3604
|
+
for (let i = 0; i < trimmed.length; i++) {
|
|
3605
|
+
if (trimmed[i] === "[") bracketIndices.push(i);
|
|
3606
|
+
}
|
|
3607
|
+
for (const start of bracketIndices) {
|
|
3608
|
+
let depth = 0;
|
|
3609
|
+
let inString = false;
|
|
3610
|
+
let escapeNext = false;
|
|
3611
|
+
for (let i = start; i < trimmed.length; i++) {
|
|
3612
|
+
const char = trimmed[i];
|
|
3613
|
+
if (escapeNext) {
|
|
3614
|
+
escapeNext = false;
|
|
3615
|
+
continue;
|
|
3616
|
+
}
|
|
3617
|
+
if (char === "\\") {
|
|
3618
|
+
escapeNext = true;
|
|
3619
|
+
continue;
|
|
3620
|
+
}
|
|
3621
|
+
if (char === '"' && !escapeNext) {
|
|
3622
|
+
inString = !inString;
|
|
3623
|
+
continue;
|
|
3624
|
+
}
|
|
3625
|
+
if (inString) continue;
|
|
3626
|
+
if (char === "[") depth++;
|
|
3627
|
+
else if (char === "]") {
|
|
3628
|
+
depth--;
|
|
3629
|
+
if (depth === 0) {
|
|
3630
|
+
const candidate = trimmed.substring(start, i + 1);
|
|
3631
|
+
try {
|
|
3632
|
+
JSON.parse(candidate);
|
|
3633
|
+
return candidate;
|
|
3634
|
+
} catch (e) {
|
|
3635
|
+
break;
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
}
|
|
3551
3640
|
}
|
|
3552
3641
|
const firstBracket = trimmed.indexOf("[");
|
|
3553
3642
|
const lastBracket = trimmed.lastIndexOf("]");
|
|
3554
3643
|
if (firstBracket !== -1 && lastBracket > firstBracket) {
|
|
3555
|
-
|
|
3644
|
+
const candidate = trimmed.substring(firstBracket, lastBracket + 1);
|
|
3645
|
+
try {
|
|
3646
|
+
JSON.parse(candidate);
|
|
3647
|
+
return candidate;
|
|
3648
|
+
} catch (e) {
|
|
3649
|
+
}
|
|
3556
3650
|
}
|
|
3557
3651
|
return trimmed;
|
|
3558
3652
|
}
|
|
@@ -4918,7 +5012,7 @@ var parse_vision_messages = async (messages) => {
|
|
|
4918
5012
|
};
|
|
4919
5013
|
|
|
4920
5014
|
// src/oss/src/utils/telemetry.ts
|
|
4921
|
-
var version = "3.0.
|
|
5015
|
+
var version = true ? "3.0.2" : "dev";
|
|
4922
5016
|
var MEM0_TELEMETRY = true;
|
|
4923
5017
|
var _a;
|
|
4924
5018
|
try {
|