diff --git a/libs/langchain-mongodb/src/storage.ts b/libs/langchain-mongodb/src/storage.ts index ce52f203c512..528afbe5dbc8 100644 --- a/libs/langchain-mongodb/src/storage.ts +++ b/libs/langchain-mongodb/src/storage.ts @@ -103,8 +103,10 @@ export class MongoDBStore extends BaseStore { } if (value === undefined || value === null) { return undefined; - } else if (typeof value === "object") { + } else if (typeof value.value === "object") { return encoder.encode(JSON.stringify(value.value)); + } else if (typeof value.value === "string") { + return encoder.encode(value.value); } else { throw new Error("Unexpected value type"); }