-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
google-vertexai[minor] Add standard tests (#5721)
* google-vertexai[minor] Add standard tests * moved tests to vertex * fixed tests * fixed latest/lowest ci * chore: lint files * chore: lint files
- Loading branch information
1 parent
3bc9b8e
commit ef9b85c
Showing
18 changed files
with
244 additions
and
822 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
dependency_range_tests/scripts/vertexai/test-with-latest-deps.sh
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
dependency_range_tests/scripts/vertexai/test-with-lowest-deps.sh
This file was deleted.
Oops, something went wrong.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ertexai/node/update_resolutions_lowest.js → ...ertexai/node/update_resolutions_lowest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
22 changes: 22 additions & 0 deletions
22
dependency_range_tests/scripts/with_standard_tests/google-vertexai/test-with-latest-deps.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
35 changes: 35 additions & 0 deletions
35
dependency_range_tests/scripts/with_standard_tests/google-vertexai/test-with-lowest-deps.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
libs/langchain-google-vertexai/src/tests/chat_models.standard.int.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
39 changes: 39 additions & 0 deletions
39
libs/langchain-google-vertexai/src/tests/chat_models.standard.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_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); | ||
}); |
Oops, something went wrong.