-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
OpenAIEmbeddings() does not work because of these bugs #12943
Comments
🤖 Hello @pranavgupta2603! I'm Dosu, a bot designed to help you solve bugs, answer questions, and guide you through becoming a contributor to LangChain. While we're waiting for a human maintainer, I'm here to assist you. I'm currently reviewing your issue and will provide you with a full answer shortly. |
🤖 Thank you for providing the detailed information. It seems like the issue is due to the changes in the OpenAI API version 1.0.0. The AttributeError you're encountering is likely because the 'Embedding' attribute has been renamed or removed in the new version of the OpenAI API. In the To resolve this issue, you should check the OpenAI API documentation for the version you are using and update your code accordingly. If the 'Embedding' and 'error' attributes have been removed or renamed, you should use the new attribute or method that replaces them. Here's an example of how you might modify the class OpenAIEmbeddings(BaseEmbeddings):
def __init__(self, openai_api_key, model="davinci", max_tokens=4096, max_retries=3):
super().__init__(openai_api_key, model, max_tokens, max_retries)
self.client = openai.embeddings # updated attribute
def _handle_error(self, error):
if isinstance(error, openai.NewErrorName): # updated attribute
# handle error
pass
else:
# handle other errors
pass Please replace Remember to thoroughly test your code after making these changes to ensure everything works as expected. If you encounter any other issues, feel free to provide more information so we can assist you further. Sources
This response is meant to be useful and save you time. 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. If you want to continue the conversation, start your reply with @dosu-bot. |
Same error |
Facing the same issue. Wonder if they announce something in the summit |
Same error here, waiting solution... |
Same error |
this only happens with the latest |
Docs just updated:
Probably need to initialize the client instead of using |
Do you have an example of how to replace the original code: |
same issue here |
@beongeist haven't gotten around to looking too deeply into it but I assume you'd need to override the OpenAIEmbeddings class. @dosubot's answer might be good starting point but I'm not sure if there are other dependencies that it might mess up. You could also just try using an older version of the openai library if that's still working.
|
pip install openai==0.28.1 as a hotfix works, guys |
same error! fucked my prod lol |
yup we're working on moving to support 1.x releases, but for now please pin |
Initial PR to get OpenAIEmbeddings working with the new sdk fyi @rlancemartin Fixes #12943 --------- Co-authored-by: Bagatur <baskaryan@gmail.com>
Initial PR to get OpenAIEmbeddings working with the new sdk fyi @rlancemartin Fixes #12943 --------- Co-authored-by: Bagatur <baskaryan@gmail.com>
The openai library seems to use openai.embeddings instead of openai.Embedding (langchain-ai/langchain#12943)
Same here, still getting the error: (openai) # pip list | grep openai (openai) # python
Traceback (most recent call last): |
I'll wait to close this until after a release is cut! This will be in 0.0.332 |
While release is getting worked on, you can do
I included the chromadb lock on 0.4.15 because their team is also working on addressing a change in 0.4.16 that would also break your code! #13051 (comment) |
Langchain 0.0.332 released with the chroma team's fix for compatibility with chromadb>=0.4.16 Can now use latest of both |
Initial PR to get OpenAIEmbeddings working with the new sdk fyi @rlancemartin Fixes langchain-ai#12943 --------- Co-authored-by: Bagatur <baskaryan@gmail.com>
System Info
Python Version: 3.11
LangChain Version: 0.0.331
OpenAI Version: 1.0.0
Who can help?
@hwchase17, @agola11, @eyurtsev
Information
Related Components
Reproduction
The following error has been caused due to the recent change in version of OpenAI to 1.0.0
Use OpenAI==0.28.1 to fix this error
With the code:
embeddings = OpenAIEmbeddings()
The error produced is:
AttributeError: module 'openai' has no attribute 'Embedding'. Did you mean: 'embeddings'?
I went through the
langchain/embeddings/openai.py
file and then changedvalue["client"] = openai.Embedding
tovalue["client"] = openai.embeddings
, but then I receive this new error:AttributeError: module 'openai' has no attribute 'error'
in the same file (langchain/embeddings/openai.py
)Expected behavior
There should be no error when calling this function.
The text was updated successfully, but these errors were encountered: