-
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 (#…
…5660) * partners[minor]: Add standard chat model tests to partner packages * google genai * yarn * groq * groq nit and mistral * add to azure in chat openai * chore: lint files * drop azure openai pkg * add generic constructor args to standard tests pkg * implement cloudflare standard tests * implement cohere standard tests * google genai package standard tests * groq * allow for custom function call ids, fix mistral * azure tests * chore: lint files * update standard tests gh action to run all pkgs * chore: lint files * revert workflow file rename * fix workflow job naming issue * add anthropic, fix api keys * cache deps? * fix build * update standard tests * cr * fix * remove dep on job which doesnt exist * cr * cr
- Loading branch information
1 parent
1959ca7
commit e834086
Showing
28 changed files
with
829 additions
and
106 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
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
53 changes: 53 additions & 0 deletions
53
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,53 @@ | ||
/* 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() { | ||
if ( | ||
!process.env.CLOUDFLARE_ACCOUNT_ID || | ||
!process.env.CLOUDFLARE_API_TOKEN | ||
) { | ||
throw new Error( | ||
"Skipping Cloudflare Workers AI integration tests because CLOUDFLARE_ACCOUNT_ID or CLOUDFLARE_API_TOKEN is not set" | ||
); | ||
} | ||
super({ | ||
Cls: ChatCloudflareWorkersAI, | ||
chatModelHasToolCalling: false, | ||
chatModelHasStructuredOutput: false, | ||
constructorArgs: {}, | ||
}); | ||
} | ||
|
||
async testUsageMetadataStreaming() { | ||
this.skipTestMessage( | ||
"testUsageMetadataStreaming", | ||
"ChatCloudflareWorkersAI", | ||
"Streaming tokens is not currently supported." | ||
); | ||
} | ||
|
||
async testUsageMetadata() { | ||
this.skipTestMessage( | ||
"testUsageMetadata", | ||
"ChatCloudflareWorkersAI", | ||
"Usage metadata tokens is not currently supported." | ||
); | ||
} | ||
} | ||
|
||
const testClass = new ChatCloudflareWorkersAIStandardIntegrationTests(); | ||
|
||
test("ChatCloudflareWorkersAIStandardIntegrationTests", async () => { | ||
const testResults = await testClass.runTests(); | ||
expect(testResults).toBe(true); | ||
}); |
50 changes: 50 additions & 0 deletions
50
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,50 @@ | ||
/* eslint-disable no-process-env */ | ||
import { test, expect } from "@jest/globals"; | ||
import { ChatModelUnitTests } from "@langchain/standard-tests"; | ||
import { AIMessageChunk } from "@langchain/core/messages"; | ||
import { LangSmithParams } from "@langchain/core/language_models/chat_models"; | ||
import { | ||
ChatCloudflareWorkersAI, | ||
ChatCloudflareWorkersAICallOptions, | ||
} from "../chat_models.js"; | ||
|
||
class ChatCloudflareWorkersAIStandardUnitTests extends ChatModelUnitTests< | ||
ChatCloudflareWorkersAICallOptions, | ||
AIMessageChunk | ||
> { | ||
constructor() { | ||
super({ | ||
Cls: ChatCloudflareWorkersAI, | ||
chatModelHasToolCalling: false, | ||
chatModelHasStructuredOutput: false, | ||
constructorArgs: {}, | ||
}); | ||
} | ||
|
||
testChatModelInitApiKey() { | ||
this.skipTestMessage( | ||
"testChatModelInitApiKey", | ||
"ChatCloudflareWorkersAI", | ||
this.multipleApiKeysRequiredMessage | ||
); | ||
} | ||
|
||
expectedLsParams(): Partial<LangSmithParams> { | ||
console.warn( | ||
"Overriding testStandardParams. ChatCloudflareWorkersAI does not support temperature or max tokens." | ||
); | ||
return { | ||
ls_provider: "string", | ||
ls_model_name: "string", | ||
ls_model_type: "chat", | ||
ls_stop: ["Array<string>"], | ||
}; | ||
} | ||
} | ||
|
||
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
47 changes: 47 additions & 0 deletions
47
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,47 @@ | ||
/* 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() { | ||
if (!process.env.COHERE_API_KEY) { | ||
throw new Error( | ||
"Can not run Cohere integration tests because COHERE_API_KEY is not set" | ||
); | ||
} | ||
super({ | ||
Cls: ChatCohere, | ||
chatModelHasToolCalling: false, | ||
chatModelHasStructuredOutput: false, | ||
constructorArgs: {}, | ||
}); | ||
} | ||
|
||
async testUsageMetadataStreaming() { | ||
this.skipTestMessage( | ||
"testUsageMetadataStreaming", | ||
"ChatCohere", | ||
"Streaming tokens is not currently supported." | ||
); | ||
} | ||
|
||
async testUsageMetadata() { | ||
this.skipTestMessage( | ||
"testUsageMetadata", | ||
"ChatCohere", | ||
"Usage metadata tokens is not currently supported." | ||
); | ||
} | ||
} | ||
|
||
const testClass = new ChatCohereStandardIntegrationTests(); | ||
|
||
test("ChatCohereStandardIntegrationTests", async () => { | ||
const testResults = await testClass.runTests(); | ||
expect(testResults).toBe(true); | ||
}); |
Oops, something went wrong.