Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/providers/langchain-mongodb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"lint:fix": "pnpm lint:eslint --fix && pnpm lint:dpdm",
"clean": "rm -rf .turbo dist/",
"test:watch": "vitest",
"test:int": "vitest run --mode int --testTimeout 100000 --maxWorkers=50%",
"test:int": "vitest run --mode int --testTimeout 10000 --maxWorkers=50%",
"format": "prettier --config .prettierrc --write \"src\"",
"format:check": "prettier --config .prettierrc --check \"src\""
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, test, expect, beforeAll, afterAll } from "vitest";
import { describe, test, expect, beforeAll, afterAll, afterEach } from "vitest";
import { v4 as uuidv4 } from "uuid";
import { Collection, MongoClient, ServerApiVersion } from "mongodb";
import { MongoDBStore } from "../storage.js";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { beforeAll, expect, vi, test, type MockInstance } from "vitest";
import { afterAll, beforeAll, beforeEach, describe, expect, vi, test, type MockInstance } from "vitest";
import { Collection, MongoClient } from "mongodb";
import { setTimeout } from "timers/promises";
import { OpenAIEmbeddings, AzureOpenAIEmbeddings } from "@langchain/openai";
Expand Down Expand Up @@ -33,7 +33,7 @@ beforeAll(async () => {
client = new MongoClient(uri(), { monitorCommands: true });
await client.connect();

const namespace = "langchain.test";
const namespace = "langchain_test_db.langchain_test";
const [dbName, collectionName] = namespace.split(".");
collection = await client.db(dbName).createCollection(collectionName);

Expand Down Expand Up @@ -108,13 +108,13 @@ function getEmbeddings() {
}

test("MongoDBStore sets client metadata", () => {
const spy = jest.spyOn(client, "appendMetadata");
const spy = vi.spyOn(client, "appendMetadata");
// eslint-disable-next-line no-new
new PatchedVectorStore(getEmbeddings(), {
collection,
});
expect(spy).toHaveBeenCalledWith({ name: "langchainjs_vector" });
jest.clearAllMocks();
vi.clearAllMocks();
});

test("MongoDBAtlasVectorSearch with external ids", async () => {
Expand Down Expand Up @@ -199,7 +199,7 @@ test("MongoDBAtlasVectorSearch with Maximal Marginal Relevance", async () => {

const standardRetriever = await vectorStore.asRetriever();

const standardRetrieverOutput = await standardRetriever.getRelevantDocuments(
const standardRetrieverOutput = await standardRetriever._getRelevantDocuments(
"foo"
);
expect(output).toHaveLength(texts.length);
Expand All @@ -218,7 +218,7 @@ test("MongoDBAtlasVectorSearch with Maximal Marginal Relevance", async () => {
},
});

const retrieverOutput = await retriever.getRelevantDocuments("foo");
const retrieverOutput = await retriever._getRelevantDocuments("foo");
expect(output).toHaveLength(texts.length);

const retrieverActual = retrieverOutput.map((doc) => doc.pageContent);
Expand Down