Replies: 1 comment 3 replies
-
It seems that with Langchain v0.2, constructing I solved it by doing two things: 1.) in my OPENAI_API_TYPE=azure
AZURE_OPENAI_API_VERSION=2024-05-01-preview
AZURE_OPENAI_ENDPOINT=https://MY_AZURE_OPENAI_RESOURCE_NAME.openai.azure.com
AZURE_OPENAI_API_KEY=xxx
AZURE_OPENAI_API_DEPLOYMENT_NAME=MY_OPENAI_DEPLOYMENT_NAME # e.g. gpt-4o
AZURE_OPENAI_API_INSTANCE_NAME=MY_OPENAI_MODEL_NAME_HERE # e.g. gpt-4o 2.) In the initialization code of import dotenv from 'dotenv';
dotenv.config();
import {
DefaultAzureCredential,
getBearerTokenProvider
} from '@azure/identity';
function getAzureBearerTokenProvider() {
return getBearerTokenProvider(
new DefaultAzureCredential(),
'https://cognitiveservices.azure.com/.default'
);
}
const azureADTokenProvider = await getAzureBearerTokenProvider();
const llm = new AzureChatOpenAI({
azureADTokenProvider,
azureOpenAIBasePath: `${process.env.AZURE_OPENAI_ENDPOINT}/openai/deployments`,
model: process.env.AZURE_OPENAI_API_INSTANCE_NAME,
temperature: 0,
streaming: true
})); |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
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
I already created deployment in Azure and using deployment name instead of model name. screenshot of azure attached.
Edit:
I am using following version of langchain
"langchain": "^0.1.19",
any help is appreciated. Thanks
Beta Was this translation helpful? Give feedback.
All reactions