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

AttributeError: 'OpenAIEmbeddings' object has no attribute 'deployment' #3251

Closed
gullerg opened this issue Apr 20, 2023 · 8 comments
Closed

Comments

@gullerg
Copy link

gullerg commented Apr 20, 2023

get this error AttributeError: 'OpenAIEmbeddings' object has no attribute 'deployment' when deploying LangChain to DigitalOcean - however I don't get it locally.

It seems rather odd, as when going through the source code, OpenAIEmbeddings indeed seem to have a 'deployment' attribute. What could cause this?

@MariuszT
Copy link

In my experience, the problem has occurred since version 0.0.145. I do not know the cause. You can do a downgrade to version 0.0.144.

@gullerg
Copy link
Author

gullerg commented Apr 21, 2023

Getting this error after downgrading: TypeError: IndexFlat.search() missing 3 required positional arguments: 'k', 'distances', and 'labels'

Seems to be a regression issue

@AliMirlou
Copy link
Contributor

@gullerg
The problem arises from this PR (specifically this line)

The deployment has a default value though, so if you create a new object from it, it should have no problems.

Unless, you have saved the object created with an older version of LangChain in a file or something, and loaded it back with a newer version. That way, the deployment field does not even exist and you get this error.

@ademidun
Copy link

Getting this error after downgrading: TypeError: IndexFlat.search() missing 3 required positional arguments: 'k', 'distances', and 'labels'

Seems to be a regression issue

I'm guessing the fix is downgrading to 0.0.144?

@Laisky
Copy link

Laisky commented May 29, 2023

@gullerg The problem arises from this PR (specifically this line)

The deployment has a default value though, so if you create a new object from it, it should have no problems.

Unless, you have saved the object created with an older version of LangChain in a file or something, and loaded it back with a newer version. That way, the deployment field does not even exist and you get this error.

Thank you for the explanation. But may I ask if there is any way to update the old version files without re-run all these embeddings process?

@Laisky
Copy link

Laisky commented May 29, 2023

Getting this error after downgrading: TypeError: IndexFlat.search() missing 3 required positional arguments: 'k', 'distances', and 'labels'
Seems to be a regression issue

I'm guessing the fix is downgrading to 0.0.144?

I solved this issue in my fork.

  1. uninstall langchain pip uninstall -y langchain

  2. reinstall langchain pip install git+https://github.com/Laisky/langchain.git@c5505ed3

  3. add an new environment OPENAI_EMBEDDINGS_DEPLOYMENT, this is your azure deployment name of embeddings model.

# -------------------------------------
# azure
# -------------------------------------
os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_KEY"] = settings.OPENAI_AZURE_TOKEN
os.environ["OPENAI_API_BASE"] = settings.OPENAI_AZURE_API
os.environ["OPENAI_API_VERSION"] = "2023-05-15"
os.environ["OPENAI_EMBEDDINGS_DEPLOYMENT"] = "embedding"
# -------------------------------------

20230529T044727Z

done

@hwchase17
Copy link
Contributor

we havent been maintaining compatability with old FAISS versions. the current save/load methods are only garunteed to work with the version they were created with. we'll work on proper forward-compatible serialization of those components at some point - its on our todo list

@dosubot
Copy link

dosubot bot commented Sep 17, 2023

Hi, @gullerg! I'm Dosu, and I'm helping the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.

Based on my understanding of the current state of the issue, you encountered an AttributeError when deploying LangChain to DigitalOcean. MariuszT suggested downgrading to version 0.0.144, but you encountered a TypeError after doing so. AliMirlou explained that the issue arises from a specific PR and suggested creating a new object from it. Laisky asked if there is a way to update old version files without re-running the embeddings process and also provided a solution in their fork of the repository, involving uninstalling and reinstalling LangChain and adding a new environment variable. hwchase17 acknowledged the issue and mentioned that they will work on forward-compatible serialization.

It seems that the issue has been resolved by Laisky's solution in their fork of the repository. The solution involves uninstalling and reinstalling LangChain and adding a new environment variable.

Before we close this issue, could you please let us know if it is still relevant to the latest version of the LangChain repository? If it is, please comment on this issue to let us know. Otherwise, feel free to close the issue yourself or it will be automatically closed in 7 days.

Thank you for your contribution to LangChain!

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Sep 17, 2023
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 24, 2023
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Sep 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants