diff --git a/libs/langchain-openai/src/tests/azure/chat_models.test.ts b/libs/langchain-openai/src/tests/azure/chat_models.test.ts index 84bfd726dd76..ee0e5bb55fe2 100644 --- a/libs/langchain-openai/src/tests/azure/chat_models.test.ts +++ b/libs/langchain-openai/src/tests/azure/chat_models.test.ts @@ -1,5 +1,9 @@ import { AzureChatOpenAI } from "../../azure/chat_models.js"; +beforeEach(() => { + delete process.env.OPENAI_API_KEY; +}); + test("Test Azure OpenAI serialization from azure endpoint", async () => { const chat = new AzureChatOpenAI({ azureOpenAIEndpoint: "https://foobar.openai.azure.com/", @@ -8,7 +12,7 @@ test("Test Azure OpenAI serialization from azure endpoint", async () => { azureOpenAIApiKey: "foo", }); expect(JSON.stringify(chat)).toEqual( - `{"lc":1,"type":"constructor","id":["langchain","chat_models","azure_openai","AzureChatOpenAI"],"kwargs":{"azure_endpoint":"https://foobar.openai.azure.com/","openai_api_key":{"lc":1,"type":"secret","id":["OPENAI_API_KEY"]},"deployment_name":"gpt-4o"}}` + `{"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"]}}}` ); }); @@ -20,7 +24,7 @@ test("Test Azure OpenAI serialization from base path", async () => { azureOpenAIApiKey: "foo", }); expect(JSON.stringify(chat)).toEqual( - `{"lc":1,"type":"constructor","id":["langchain","chat_models","azure_openai","AzureChatOpenAI"],"kwargs":{"openai_api_key":{"lc":1,"type":"secret","id":["OPENAI_API_KEY"]},"azure_endpoint":"https://foobar.openai.azure.com","deployment_name":"gpt-4o"}}` + `{"lc":1,"type":"constructor","id":["langchain","chat_models","azure_openai","AzureChatOpenAI"],"kwargs":{"openai_api_version":"2024-08-01-preview","azure_open_ai_api_key":{"lc":1,"type":"secret","id":["AZURE_OPENAI_API_KEY"]},"azure_endpoint":"https://foobar.openai.azure.com","deployment_name":"gpt-4o-mini"}}` ); }); @@ -32,6 +36,6 @@ test("Test Azure OpenAI serialization from instance name", async () => { azureOpenAIApiKey: "foo", }); expect(JSON.stringify(chat)).toEqual( - `{"lc":1,"type":"constructor","id":["langchain","chat_models","azure_openai","AzureChatOpenAI"],"kwargs":{"openai_api_key":{"lc":1,"type":"secret","id":["OPENAI_API_KEY"]},"azure_endpoint":"https://foobar.openai.azure.com/","deployment_name":"gpt-4o"}}` + `{"lc":1,"type":"constructor","id":["langchain","chat_models","azure_openai","AzureChatOpenAI"],"kwargs":{"azure_open_ai_api_instance_name":"foobar","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"]},"azure_endpoint":"https://foobar.openai.azure.com/"}}` ); }); diff --git a/libs/langchain-openai/src/tests/chat_models.test.ts b/libs/langchain-openai/src/tests/chat_models.test.ts index a24c180ff1d0..274c150845ef 100644 --- a/libs/langchain-openai/src/tests/chat_models.test.ts +++ b/libs/langchain-openai/src/tests/chat_models.test.ts @@ -194,6 +194,7 @@ describe("strict tool calling", () => { }), { strict: true, + method: "functionCalling", } ); @@ -238,7 +239,8 @@ describe("strict tool calling", () => { const modelWithTools = model.withStructuredOutput( z.object({ location: z.string().describe("The location to get the weather for"), - }) + }), + { method: "functionCalling" } ); // This will fail since we're not returning a valid response in our mocked fetch function.