-
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.
partners[minor]: Add standard chat model tests to partner packages
- Loading branch information
1 parent
b5de9a6
commit 4820bf9
Showing
11 changed files
with
216 additions
and
42 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
28 changes: 28 additions & 0 deletions
28
libs/langchain-azure-openai/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,28 @@ | ||
/* eslint-disable no-process-env */ | ||
import { test, expect } from "@jest/globals"; | ||
import { ChatModelIntegrationTests } from "@langchain/standard-tests"; | ||
import { AIMessageChunk } from "@langchain/core/messages"; | ||
import { AzureChatOpenAI, ChatOpenAICallOptions } from "../chat_models.js"; | ||
|
||
class AzureChatOpenAIStandardIntegrationTests extends ChatModelIntegrationTests< | ||
ChatOpenAICallOptions, | ||
AIMessageChunk | ||
> { | ||
constructor() { | ||
super({ | ||
Cls: AzureChatOpenAI, | ||
chatModelHasToolCalling: true, | ||
chatModelHasStructuredOutput: true, | ||
constructorArgs: { | ||
model: "gpt-3.5-turbo", | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
const testClass = new AzureChatOpenAIStandardIntegrationTests(); | ||
|
||
test("AzureChatOpenAIStandardIntegrationTests", async () => { | ||
const testResults = await testClass.runTests(); | ||
expect(testResults).toBe(true); | ||
}); |
39 changes: 39 additions & 0 deletions
39
libs/langchain-azure-openai/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 { AzureChatOpenAI, ChatOpenAICallOptions } from "../chat_models.js"; | ||
|
||
class AzureChatOpenAIStandardUnitTests extends ChatModelUnitTests< | ||
ChatOpenAICallOptions, | ||
AIMessageChunk | ||
> { | ||
constructor() { | ||
super({ | ||
Cls: AzureChatOpenAI, | ||
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.OPENAI_API_KEY = "test"; | ||
} | ||
|
||
testChatModelInitApiKey() { | ||
// Unset the API key env var here so this test can properly check | ||
// the API key class arg. | ||
process.env.OPENAI_API_KEY = ""; | ||
super.testChatModelInitApiKey(); | ||
// Re-set the API key env var here so other tests can run properly. | ||
process.env.OPENAI_API_KEY = "test"; | ||
} | ||
} | ||
|
||
const testClass = new AzureChatOpenAIStandardUnitTests(); | ||
|
||
test("AzureChatOpenAIStandardUnitTests", () => { | ||
const testResults = testClass.runTests(); | ||
expect(testResults).toBe(true); | ||
}); |
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
26 changes: 26 additions & 0 deletions
26
libs/langchain-cloudflare/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,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 { ChatCloudflareWorkersAI, ChatCloudflareWorkersAICallOptions } from "../chat_models.js"; | ||
|
||
class ChatCloudflareWorkersAIStandardIntegrationTests extends ChatModelIntegrationTests< | ||
ChatCloudflareWorkersAICallOptions, | ||
AIMessageChunk | ||
> { | ||
constructor() { | ||
super({ | ||
Cls: ChatCloudflareWorkersAI, | ||
chatModelHasToolCalling: true, | ||
chatModelHasStructuredOutput: true, | ||
constructorArgs: {}, | ||
}); | ||
} | ||
} | ||
|
||
const testClass = new ChatCloudflareWorkersAIStandardIntegrationTests(); | ||
|
||
test("ChatCloudflareWorkersAIStandardIntegrationTests", async () => { | ||
const testResults = await testClass.runTests(); | ||
expect(testResults).toBe(true); | ||
}); |
30 changes: 30 additions & 0 deletions
30
libs/langchain-cloudflare/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,30 @@ | ||
/* eslint-disable no-process-env */ | ||
import { test, expect } from "@jest/globals"; | ||
import { ChatModelUnitTests } from "@langchain/standard-tests"; | ||
import { AIMessageChunk } from "@langchain/core/messages"; | ||
import { ChatCloudflareWorkersAI, ChatCloudflareWorkersAICallOptions } from "../chat_models.js"; | ||
|
||
class ChatCloudflareWorkersAIStandardUnitTests extends ChatModelUnitTests< | ||
ChatCloudflareWorkersAICallOptions, | ||
AIMessageChunk | ||
> { | ||
constructor() { | ||
super({ | ||
Cls: ChatCloudflareWorkersAI, | ||
chatModelHasToolCalling: true, | ||
chatModelHasStructuredOutput: true, | ||
constructorArgs: {}, | ||
}); | ||
} | ||
|
||
testChatModelInitApiKey() { | ||
console.warn("Skipping testChatModelInitApiKey for ChatCloudflareWorkersAI. Multiple API keys are required."); | ||
} | ||
} | ||
|
||
const testClass = new ChatCloudflareWorkersAIStandardUnitTests(); | ||
|
||
test("ChatCloudflareWorkersAIStandardUnitTests", () => { | ||
const testResults = testClass.runTests(); | ||
expect(testResults).toBe(true); | ||
}); |
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
26 changes: 26 additions & 0 deletions
26
libs/langchain-cohere/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,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 { ChatCohere, CohereChatCallOptions } from "../chat_models.js"; | ||
|
||
class ChatCohereStandardIntegrationTests extends ChatModelIntegrationTests< | ||
CohereChatCallOptions, | ||
AIMessageChunk | ||
> { | ||
constructor() { | ||
super({ | ||
Cls: ChatCohere, | ||
chatModelHasToolCalling: true, | ||
chatModelHasStructuredOutput: true, | ||
constructorArgs: {}, | ||
}); | ||
} | ||
} | ||
|
||
const testClass = new ChatCohereStandardIntegrationTests(); | ||
|
||
test("ChatCohereStandardIntegrationTests", async () => { | ||
const testResults = await testClass.runTests(); | ||
expect(testResults).toBe(true); | ||
}); |
39 changes: 39 additions & 0 deletions
39
libs/langchain-cohere/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 { ChatCohere, CohereChatCallOptions } from "../chat_models.js"; | ||
|
||
class ChatCohereStandardUnitTests extends ChatModelUnitTests< | ||
CohereChatCallOptions, | ||
AIMessageChunk | ||
> { | ||
constructor() { | ||
super({ | ||
Cls: ChatCohere, | ||
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.COHERE_API_KEY = "test"; | ||
} | ||
|
||
testChatModelInitApiKey() { | ||
// Unset the API key env var here so this test can properly check | ||
// the API key class arg. | ||
process.env.COHERE_API_KEY = ""; | ||
super.testChatModelInitApiKey(); | ||
// Re-set the API key env var here so other tests can run properly. | ||
process.env.COHERE_API_KEY = "test"; | ||
} | ||
} | ||
|
||
const testClass = new ChatCohereStandardUnitTests(); | ||
|
||
test("ChatCohereStandardUnitTests", () => { | ||
const testResults = testClass.runTests(); | ||
expect(testResults).toBe(true); | ||
}); |
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