-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
google-vertexai[minor] Add standard tests #5721
Changes from all commits
a6110d9
dcfa55d
dda57e7
1e11134
4b41efd
1227c69
301f7aa
0669d24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euxo pipefail | ||
|
||
export CI=true | ||
|
||
# New monorepo directory paths | ||
monorepo_dir="/app/monorepo" | ||
monorepo_openai_dir="/app/monorepo/libs/langchain-google-vertexai" | ||
|
||
# Run the shared script to copy all necessary folders/files | ||
bash /scripts/with_standard_tests/shared.sh google-vertexai | ||
|
||
# Navigate back to monorepo root and install dependencies | ||
cd "$monorepo_dir" | ||
yarn | ||
|
||
# Navigate into `@langchain/google-vertexai` to build and run tests | ||
# We need to run inside the google-vertexai directory so turbo repo does | ||
# not try to build the package/its workspace dependencies. | ||
cd "$monorepo_openai_dir" | ||
yarn test |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euxo pipefail | ||
|
||
export CI=true | ||
|
||
monorepo_dir="/app/monorepo" | ||
monorepo_openai_dir="/app/monorepo/libs/langchain-google-vertexai" | ||
updater_script_dir="/app/updater_script" | ||
updater_script_dir="/app/updater_script" | ||
original_updater_script_dir="/scripts/with_standard_tests/google-vertexai/node" | ||
|
||
# Run the shared script to copy all necessary folders/files | ||
bash /scripts/with_standard_tests/shared.sh google-vertexai | ||
|
||
# Copy the updater script to the monorepo | ||
mkdir -p "$updater_script_dir" | ||
cp "$original_updater_script_dir"/* "$updater_script_dir/" | ||
|
||
# Install deps (e.g semver) for the updater script | ||
cd "$updater_script_dir" | ||
yarn | ||
# Run the updater script | ||
node "update_resolutions_lowest.js" | ||
|
||
|
||
# Navigate back to monorepo root and install dependencies | ||
cd "$monorepo_dir" | ||
yarn | ||
|
||
# Navigate into `@langchain/package` to build and run tests | ||
# We need to run inside the package directory so turbo repo does | ||
# not try to build the package/its workspace dependencies. | ||
cd "$monorepo_openai_dir" | ||
yarn test |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* 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_APPLICATION_CREDENTIALS) { | ||
throw new Error( | ||
"GOOGLE_APPLICATION_CREDENTIALS must be set to run standard integration tests." | ||
); | ||
} | ||
super({ | ||
Cls: ChatVertexAI, | ||
chatModelHasToolCalling: true, | ||
chatModelHasStructuredOutput: true, | ||
constructorArgs: { | ||
model: "gemini-1.5-pro", | ||
}, | ||
}); | ||
} | ||
|
||
async testUsageMetadataStreaming() { | ||
this.skipTestMessage( | ||
"testUsageMetadataStreaming", | ||
"ChatVertexAI", | ||
"Streaming tokens is not currently supported." | ||
); | ||
} | ||
|
||
async testUsageMetadata() { | ||
this.skipTestMessage( | ||
"testUsageMetadata", | ||
"ChatVertexAI", | ||
"Usage metadata tokens is not currently supported." | ||
); | ||
} | ||
|
||
async testToolMessageHistoriesListContent() { | ||
this.skipTestMessage( | ||
"testToolMessageHistoriesListContent", | ||
"ChatVertexAI", | ||
"Not implemented." | ||
); | ||
} | ||
} | ||
|
||
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 */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey team, just a heads up that I've flagged a change in the PR that explicitly adds an environment variable via |
||
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_APPLICATION_CREDENTIALS = "test"; | ||
} | ||
|
||
testChatModelInitApiKey() { | ||
this.skipTestMessage( | ||
"testChatModelInitApiKey", | ||
"ChatVertexAI (gauth)", | ||
this.multipleApiKeysRequiredMessage | ||
); | ||
} | ||
} | ||
|
||
const testClass = new ChatVertexAIStandardUnitTests(); | ||
|
||
test("ChatVertexAIStandardUnitTests", () => { | ||
const testResults = testClass.runTests(); | ||
expect(testResults).toBe(true); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey team, I've reviewed the code and noticed that the new changes are accessing environment variables via
process.env
. I've flagged this for your attention to ensure it aligns with our best practices. Let me know if you need any further assistance with this.