Reputation: 1106
I have been using OpenAI with langchain in my application and recently tries to switch to Azure OpenAI but keep getting error - Error: Azure OpenAI API deployment name not found
.
Following is the code I am using
import { AzureChatOpenAI } from '@langchain/openai';
const llm = new AzureChatOpenAI({
temperature: 0,
azureOpenAIApiDeploymentName: 'GPT35turbo16k',
azureOpenAIApiVersion: '0613',
azureOpenAIApiInstanceName: 'https://my-instance-name.openai.azure.com/',
azureOpenAIApiKey: 'my-api-key',
streaming: true,
verbose: true,
callbacks: [
{
handleLLMNewToken(token: string) {
res.write(
JSON.stringify({
type: 'html',
content: token,
}),
);
},
},
],
});
I already created deployment in Azure and using deployment name instead of model name. screenshot of azure attached.
any help is appreciated. Thanks
Upvotes: 0
Views: 483
Reputation: 388
click on deployment name hyperlink in your screenshot and go to the deployment detail page as below:
Upvotes: 0
Reputation: 1211
The request looks good, except for the API version. You should get the right version from the Microsoft documentation.
As of now, the latest stable General Availability API version is 2024-02-01
. In your example, you should have:
import { AzureChatOpenAI } from '@langchain/openai';
const llm = new AzureChatOpenAI({
temperature: 0,
azureOpenAIApiDeploymentName: 'GPT35turbo16k',
azureOpenAIApiVersion: '2024-02-01', // use the right version here
azureOpenAIApiInstanceName: 'https://my-instance-name.openai.azure.com/',
azureOpenAIApiKey: 'my-api-key',
streaming: true,
verbose: true,
callbacks: [
{
handleLLMNewToken(token: string) {
res.write(
JSON.stringify({
type: 'html',
content: token,
}),
);
},
},
],
});
Upvotes: 0