Skip to content

Commit

Permalink
Adds tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 committed Feb 7, 2025
1 parent f40a649 commit cfb9221
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions libs/langchain-openai/src/tests/azure/chat_models.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ test("Test Azure OpenAI serialization from azure endpoint", async () => {
);
});

test("Test Azure OpenAI serialization does not pass along extra params", async () => {
const chat = new AzureChatOpenAI({
azureOpenAIEndpoint: "https://foobar.openai.azure.com/",
azureOpenAIApiDeploymentName: "gpt-4o",
azureOpenAIApiVersion: "2024-08-01-preview",
azureOpenAIApiKey: "foo",
extraParam: "extra",
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any);
expect(JSON.stringify(chat)).toEqual(
`{"lc":1,"type":"constructor","id":["langchain","chat_models","azure_openai","AzureChatOpenAI"],"kwargs":{"azure_endpoint":"https://foobar.openai.azure.com/","deployment_name":"gpt-4o","openai_api_version":"2024-08-01-preview","azure_open_ai_api_key":{"lc":1,"type":"secret","id":["AZURE_OPENAI_API_KEY"]}}}`
);
});

test("Test Azure OpenAI serialization from base path", async () => {
const chat = new AzureChatOpenAI({
azureOpenAIBasePath:
Expand Down
12 changes: 12 additions & 0 deletions libs/langchain-openai/src/tests/chat_models.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,15 @@ describe("strict tool calling", () => {
}
});
});

test("Test OpenAI serialization doesn't pass along extra params", async () => {
const chat = new ChatOpenAI({
apiKey: "test-key",
model: "o3-mini",
somethingUnexpected: true,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any);
expect(JSON.stringify(chat)).toEqual(
`{"lc":1,"type":"constructor","id":["langchain","chat_models","openai","ChatOpenAI"],"kwargs":{"openai_api_key":{"lc":1,"type":"secret","id":["OPENAI_API_KEY"]},"model":"o3-mini"}}`
);
});

0 comments on commit cfb9221

Please sign in to comment.