Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci[minor]: Run fireworks and gvertex in daily standard tests #6507

Merged
merged 13 commits into from
Aug 16, 2024
42 changes: 28 additions & 14 deletions .github/workflows/standard-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
package: [anthropic, cohere, google-genai, groq, mistralai, aws]
package: [anthropic, cohere, google-genai, groq, mistralai, aws, google-vertexai-web]
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18.x
Expand All @@ -24,16 +24,15 @@ jobs:
- name: Run integration tests for ${{ matrix.package }}
run: yarn turbo test:integration --filter=@langchain/${{ matrix.package }}
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
DISABLE_CONSOLE_LOGS: "true"
# @langchain/aws credentials
BEDROCK_AWS_ACCESS_KEY_ID: ${{ secrets.BEDROCK_AWS_ACCESS_KEY_ID }}
BEDROCK_AWS_SECRET_ACCESS_KEY: ${{ secrets.BEDROCK_AWS_SECRET_ACCESS_KEY }}
BEDROCK_AWS_REGION: "us-east-1"
ANTHROPIC_API_KEY: ${{ matrix.package == 'anthropic' && secrets.ANTHROPIC_API_KEY || '' }}
COHERE_API_KEY: ${{ matrix.package == 'cohere' && secrets.COHERE_API_KEY || '' }}
GOOGLE_API_KEY: ${{ matrix.package == 'google-genai' && secrets.GOOGLE_API_KEY || '' }}
GROQ_API_KEY: ${{ matrix.package == 'groq' && secrets.GROQ_API_KEY || '' }}
MISTRAL_API_KEY: ${{ matrix.package == 'mistralai' && secrets.MISTRAL_API_KEY || '' }}
BEDROCK_AWS_ACCESS_KEY_ID: ${{ matrix.package == 'aws' && secrets.BEDROCK_AWS_ACCESS_KEY_ID || '' }}
BEDROCK_AWS_SECRET_ACCESS_KEY: ${{ matrix.package == 'aws' && secrets.BEDROCK_AWS_SECRET_ACCESS_KEY || '' }}
BEDROCK_AWS_REGION: ${{ matrix.package == 'aws' && 'us-east-1' || '' }}
GOOGLE_VERTEX_AI_WEB_CREDENTIALS: ${{ matrix.package == 'google-vertexai-web' && secrets.GOOGLE_VERTEX_AI_WEB_CREDENTIALS || '' }}

# The `@langchain/openai` package contains standard tests for ChatOpenAI and AzureChatOpenAI
# We want to run these separately, so we need to pass the exact path for each test, which means
Expand All @@ -55,7 +54,6 @@ jobs:
run: yarn workspace @langchain/openai test:single src/tests/chat_models_structured_output.int.test.ts src/tests/chat_models-extended.int.test.ts src/tests/chat_models-vision.int.test.ts src/tests/chat_models.int.test.ts src/tests/chat_models.standard.int.test.ts
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
DISABLE_CONSOLE_LOGS: "true"

standard-tests-azure-openai:
runs-on: ubuntu-latest
Expand All @@ -77,7 +75,6 @@ jobs:
AZURE_OPENAI_API_DEPLOYMENT_NAME: "chat"
AZURE_OPENAI_API_VERSION: ${{ secrets.AZURE_OPENAI_API_VERSION }}
AZURE_OPENAI_BASE_PATH: ${{ secrets.AZURE_OPENAI_BASE_PATH }}
DISABLE_CONSOLE_LOGS: "true"

standard-tests-bedrock:
runs-on: ubuntu-latest
Expand All @@ -98,4 +95,21 @@ jobs:
BEDROCK_AWS_REGION: "us-east-1"
BEDROCK_AWS_SECRET_ACCESS_KEY: ${{ secrets.BEDROCK_AWS_SECRET_ACCESS_KEY }}
BEDROCK_AWS_ACCESS_KEY_ID: ${{ secrets.BEDROCK_AWS_ACCESS_KEY_ID }}
DISABLE_CONSOLE_LOGS: "true"

standard-tests-fireworks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "yarn"
- name: Install dependencies
run: yarn install --immutable --mode=skip-build
- name: Build `@langchain/community`
run: yarn build --filter=@langchain/community
- name: Run standard tests (integration) for `@langchain/community` ChatFireworks
run: yarn workspace @langchain/community test:single src/chat_models/tests/chatfireworks.standard.int.test.ts
env:
FIREWORKS_API_KEY: ${{ secrets.FIREWORKS_API_KEY }}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { test } from "@jest/globals";
import { AmazonKnowledgeBaseRetriever } from "../bedrock.js";

