-
Notifications
You must be signed in to change notification settings - Fork 2.9k
community[minor]: Add standard tests to community chat models #5669
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
Changes from all commits
4820bf9
400b04b
efb7f3f
1510d62
74d2fe9
f694aad
f9b4d85
5a8767e
bdb4d55
de2259c
8991340
183816c
b96008e
3f4a3b3
ded3663
18c748e
20d16d2
cc4f4e7
63de31e
c323fab
50971e2
01573ab
f978653
ca50201
74da454
ee55ad9
31aa8f8
d607d2b
4c0789b
e66d30e
8d8fac1
77111c7
b2367b9
2a1af54
404fdae
d7f7d45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /* eslint-disable no-process-env */ | ||
| import { test, expect } from "@jest/globals"; | ||
| import { ChatModelIntegrationTests } from "@langchain/standard-tests"; | ||
| import { AIMessageChunk } from "@langchain/core/messages"; | ||
| import { BaseChatModelCallOptions } from "@langchain/core/language_models/chat_models"; | ||
| import { BedrockChat } from "../bedrock/index.js"; | ||
|
|
||
| class BedrockChatStandardIntegrationTests extends ChatModelIntegrationTests< | ||
| BaseChatModelCallOptions, | ||
| AIMessageChunk | ||
| > { | ||
| constructor() { | ||
| const region = process.env.BEDROCK_AWS_REGION ?? "us-east-1"; | ||
| super({ | ||
| Cls: BedrockChat, | ||
| chatModelHasToolCalling: false, | ||
| chatModelHasStructuredOutput: false, | ||
| constructorArgs: { | ||
| region, | ||
| model: "amazon.titan-text-express-v1", | ||
| credentials: { | ||
| secretAccessKey: process.env.BEDROCK_AWS_SECRET_ACCESS_KEY, | ||
| accessKeyId: process.env.BEDROCK_AWS_ACCESS_KEY_ID, | ||
| }, | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| async testUsageMetadataStreaming() { | ||
| this.skipTestMessage( | ||
| "testUsageMetadataStreaming", | ||
| "BedrockChat", | ||
| "Streaming tokens is not currently supported." | ||
| ); | ||
| } | ||
|
|
||
| async testUsageMetadata() { | ||
| this.skipTestMessage( | ||
| "testUsageMetadata", | ||
| "BedrockChat", | ||
| "Usage metadata tokens is not currently supported." | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| const testClass = new BedrockChatStandardIntegrationTests(); | ||
|
|
||
| test("BedrockChatStandardIntegrationTests", 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 there! I've noticed that this PR includes changes that explicitly access and set environment variables using |
||
| import { test, expect } from "@jest/globals"; | ||
| import { ChatModelUnitTests } from "@langchain/standard-tests"; | ||
| import { AIMessageChunk } from "@langchain/core/messages"; | ||
| import { BaseChatModelCallOptions } from "@langchain/core/language_models/chat_models"; | ||
| import { BedrockChat } from "../bedrock/index.js"; | ||
|
|
||
| class BedrockChatStandardUnitTests extends ChatModelUnitTests< | ||
| BaseChatModelCallOptions, | ||
| AIMessageChunk | ||
| > { | ||
| constructor() { | ||
| super({ | ||
| Cls: BedrockChat, | ||
| chatModelHasToolCalling: false, | ||
| chatModelHasStructuredOutput: false, | ||
| constructorArgs: {}, | ||
| }); | ||
| process.env.BEDROCK_AWS_SECRET_ACCESS_KEY = "test"; | ||
| process.env.BEDROCK_AWS_ACCESS_KEY_ID = "test"; | ||
| process.env.BEDROCK_AWS_SESSION_TOKEN = "test"; | ||
| process.env.AWS_DEFAULT_REGION = "us-east-1"; | ||
| } | ||
|
|
||
| testChatModelInitApiKey() { | ||
| this.skipTestMessage( | ||
| "testChatModelInitApiKey", | ||
| "BedrockChat", | ||
| this.multipleApiKeysRequiredMessage | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| const testClass = new BedrockChatStandardUnitTests(); | ||
|
|
||
| test("BedrockChatStandardUnitTests", () => { | ||
| const testResults = testClass.runTests(); | ||
| expect(testResults).toBe(true); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* eslint-disable no-process-env */ | ||
| import { test, expect } from "@jest/globals"; | ||
| import { ChatModelIntegrationTests } from "@langchain/standard-tests"; | ||
| import { AIMessageChunk } from "@langchain/core/messages"; | ||
| import { ChatFireworks, ChatFireworksCallOptions } from "../fireworks.js"; | ||
|
|
||
| class ChatFireworksStandardIntegrationTests extends ChatModelIntegrationTests< | ||
| ChatFireworksCallOptions, | ||
| AIMessageChunk | ||
| > { | ||
| constructor() { | ||
| super({ | ||
| Cls: ChatFireworks, | ||
| chatModelHasToolCalling: true, | ||
| chatModelHasStructuredOutput: true, | ||
| constructorArgs: { | ||
| model: "accounts/fireworks/models/firefunction-v1", | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| async testToolMessageHistoriesListContent() { | ||
| this.skipTestMessage( | ||
| "testToolMessageHistoriesListContent", | ||
| "ChatFireworks", | ||
| "Not implemented." | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| const testClass = new ChatFireworksStandardIntegrationTests(); | ||
|
|
||
| test("ChatFireworksStandardIntegrationTests", async () => { | ||
| const testResults = await testClass.runTests(); | ||
| expect(testResults).toBe(true); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* 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, I've reviewed the code and noticed that the addition of environment variable manipulation via |
||
| import { test, expect } from "@jest/globals"; | ||
| import { ChatModelUnitTests } from "@langchain/standard-tests"; | ||
| import { AIMessageChunk } from "@langchain/core/messages"; | ||
| import { ChatFireworks, ChatFireworksCallOptions } from "../fireworks.js"; | ||
|
|
||
| class ChatFireworksStandardUnitTests extends ChatModelUnitTests< | ||
| ChatFireworksCallOptions, | ||
| AIMessageChunk | ||
| > { | ||
| constructor() { | ||
| super({ | ||
| Cls: ChatFireworks, | ||
| chatModelHasToolCalling: true, | ||
| chatModelHasStructuredOutput: true, | ||
| constructorArgs: {}, | ||
| }); | ||
| process.env.FIREWORKS_API_KEY = "test"; | ||
| } | ||
|
|
||
| testChatModelInitApiKey() { | ||
| // Unset the API key env var here so this test can properly check | ||
| // the API key class arg. | ||
| process.env.FIREWORKS_API_KEY = ""; | ||
| super.testChatModelInitApiKey(); | ||
| // Re-set the API key env var here so other tests can run properly. | ||
| process.env.FIREWORKS_API_KEY = "test"; | ||
| } | ||
| } | ||
|
|
||
| const testClass = new ChatFireworksStandardUnitTests(); | ||
|
|
||
| test("ChatFireworksStandardUnitTests", () => { | ||
| const testResults = testClass.runTests(); | ||
| expect(testResults).toBe(true); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* eslint-disable no-process-env */ | ||
| import { test, expect } from "@jest/globals"; | ||
| import { ChatModelUnitTests } from "@langchain/standard-tests"; | ||
| import { AIMessageChunk } from "@langchain/core/messages"; | ||
| import { ChatOllama, ChatOllamaCallOptions } from "../ollama.js"; | ||
|
|
||
| class ChatOllamaStandardUnitTests extends ChatModelUnitTests< | ||
| ChatOllamaCallOptions, | ||
| AIMessageChunk | ||
| > { | ||
| constructor() { | ||
| super({ | ||
| Cls: ChatOllama, | ||
| chatModelHasToolCalling: false, | ||
| chatModelHasStructuredOutput: false, | ||
| constructorArgs: {}, | ||
| }); | ||
| } | ||
|
|
||
| testChatModelInitApiKey() { | ||
| this.skipTestMessage( | ||
| "testChatModelInitApiKey", | ||
| "ChatOllama", | ||
| "API key not required." | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| const testClass = new ChatOllamaStandardUnitTests(); | ||
|
|
||
| test("ChatOllamaStandardUnitTests", () => { | ||
| const testResults = testClass.runTests(); | ||
| expect(testResults).toBe(true); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /* eslint-disable no-process-env */ | ||
| import { test, expect } from "@jest/globals"; | ||
| import { ChatModelIntegrationTests } from "@langchain/standard-tests"; | ||
| import { AIMessageChunk } from "@langchain/core/messages"; | ||
| import { ChatTogetherAI, ChatTogetherAICallOptions } from "../togetherai.js"; | ||
|
|
||
| class ChatTogetherAIStandardIntegrationTests extends ChatModelIntegrationTests< | ||
| ChatTogetherAICallOptions, | ||
| AIMessageChunk | ||
| > { | ||
| constructor() { | ||
| super({ | ||
| Cls: ChatTogetherAI, | ||
| chatModelHasToolCalling: true, | ||
| chatModelHasStructuredOutput: true, | ||
| constructorArgs: {}, | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| const testClass = new ChatTogetherAIStandardIntegrationTests(); | ||
|
|
||
| test("ChatTogetherAIStandardIntegrationTests", async () => { | ||
| const testResults = await testClass.runTests(); | ||
| expect(testResults).toBe(true); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* 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 the latest change in the PR for review as it explicitly adds and accesses environment variables via |
||
| import { test, expect } from "@jest/globals"; | ||
| import { ChatModelUnitTests } from "@langchain/standard-tests"; | ||
| import { AIMessageChunk } from "@langchain/core/messages"; | ||
| import { ChatTogetherAI, ChatTogetherAICallOptions } from "../togetherai.js"; | ||
|
|
||
| class ChatTogetherAIStandardUnitTests extends ChatModelUnitTests< | ||
| ChatTogetherAICallOptions, | ||
| AIMessageChunk | ||
| > { | ||
| constructor() { | ||
| super({ | ||
| Cls: ChatTogetherAI, | ||
| chatModelHasToolCalling: false, | ||
| chatModelHasStructuredOutput: false, | ||
| constructorArgs: {}, | ||
| }); | ||
| process.env.TOGETHER_AI_API_KEY = "test"; | ||
| } | ||
|
|
||
| testChatModelInitApiKey() { | ||
| // Unset the API key env var here so this test can properly check | ||
| // the API key class arg. | ||
| process.env.TOGETHER_AI_API_KEY = ""; | ||
| super.testChatModelInitApiKey(); | ||
| // Re-set the API key env var here so other tests can run properly. | ||
| process.env.TOGETHER_AI_API_KEY = "test"; | ||
| } | ||
| } | ||
|
|
||
| const testClass = new ChatTogetherAIStandardUnitTests(); | ||
|
|
||
| test("ChatTogetherAIStandardUnitTests", () => { | ||
| 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.
Great work on the PR! I've noticed that the code explicitly accesses environment variables using
process.env, so I've flagged this for maintainers to review. Keep up the good work!