Skip to content

Commit

Permalink
Adds test-int-deps docker compose file for spinning up local infra fo…
Browse files Browse the repository at this point in the history
…r integration tests, add more skips for specific integrations
  • Loading branch information
jacoblee93 committed Jun 8, 2023
1 parent 9af90c9 commit fb499a2
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 70 deletions.
10 changes: 5 additions & 5 deletions langchain/src/chat_models/tests/chatgooglevertexai.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ import { ConversationChain } from "../../chains/conversation.js";
import { BufferMemory } from "../../memory/buffer_memory.js";
import { ChatGoogleVertexAI } from "../googlevertexai.js";

test("Test ChatGoogleVertexAI", async () => {
test.skip("Test ChatGoogleVertexAI", async () => {
const chat = new ChatGoogleVertexAI();
const message = new HumanChatMessage("Hello!");
const res = await chat.call([message]);
console.log({ res });
});

test("Test ChatGoogleVertexAI generate", async () => {
test.skip("Test ChatGoogleVertexAI generate", async () => {
const chat = new ChatGoogleVertexAI();
const message = new HumanChatMessage("Hello!");
const res = await chat.generate([[message]]);
console.log(JSON.stringify(res, null, 2));
});

test("ChatGoogleVertexAI, prompt templates", async () => {
test.skip("ChatGoogleVertexAI, prompt templates", async () => {
const chat = new ChatGoogleVertexAI();

// PaLM doesn't support translation yet
Expand All @@ -49,7 +49,7 @@ test("ChatGoogleVertexAI, prompt templates", async () => {
console.log(responseA.generations);
});

test("ChatGoogleVertexAI, longer chain of messages", async () => {
test.skip("ChatGoogleVertexAI, longer chain of messages", async () => {
const chat = new ChatGoogleVertexAI();

const chatPrompt = ChatPromptTemplate.fromPromptMessages([
Expand All @@ -67,7 +67,7 @@ test("ChatGoogleVertexAI, longer chain of messages", async () => {
console.log(responseA.generations);
});

test("ChatGoogleVertexAI, with a memory in a chain", async () => {
test.skip("ChatGoogleVertexAI, with a memory in a chain", async () => {
const chatPrompt = ChatPromptTemplate.fromPromptMessages([
SystemMessagePromptTemplate.fromTemplate(
"You are a helpful assistant who must always respond like a pirate"
Expand Down
6 changes: 3 additions & 3 deletions langchain/src/embeddings/tests/googlevertexai.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { test, expect } from "@jest/globals";
import { GoogleVertexAIEmbeddings } from "../googlevertexai.js";
import { HNSWLib } from "../../vectorstores/hnswlib.js";

test("Test GoogleVertexAIEmbeddings.embedQuery", async () => {
test.skip("Test GoogleVertexAIEmbeddings.embedQuery", async () => {
const embeddings = new GoogleVertexAIEmbeddings();
const res = await embeddings.embedQuery("Hello world");
console.log(res);
expect(typeof res[0]).toBe("number");
});

test("Test GoogleVertexAIEmbeddings.embedDocuments", async () => {
test.skip("Test GoogleVertexAIEmbeddings.embedDocuments", async () => {
const embeddings = new GoogleVertexAIEmbeddings();
const res = await embeddings.embedDocuments(["Hello world", "Bye bye"]);
console.log(res);
Expand All @@ -18,7 +18,7 @@ test("Test GoogleVertexAIEmbeddings.embedDocuments", async () => {
expect(typeof res[1][0]).toBe("number");
});

test("Test end to end with HNSWLib", async () => {
test.skip("Test end to end with HNSWLib", async () => {
const vectorStore = await HNSWLib.fromTexts(
["Hello world", "Bye bye", "hello nice world"],
[{ id: 2 }, { id: 1 }, { id: 3 }],
Expand Down
8 changes: 4 additions & 4 deletions langchain/src/llms/tests/googlevertexai.int.test.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { test } from "@jest/globals";
import { GoogleVertexAI } from "../googlevertexai.js";

test("Test Google Vertex", async () => {
test.skip("Test Google Vertex", async () => {
const model = new GoogleVertexAI({ maxOutputTokens: 50 });
const res = await model.call("1 + 1 = ");
console.log({ res });
});

test("Test Google Vertex generation", async () => {
test.skip("Test Google Vertex generation", async () => {
const model = new GoogleVertexAI({ maxOutputTokens: 50 });
const res = await model.generate(["1 + 1 = "]);
console.log(JSON.stringify(res, null, 2));
});

test("Test Google Vertex generation", async () => {
test.skip("Test Google Vertex generation", async () => {
const model = new GoogleVertexAI({ maxOutputTokens: 50 });
const res = await model.generate(["Print hello world."]);
console.log(JSON.stringify(res, null, 2));
});

test("Test Google Vertex generation", async () => {
test.skip("Test Google Vertex generation", async () => {
const model = new GoogleVertexAI({ maxOutputTokens: 50 });
const res = await model.generate([
`Translate "I love programming" into Korean.`,
Expand Down
2 changes: 1 addition & 1 deletion langchain/src/llms/tests/sagemaker_endpoint.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class HuggingFaceTextGenerationGPT2ContentHandler
}

// Requires a pre-configured sagemaker endpoint
test("Test SageMakerEndpoint", async () => {
test.skip("Test SageMakerEndpoint", async () => {
const contentHandler = new HuggingFaceTextGenerationGPT2ContentHandler();

const model = new SageMakerEndpoint({
Expand Down
30 changes: 7 additions & 23 deletions langchain/src/memory/tests/entity_memory.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,27 @@ test("Test entity memory in a chain", async () => {
});

const res2 = await chain.call({
input: "I work in sales. What about you?",
input:
"My office is the Scranton branch of Dunder Mifflin. What about you?",
});
console.log({
res2,
memory: await memory.loadMemoryVariables({ input: "Who is Jim?" }),
});

const res3 = await chain.call({
input:
"My office is the Scranton branch of Dunder Mifflin. What about you?",
input: "I am Jim.",
});
console.log({
res3,
memory: await memory.loadMemoryVariables({ input: "Who is Jim?" }),
});

const res4 = await chain.call({
input: "I am Jim.",
});
console.log({
res4,
memory: await memory.loadMemoryVariables({ input: "Who is Jim?" }),
});

const res5 = await chain.call({
input: "What have I told you about Jim so far?",
});
console.log({
res5,
res4,
memory: await memory.loadMemoryVariables({ input: "Who is Jim?" }),
});
}, 120000);
Expand All @@ -74,34 +66,26 @@ test("Test entity memory with a chat model in a chain", async () => {
});

const res2 = await chain.call({
input: "I work in sales. What about you?",
input: "My office is the Utica branch of Dunder Mifflin. What about you?",
});
console.log({
res2,
memory: await memory.loadMemoryVariables({ input: "Who is Jim?" }),
});

const res3 = await chain.call({
input: "My office is the Utica branch of Dunder Mifflin. What about you?",
input: "I am Jim.",
});
console.log({
res3,
memory: await memory.loadMemoryVariables({ input: "Who is Jim?" }),
});

const res4 = await chain.call({
input: "I am Jim.",
});
console.log({
res4,
memory: await memory.loadMemoryVariables({ input: "Who is Jim?" }),
});

const res5 = await chain.call({
input: "What have I told you about Jim so far?",
});
console.log({
res5,
res4,
memory: await memory.loadMemoryVariables({ input: "Who is Jim?" }),
});
}, 120000);
4 changes: 2 additions & 2 deletions langchain/src/memory/tests/zep_memory.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ beforeEach((done) => {
setTimeout(done, 1000); // 1-second delay before each test case
});

test("addMemory to Zep memory", async () => {
test.skip("addMemory to Zep memory", async () => {
await zepMemory.saveContext(
{ input: "Who was Octavia Butler?" },
{
Expand All @@ -21,7 +21,7 @@ test("addMemory to Zep memory", async () => {
);
});

test("getMessages from Zep memory", async () => {
test.skip("getMessages from Zep memory", async () => {
const memoryVariables = await zepMemory.loadMemoryVariables({});
console.log("memoryVariables", memoryVariables);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ChromaTranslator } from "../chroma.js";
import { OpenAI } from "../../../llms/openai.js";
import { Chroma } from "../../../vectorstores/chroma.js";

test("Chroma Store Self Query Retriever Test", async () => {
test.skip("Chroma Store Self Query Retriever Test", async () => {
const docs = [
new Document({
pageContent:
Expand Down
2 changes: 1 addition & 1 deletion langchain/src/retrievers/tests/vespa.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { test, expect } from "@jest/globals";

import { VespaRetriever } from "../vespa.js";

test("VespaRetriever", async () => {
test.skip("VespaRetriever", async () => {
const url = process.env.VESPA_URL!;
const query_body = {
yql: "select * from music where album contains 'head';",
Expand Down
2 changes: 1 addition & 1 deletion langchain/src/stores/tests/redis.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ test("Test Redis history with a TTL", async () => {
const resultWithHistory = await chatHistory.getMessages();
expect(resultWithHistory).toEqual(expectedMessages);

await new Promise((resolve) => setTimeout(resolve, 5000));
await new Promise((resolve) => setTimeout(resolve, 6000));

const expiredResult = await chatHistory.getMessages();
expect(expiredResult).toStrictEqual([]);
Expand Down
20 changes: 0 additions & 20 deletions langchain/src/tools/tests/brave_search.int.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { test } from "@jest/globals";
import { BraveSearch } from "../brave_search.js";
import { Calculator } from "../calculator.js";
import { ChatOpenAI } from "../../chat_models/openai.js";
import { initializeAgentExecutorWithOptions } from "../../agents/initialize.js";

test("BraveSearchTool", async () => {
const tool = new BraveSearch();
Expand All @@ -11,20 +8,3 @@ test("BraveSearchTool", async () => {

console.log({ result });
});

test("Run in an agent", async () => {
const model = new ChatOpenAI({ temperature: 0 });
const tools = [new BraveSearch(), new Calculator()];

const executor = await initializeAgentExecutorWithOptions(tools, model, {
agentType: "chat-zero-shot-react-description",
verbose: true,
});

const input = `Who is Dua Lipa's boyfriend? What is his current age raised to the 0.23 power?`;
console.log(`Executing with input "${input}"...`);

const result = await executor.call({ input });

console.log(`Got output ${result.output}`);
});
4 changes: 2 additions & 2 deletions langchain/src/vectorstores/tests/chroma.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("Chroma", () => {
});
});

test("auto-generated ids", async () => {
test.skip("auto-generated ids", async () => {
const pageContent = faker.lorem.sentence(5);

await chromaStore.addDocuments([{ pageContent, metadata: { foo: "bar" } }]);
Expand All @@ -30,7 +30,7 @@ describe("Chroma", () => {
]);
});

test("metadata filtering", async () => {
test.skip("metadata filtering", async () => {
const pageContent = faker.lorem.sentence(5);
const id = uuid.v4();

Expand Down
4 changes: 2 additions & 2 deletions langchain/src/vectorstores/tests/milvus.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ beforeAll(async () => {
collectionName = `test_collection_${Math.random().toString(36).substring(7)}`;
});

test("Test Milvus.fromtext", async () => {
test.skip("Test Milvus.fromtext", async () => {
const texts = [
`Tortoise: Labyrinth? Labyrinth? Could it Are we in the notorious Little
Harmonic Labyrinth of the dreaded Majotaur?`,
Expand Down Expand Up @@ -51,7 +51,7 @@ Harmonic Labyrinth of the dreaded Majotaur?`,
]);
});

test("Test Milvus.fromExistingCollection", async () => {
test.skip("Test Milvus.fromExistingCollection", async () => {
const milvus = await Milvus.fromExistingCollection(embeddings, {
collectionName,
});
Expand Down
6 changes: 3 additions & 3 deletions langchain/src/vectorstores/tests/mongodb_atlas.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const client = new MongoClient(process.env.MONGODB_ATLAS_URI!);

test.skip("MongoDBAtlasVectorSearch with external ids", async () => {
expect(process.env.MONGODB_ATLAS_URI).toBeDefined();

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const client = new MongoClient(process.env.MONGODB_ATLAS_URI!);

try {
const namespace = "langchain.test";
const [dbName, collectionName] = namespace.split(".");
Expand Down
2 changes: 1 addition & 1 deletion langchain/src/vectorstores/tests/qdrant.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("QdrantVectorStore testcase", () => {
});
});

test("base usage", async () => {
test.skip("base usage", async () => {
const pageContent = faker.lorem.sentence(5);

await qdrantVectorStore.addDocuments([{ pageContent, metadata: {} }]);
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
"lint:fix": "yarn lint -- --fix",
"test": "turbo run test test:integration && yarn test:exports:docker",
"test:unit": "turbo run test",
"test:int": "turbo run test:integration",
"test:int": "yarn run test:int:deps && turbo run test:integration ; yarn run test:int:deps:down",
"test:int:deps": "docker compose -f test-int-deps-docker-compose.yml up -d",
"test:int:deps:down": "docker compose -f test-int-deps-docker-compose.yml down",
"test:exports:docker": "docker compose up",
"publish": "bash scripts/release-branch.sh && turbo run build lint test test:integration && yarn run test:exports:docker && yarn workspace langchain run release && echo '🔗 Open https://github.com/hwchase17/langchainjs/compare/release?expand=1 and merge the release PR'",
"example": "yarn workspace examples start",
Expand Down
14 changes: 14 additions & 0 deletions test-int-deps-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.8'
services:
cache:
image: redis:6.2-alpine
restart: always
ports:
- '6379:6379'
command: redis-server --save 20 1 --loglevel warning
volumes:
- cache:/data

volumes:
cache:
driver: local

0 comments on commit fb499a2

Please sign in to comment.