Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration using OpenAI API hosted on Azure #2013

Closed
gclem opened this issue Jul 19, 2023 · 3 comments
Closed

Configuration using OpenAI API hosted on Azure #2013

gclem opened this issue Jul 19, 2023 · 3 comments
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature auto:question A specific question about the codebase, product, project, or how to use a feature

Comments

@gclem
Copy link

gclem commented Jul 19, 2023

Hi,

There are 2 cases of handling API URL on Azure :

First one is generated from the instance name in .env file
AZURE_OPENAI_API_INSTANCE_NAME=''

Documented here
/** * Azure OpenAI API deployment name to use for completions when making requests to Azure OpenAI. * This is the name of the deployment you created in the Azure portal. * e.g. "my-openai-deployment" * this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/ */ azureOpenAIApiDeploymentName?: string;

Second one, is static.
From what I can see with my account, there are differents typologies of clusters, depending the location of deployement (Azure region)
My second cluster has a generic url path :
AZURE_OPENAI_BASE_PATH=https://westeurope.api.cognitive.microsoft.com/

I have an issue, during the creation of the vector store (seems the class OpenAIEmbedding), not using the overwriten BASEPATH in the config file.

creating vector store... error Error: getaddrinfo ENOTFOUND [instanceName].openai.azure.com at __node_internal_captureLargerStackTrace (node:internal/errors:496:5) at __node_internal_ (node:internal/errors:715:10) at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:118:26) { errno: -3008, code: 'ENOTFOUND',

In ingest-data.ts
const embeddings = new OpenAIEmbeddings();

Any example on making Embedding works without updating the code with Azure on your side folks?

@dosubot dosubot bot added auto:bug Related to a bug, vulnerability, unexpected error with an existing feature auto:question A specific question about the codebase, product, project, or how to use a feature labels Jul 19, 2023
@dosubot
Copy link

dosubot bot commented Jul 19, 2023

Answer generated by a 🤖

Answer

I understand that you're having trouble configuring the OpenAI API on Azure with LangChain. Specifically, you're encountering an issue when creating the vector store with the OpenAIEmbedding class, and you're not sure how to correctly set up the endpoint URL for Azure OpenAI.

From my understanding, the getEndpoint function in langchain/src/util/azure.ts is responsible for generating the endpoint URL. The error message you're seeing suggests that the instance name you're providing isn't being recognized, which could be due to a misconfiguration in your .env file or in the OpenAIEndpointConfig object you're passing to the getEndpoint function.

To address this issue, you should ensure that the azureOpenAIApiInstanceName and azureOpenAIApiDeploymentName are correctly set in your configuration. If you're using a static base path, you should provide it in the azureOpenAIBasePath field, and also provide the azureOpenAIApiDeploymentName and azureOpenAIApiKey.

Here's an example of how you might set up your configuration:

const config: OpenAIEndpointConfig = {
  azureOpenAIApiDeploymentName: 'my-openai-deployment',
  azureOpenAIApiInstanceName: 'my-instance-name',
  azureOpenAIApiKey: 'my-api-key',
  azureOpenAIBasePath: 'https://westeurope.api.cognitive.microsoft.com',
};

const endpoint = getEndpoint(config);

In this example, my-openai-deployment is the name of your deployment, my-instance-name is the name of your instance, and my-api-key is your API key. The azureOpenAIBasePath is set to the static base path you mentioned.

Please replace 'my-openai-deployment', 'my-instance-name', and 'my-api-key' with your actual deployment name, instance name, and API key, respectively.

This is just one potential solution based on the information you've provided. If you're still encountering issues after checking your configuration, it might be a problem with the Azure OpenAI service itself.

If you find this solution helpful and believe it might be useful to others, I encourage you to make a pull request to update the documentation. This way, other users who encounter the same issue can benefit from your experience.

Sources


This response is meant to be useful, save you time, and share context. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

@jacoblee93
Copy link
Collaborator

jacoblee93 commented Jul 19, 2023

Hey @gclem, with the base path the URL to Azure is created like this:

${azureOpenAIBasePath}/${azureOpenAIApiDeploymentName}. It could definitely be better documented though.

Can you try that?

@gclem
Copy link
Author

gclem commented Jul 20, 2023

Thanks, it works for static API url overwritting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature auto:question A specific question about the codebase, product, project, or how to use a feature
Projects
None yet
Development

No branches or pull requests

2 participants