test("AmazonKnowledgeBaseRetriever", async () => {
test.skip("AmazonKnowledgeBaseRetriever", async () => {
if (
!process.env.BEDROCK_AWS_REGION ||
!process.env.BEDROCK_AWS_ACCESS_KEY_ID ||
Expand Down
2 changes: 1 addition & 1 deletion libs/langchain-aws/src/retrievers/tests/kendra.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { test } from "@jest/globals";
import { AmazonKendraRetriever } from "../kendra.js";

test("AmazonKendraRetriever", async () => {
test.skip("AmazonKendraRetriever", async () => {
if (
!process.env.BEDROCK_AWS_REGION ||
!process.env.BEDROCK_AWS_ACCESS_KEY_ID ||
Expand Down
2 changes: 2 additions & 0 deletions libs/langchain-google-vertexai-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
},
"devDependencies": {
"@jest/globals": "^29.5.0",
"@langchain/google-common": "~0.0",
"@langchain/scripts": "^0.0.21",
"@langchain/standard-tests": "0.0.0",
"@swc/core": "^1.3.90",
"@swc/jest": "^0.2.29",
"@tsconfig/recommended": "^1.0.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable import/no-extraneous-dependencies, no-process-env */

import { z } from "zod";
import { test } from "@jest/globals";
Expand All @@ -9,7 +9,6 @@ import {
BaseMessageChunk,
HumanMessage,
SystemMessage,
ToolMessage,
} from "@langchain/core/messages";
import { BaseLanguageModelInput } from "@langchain/core/language_models/base";
import { ChatPromptValue } from "@langchain/core/prompt_values";
Expand All @@ -36,7 +35,13 @@ class WeatherTool extends StructuredTool {

describe("Google APIKey Chat", () => {
test("invoke", async () => {
const model = new ChatVertexAI();
const model = new ChatVertexAI({
authOptions: {
credentials: JSON.parse(
process.env.GOOGLE_VERTEX_AI_WEB_CREDENTIALS ?? ""
),
},
});
const res = await model.invoke("What is 1 + 1?");
// console.log(res);
expect(res).toBeDefined();
Expand Down Expand Up @@ -108,37 +113,6 @@ describe("Google APIKey Chat", () => {
);
});

test("Few shotting with tool calls", async () => {
const chat = new ChatVertexAI().bindTools([new WeatherTool()]);
// @eslint-disable-next-line/@typescript-eslint/ban-ts-comment
// @ts-expect-error unused var
const res = await chat.invoke("What is the weather in SF");
// console.log(res);
const res2 = await chat.invoke([
new HumanMessage("What is the weather in SF?"),
new AIMessage({
content: "",
tool_calls: [
{
id: "12345",
name: "get_current_weather",
args: {
location: "SF",
},
},
],
}),
new ToolMessage({
tool_call_id: "12345",
content: "It is currently 24 degrees with hail in SF.",
}),
new AIMessage("It is currently 24 degrees in SF with hail in SF."),
new HumanMessage("What did you say the weather was?"),
]);
// console.log(res2);
expect(res2.content).toContain("24");
});

test("withStructuredOutput", async () => {
const tool = {
name: "get_weather",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/* eslint-disable no-process-env */
import { test, expect } from "@jest/globals";
import { ChatModelIntegrationTests } from "@langchain/standard-tests";
import { AIMessageChunk } from "@langchain/core/messages";
import { GoogleAIBaseLanguageModelCallOptions } from "@langchain/google-common";
import { ChatVertexAI } from "../chat_models.js";

class ChatVertexAIStandardIntegrationTests extends ChatModelIntegrationTests<
GoogleAIBaseLanguageModelCallOptions,
AIMessageChunk
> {
constructor() {
if (!process.env.GOOGLE_VERTEX_AI_WEB_CREDENTIALS) {
throw new Error("Missing secrets for Google VertexAI standard tests.");
}

super({
Cls: ChatVertexAI,
chatModelHasToolCalling: true,
chatModelHasStructuredOutput: true,
supportsParallelToolCalls: true,
invokeResponseType: AIMessageChunk,
constructorArgs: {
model: "gemini-1.5-pro",
authOptions: {
credentials: JSON.parse(process.env.GOOGLE_VERTEX_AI_WEB_CREDENTIALS),
},
},
});
}

async testToolMessageHistoriesListContent() {
this.skipTestMessage(
"testToolMessageHistoriesListContent",
"ChatVertexAI",
"Not implemented."
);
}

async testInvokeMoreComplexTools() {
this.skipTestMessage(
"testInvokeMoreComplexTools",
"ChatVertexAI",
"Google VertexAI does not support tool schemas which contain object with unknown/any parameters." +
"Google VertexAI only supports objects in schemas when the parameters are defined."
);
}

async testParallelToolCalling() {
// Pass `true` in the second argument to only verify it can support parallel tool calls in the message history.
// This is because the model struggles to actually call parallel tools.
await super.testParallelToolCalling(undefined, true);
}
}

const testClass = new ChatVertexAIStandardIntegrationTests();

test("ChatVertexAIStandardIntegrationTests", async () => {
const testResults = await testClass.runTests();
expect(testResults).toBe(true);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* eslint-disable no-process-env */
import { test, expect } from "@jest/globals";
import { ChatModelUnitTests } from "@langchain/standard-tests";
import { AIMessageChunk } from "@langchain/core/messages";
import { GoogleAIBaseLanguageModelCallOptions } from "@langchain/google-common";
import { ChatVertexAI } from "../chat_models.js";

class ChatVertexAIStandardUnitTests extends ChatModelUnitTests<
GoogleAIBaseLanguageModelCallOptions,
AIMessageChunk
> {
constructor() {
super({
Cls: ChatVertexAI,
chatModelHasToolCalling: true,
chatModelHasStructuredOutput: true,
constructorArgs: {},
});
// This must be set so method like `.bindTools` or `.withStructuredOutput`
// which we call after instantiating the model will work.
// (constructor will throw if API key is not set)
process.env.GOOGLE_VERTEX_AI_WEB_CREDENTIALS = "test";
}

testChatModelInitApiKey() {
this.skipTestMessage(
"testChatModelInitApiKey",
"ChatVertexAI (webauth)",
this.multipleApiKeysRequiredMessage
);
}
}

const testClass = new ChatVertexAIStandardUnitTests();

test("ChatVertexAIStandardUnitTests", () => {
const testResults = testClass.runTests();
expect(testResults).toBe(true);
});
Loading
Loading