-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a6110d9
google-vertexai[minor] Add standard tests
bracesproul dcfa55d
merge main
bracesproul dda57e7
moved tests to vertex
bracesproul 1e11134
fixed tests
bracesproul 4b41efd
Merge branch 'main' into brace/vertex-standard-tests
bracesproul 1227c69
fixed latest/lowest ci
bracesproul 301f7aa
chore: lint files
bracesproul 0669d24
chore: lint files
bracesproul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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); | ||
}); |
35 changes: 35 additions & 0 deletions
35
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,35 @@ | ||
/* 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 { ChatVertexAI } from "../chat_models.js"; | ||
import { GoogleAIBaseLanguageModelCallOptions } from "@langchain/google-common"; | ||
|
||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.