diff --git a/mem0-ts/package.json b/mem0-ts/package.json index 96f378eac..e6f29d4cb 100644 --- a/mem0-ts/package.json +++ b/mem0-ts/package.json @@ -263,6 +263,9 @@ }, "@types/pg": { "optional": true + }, + "natural": { + "optional": true } }, "engines": { diff --git a/mem0-ts/src/oss/tests/pgvector.optional-peer.test.ts b/mem0-ts/src/oss/tests/missing-optional-peers.test.ts similarity index 63% rename from mem0-ts/src/oss/tests/pgvector.optional-peer.test.ts rename to mem0-ts/src/oss/tests/missing-optional-peers.test.ts index 896e781b1..910849c55 100644 --- a/mem0-ts/src/oss/tests/pgvector.optional-peer.test.ts +++ b/mem0-ts/src/oss/tests/missing-optional-peers.test.ts @@ -2,7 +2,11 @@ jest.mock("pg", () => { throw new Error("Cannot find module 'pg'"); }); -describe("pg is an optional peer", () => { +jest.mock("natural", () => { + throw new Error("Cannot find module 'natural'"); +}); + +describe("mem0ai/oss without pg or natural installed", () => { beforeEach(() => { jest.spyOn(console, "error").mockImplementation(() => {}); }); @@ -11,7 +15,7 @@ describe("pg is an optional peer", () => { jest.restoreAllMocks(); }); - test("mem0ai/oss loads without pg installed", async () => { + test("mem0ai/oss loads", async () => { await expect(import("../src")).resolves.toHaveProperty("Memory"); }); @@ -26,4 +30,10 @@ describe("pg is an optional peer", () => { "The 'pg' package is required to use the PGVector vector store. Install it with: npm install pg", ); }); + + test("BM25 lemmatization falls back to the built-in stemmer", async () => { + const { lemmatizeForBm25 } = await import("../src/utils/lemmatization"); + + expect(lemmatizeForBm25("The dogs were running")).toBe("dog runn running"); + }); });