0

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 not openai_api_base (or alias base_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

5
  • i think you have given base_url parameter. Recheck the code once again. Commented Feb 20, 2024 at 12:19
  • I hope you have referred AzureOpenAIEmbeddings Commented Feb 20, 2024 at 13:02
  • 1
    Yes, i used this documentation, but got the error. Commented Feb 20, 2024 at 13:39
  • What's the environment that your code is running. Is it vscode? Commented Feb 20, 2024 at 13:57
  • yes it is. I use Python 3.9 on a Mac Commented Feb 20, 2024 at 14:32

2 Answers 2

0

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.

Sign up to request clarification or add additional context in comments.

Comments

-1

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 for openai_api_base. And that's what the error message(marked in bold) trying to say.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.