mem0ai 3.0.9 → 3.0.10
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/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -3
- package/dist/index.mjs.map +1 -1
- package/dist/oss/index.d.mts +1 -0
- package/dist/oss/index.d.ts +1 -0
- package/dist/oss/index.js +45 -9
- package/dist/oss/index.js.map +1 -1
- package/dist/oss/index.mjs +45 -9
- package/dist/oss/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/oss/index.mjs
CHANGED
|
@@ -339,7 +339,11 @@ var AnthropicLLM = class {
|
|
|
339
339
|
if (!apiKey) {
|
|
340
340
|
throw new Error("Anthropic API key is required");
|
|
341
341
|
}
|
|
342
|
-
|
|
342
|
+
const clientArgs = { apiKey };
|
|
343
|
+
if (config.baseURL) {
|
|
344
|
+
clientArgs.baseURL = config.baseURL;
|
|
345
|
+
}
|
|
346
|
+
this.client = new Anthropic(clientArgs);
|
|
343
347
|
this.model = config.model || "claude-sonnet-4-6";
|
|
344
348
|
this.maxTokens = (_a2 = config.maxTokens) != null ? _a2 : 2e3;
|
|
345
349
|
this.temperature = (_b2 = config.temperature) != null ? _b2 : 0.1;
|
|
@@ -5094,6 +5098,7 @@ var get_image_description = async (image_url) => {
|
|
|
5094
5098
|
return response;
|
|
5095
5099
|
};
|
|
5096
5100
|
var parse_vision_messages = async (messages) => {
|
|
5101
|
+
var _a2;
|
|
5097
5102
|
const parsed_messages = [];
|
|
5098
5103
|
for (const message of messages) {
|
|
5099
5104
|
let new_message = {
|
|
@@ -5102,9 +5107,11 @@ var parse_vision_messages = async (messages) => {
|
|
|
5102
5107
|
};
|
|
5103
5108
|
if (message.role !== "system") {
|
|
5104
5109
|
if (typeof message.content === "object" && message.content.type === "image_url") {
|
|
5105
|
-
const
|
|
5106
|
-
|
|
5107
|
-
|
|
5110
|
+
const imageUrl = (_a2 = message.content.image_url) == null ? void 0 : _a2.url;
|
|
5111
|
+
if (!imageUrl) {
|
|
5112
|
+
throw new Error("image_url content part is missing image_url.url");
|
|
5113
|
+
}
|
|
5114
|
+
const description = await get_image_description(imageUrl);
|
|
5108
5115
|
new_message.content = typeof description === "string" ? description : JSON.stringify(description);
|
|
5109
5116
|
parsed_messages.push(new_message);
|
|
5110
5117
|
} else parsed_messages.push(message);
|
|
@@ -5114,7 +5121,7 @@ var parse_vision_messages = async (messages) => {
|
|
|
5114
5121
|
};
|
|
5115
5122
|
|
|
5116
5123
|
// src/oss/src/utils/telemetry.ts
|
|
5117
|
-
var version = true ? "3.0.
|
|
5124
|
+
var version = true ? "3.0.10" : "dev";
|
|
5118
5125
|
var MEM0_TELEMETRY = true;
|
|
5119
5126
|
var _a, _b;
|
|
5120
5127
|
try {
|
|
@@ -7538,6 +7545,25 @@ var Memory = class _Memory {
|
|
|
7538
7545
|
"messages is required and cannot be undefined or null. Provide a string or array of messages."
|
|
7539
7546
|
);
|
|
7540
7547
|
}
|
|
7548
|
+
if (Array.isArray(messages)) {
|
|
7549
|
+
if (messages.length === 0) {
|
|
7550
|
+
throw new Error(
|
|
7551
|
+
"messages array cannot be empty. Provide at least one message with non-empty content."
|
|
7552
|
+
);
|
|
7553
|
+
}
|
|
7554
|
+
const allBlank = messages.every(
|
|
7555
|
+
(m) => typeof m.content === "string" && m.content.trim() === ""
|
|
7556
|
+
);
|
|
7557
|
+
if (allBlank) {
|
|
7558
|
+
throw new Error(
|
|
7559
|
+
"messages array cannot contain only blank content. Provide at least one message with non-empty content."
|
|
7560
|
+
);
|
|
7561
|
+
}
|
|
7562
|
+
} else if (messages.trim() === "") {
|
|
7563
|
+
throw new Error(
|
|
7564
|
+
"messages string cannot be empty. Provide non-empty content."
|
|
7565
|
+
);
|
|
7566
|
+
}
|
|
7541
7567
|
const temporalUsageNotice = detectTemporalUsageFromMetadata(
|
|
7542
7568
|
config == null ? void 0 : config.metadata
|
|
7543
7569
|
);
|
|
@@ -7597,7 +7623,7 @@ var Memory = class _Memory {
|
|
|
7597
7623
|
if (!infer) {
|
|
7598
7624
|
const returnedMemories = [];
|
|
7599
7625
|
for (const message of messages) {
|
|
7600
|
-
if (message.
|
|
7626
|
+
if (message.role === "system") {
|
|
7601
7627
|
continue;
|
|
7602
7628
|
}
|
|
7603
7629
|
const memoryId = await this.createMemory(
|
|
@@ -7621,7 +7647,7 @@ var Memory = class _Memory {
|
|
|
7621
7647
|
} catch (e) {
|
|
7622
7648
|
}
|
|
7623
7649
|
}
|
|
7624
|
-
const parsedMessages = messages.map((m) => m.content).join("\n");
|
|
7650
|
+
const parsedMessages = messages.map((m) => `${m.role}: ${m.content}`).join("\n");
|
|
7625
7651
|
const queryEmbedding = await this.embedder.embed(parsedMessages);
|
|
7626
7652
|
const existingResults = await this.vectorStore.search(
|
|
7627
7653
|
queryEmbedding,
|
|
@@ -7980,7 +8006,13 @@ var Memory = class _Memory {
|
|
|
7980
8006
|
memoryItem.metadata[key] = value;
|
|
7981
8007
|
}
|
|
7982
8008
|
}
|
|
7983
|
-
const result = {
|
|
8009
|
+
const result = {
|
|
8010
|
+
...memoryItem,
|
|
8011
|
+
...filters,
|
|
8012
|
+
...memory.payload.attributedTo && {
|
|
8013
|
+
attributedTo: memory.payload.attributedTo
|
|
8014
|
+
}
|
|
8015
|
+
};
|
|
7984
8016
|
await this._displayFirstRunNotice("get");
|
|
7985
8017
|
return result;
|
|
7986
8018
|
}
|
|
@@ -8178,6 +8210,7 @@ var Memory = class _Memory {
|
|
|
8178
8210
|
...payload.user_id && { user_id: payload.user_id },
|
|
8179
8211
|
...payload.agent_id && { agent_id: payload.agent_id },
|
|
8180
8212
|
...payload.run_id && { run_id: payload.run_id },
|
|
8213
|
+
...payload.attributedTo && { attributedTo: payload.attributedTo },
|
|
8181
8214
|
...scored.scoreDetails && { score_details: scored.scoreDetails }
|
|
8182
8215
|
};
|
|
8183
8216
|
});
|
|
@@ -8371,7 +8404,10 @@ var Memory = class _Memory {
|
|
|
8371
8404
|
metadata: Object.entries(mem.payload).filter(([key]) => !excludedKeys.has(key)).reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}),
|
|
8372
8405
|
...mem.payload.user_id && { user_id: mem.payload.user_id },
|
|
8373
8406
|
...mem.payload.agent_id && { agent_id: mem.payload.agent_id },
|
|
8374
|
-
...mem.payload.run_id && { run_id: mem.payload.run_id }
|
|
8407
|
+
...mem.payload.run_id && { run_id: mem.payload.run_id },
|
|
8408
|
+
...mem.payload.attributedTo && {
|
|
8409
|
+
attributedTo: mem.payload.attributedTo
|
|
8410
|
+
}
|
|
8375
8411
|
}));
|
|
8376
8412
|
const result = { results };
|
|
8377
8413
|
const scaleThresholdNotice = detectScaleThresholdFromTopK(topK);
|