Replies: 3 comments
-
Answer generated by a 🤖 AnswerI understand that you're encountering an In your code, you've set the OpenAI API key using the line To address this issue, I suggest setting the openai.api_key = 'xxx' Please replace If you're using custom embeddings, ensure that the model is correctly initialized and the embeddings are correctly generated. In case you're using Azure OpenAI, you need to set the openai.api_type = "azure"
openai.api_base = "https://<foo-bar>.openai.azure.com"
openai.api_version = "2022-12-01"
os.environ["OPENAI_API_KEY"] = "youcannottellanyone"
openai.api_key = os.getenv("OPENAI_API_KEY") And initialize the llm = AzureOpenAI(
engine="<foo-bar-deployment>",
temperature=0,
openai_api_version=openai.api_version,
model_kwargs={
"api_key": openai.api_key,
"api_base": openai.api_base,
"api_type": openai.api_type,
"api_version": openai.api_version,
},
) Please replace This solution should help resolve the 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. |
Beta Was this translation helpful? Give feedback.
-
The way llama-index is implemented forces you to set the environment variable before importing the VectorStoreIndex. So, put |
Beta Was this translation helpful? Give feedback.
-
If this is the case, then the documentation needs to be updated here. |
Beta Was this translation helpful? Give feedback.
-
Question Validation
Question
I'm encountering an AuthenticationError when trying to generate embeddings using the OpenAI API in my application that uses the llama_index library. Here's a snippet of the code where the issue occurs:
And the error message I get is:
The error is raised when trying to create an embedding using the OpenAI's service, but it fails due to an authentication issue. It seems like the tenacity library is trying to retry the operation, but it fails every time due to the same error.
Any help on how to resolve this would be much appreciated.
Beta Was this translation helpful? Give feedback.
All reactions