langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
94.44k stars 15.26k forks source link

A ton of Bugs after OpenAI API update today #12956

Closed Vanekkk1 closed 11 months ago

Vanekkk1 commented 1 year ago

System Info

all last versions as of 6/11/2023

Who can help?

No response

Information

Related Components

Reproduction

Run anything with OpeanAI ChatCompletions and Embeddings

Expected behavior

File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/langchain/embeddings/openai.py", line 284, in validate_environment values["client"] = openai.Embedding ^^^^^^^^^^^^^^^^ AttributeError: module 'openai' has no attribute 'Embedding'. Did you mean: 'embeddings'?

File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/langchain/load/serializable.py", line 97, in init super().init(**kwargs) File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pydantic/v1/main.py", line 341, in init raise validation_error pydantic.v1.error_wrappers.ValidationError: 1 validation error for ChatOpenAI root openai has no ChatCompletion attribute, this is likely due to an old version of the openai package. Try upgrading it with pip install --upgrade openai. (type=value_error)

dosubot[bot] commented 1 year ago

🤖

Hello @Vanekkk1,

Great to see you back here! I hope you're doing well. I'm already on your issue and will provide a thorough response shortly.

dosubot[bot] commented 1 year ago

🤖

Based on the information provided, it seems like the OpenAI package might be outdated. The error message suggests that the 'ChatCompletion' attribute is not found in the 'openai' package. This could be due to an older version of the package being used. You can resolve this by upgrading the OpenAI package. You can do this by running the following command in your terminal:

pip install --upgrade openai

This solution was suggested in a similar issue openai has no ChatCompletion attribute in the LangChain repository.

As for the 'ValidationError' in 'main.py', there is no context provided for this error in the given context. Therefore, I cannot provide a solution for this error.

Please provide the relevant context or code snippet where the 'ValidationError' is occurring for further assistance.

As for the changes in the latest OpenAI API update that could have caused these bugs, I wasn't able to find specific information within the LangChain repository. It's possible that the update introduced changes that are incompatible with the current version of LangChain. It would be helpful to review the OpenAI API update notes to understand what changes were made.

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.

msunkarahend commented 1 year ago

@dosu-bot even if i upgrade the openai to openai==1.1.0 version (latest). the issue is not resolved.

vanduyta commented 1 year ago

Hi, the same happened to me since I did not have fixed versions in requirements file. What worked was to install openai 0.28.1 langchain 0.0.330 Good luck and good night after this wonderful evening with errors...

dosuken123 commented 1 year ago

I checked in https://github.com/langchain-ai/langchain/issues/12967 that using openai==v0.28.1 https://github.com/openai/openai-python/releases/tag/v0.28.1 mitigates this issue for now.

openai-python might have changed their API at the recent v1 bump.

msunkarahend commented 1 year ago

Hi, the same happened to me since I did not have fixed versions in requirements file. What worked was to install openai 0.28.1 langchain 0.0.330 Good luck and good night after this wonderful evening with errors...

Thanks @vanduyta and @dosuken123. it worked for me too

Bijas48 commented 12 months ago

Hi, the same happened to me since I did not have fixed versions in requirements file. What worked was to install openai 0.28.1 langchain 0.0.330 Good luck and good night after this wonderful evening with errors...

Its work, thanks man

m-cavazza commented 12 months ago

This could be due to the new 'client' model of the OpenAI API in v1.1.0+ On the regular API where you would previously write: openai.ChatCompletion.create the syntax is now: openai.chat.completions.create check also: https://github.com/openai/openai-python/discussions/631 However, with Langchain we have no such access, and are getting this kind of error:

Langchain
PilotGFX commented 11 months ago

My issue was: ValueError: Expected EmbeddingFunction.call to have the following signature: odict_keys(['self', 'input']), got odict_keys(['self', 'args', 'kwargs']) force installing langchain 0.0.335 and openai 1.3.0 works here. i have not tried all releases. for info i can disclose openai 0.28 is from september the 26th 2023 and openai 1.3.0 is from november 15th 2023.