Reputation: 159
I get the following error:
ValidationError Traceback (most recent call last) Cell In[31], line 1 ----> 1 embeddings = AzureOpenAIEmbeddings( 2 azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"], 3 azure_deployment="text_embedding" 4 )
File ~/Projects/pia_project/venv/lib/python3.9/site-packages/pydantic/v1/main.py:341, in BaseModel.init(pydantic_self, **data) 339 values, fields_set, validation_error = validate_model(pydantic_self.class, data) 340 if validation_error: --> 341 raise validation_error 342 try: 343 object_setattr(pydantic_self, 'dict', values)
ValidationError: 1 validation error for AzureOpenAIEmbeddings root As of openai>=1.0.0, Azure endpoints should be specified via the
azure_endpoint
param notopenai_api_base
(or aliasbase_url
). (type=value_error)
Eventhough, executing the following Code
from langchain_openai import AzureOpenAIEmbeddings, OpenAIEmbeddings
embeddings = AzureOpenAIEmbeddings(
azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
azure_deployment="text_embedding"
)
The strange thing here is that I use the azure_endpoint parameter, but I still get the error. I have access to the OpenAi embedding model via Azure that's why I'm using it this way. How do I solve this issue?
My packages are: openai 1.12.0 langchain 0.1.8 langchain-openai 0.0.6
Upvotes: 0
Views: 1213
Reputation: 538
That error is all about your langchain version problem. Upgread few things -
pip install --upgrade langchain-openai --user
pip install langchain-core==0.1.46
Again, that issue is related to version compatibility, check accordingly.
Upvotes: 0
Reputation: 1417
I am having the same issue, and found the answer in this question
Snapshot of the answer from the link:
I think you have configured the
OPENAI_API_BASE
environment variable. It's value will be automatically taken foropenai_api_base
. And that's what the error message(marked in bold) trying to say.
Upvotes: -1