-
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
openai
has no ChatCompletion
attribute
#2505
Comments
I can't replicate this, here's a minimal example from the docs: from langchain.chat_models import ChatOpenAI
from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate
prompt = PromptTemplate(
input_variables=["product"],
template="What is a good name for a company that makes {product}?",
)
chat = ChatOpenAI(temperature=0)
chain = LLMChain(llm=chat, prompt=prompt)
print(chain.run('colorful socks')) langchain version -> 0.0.133 and openai -> 0.27.4 |
Same here with openai version 0.27.4 and langchain 0.0.134. |
My bad. I put openai.py to the current directory and run the python script that import openai which lead to the error. |
I also faced similar issues, but it's not because accidentally putting openai.py into current directory. I suspect that openai change their code from Source: https://pypi.org/project/openai/ |
the langchain docs have changed to:
which is now causing this issue... what openai package do we have to lock to (not indicated in docs), but the getting started page is failing miserably |
For a temporary fix/workaround I was able to remove the The new code snippet would look like this openai.api_key = openai_api_key
if openai_organization:
openai.organization = openai_organization
if openai_api_base:
openai.api_base = openai_api_base
values["client"] = openai.ChatCompletion
if values["n"] < 1:
raise ValueError("n must be at least 1.")
if values["n"] > 1 and values["streaming"]:
raise ValueError("n must be 1 when streaming.")
return values
|
Hi, @ChuckJonas! 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, you were experiencing an error when trying to initialize a However, the issue has been resolved by marcjulianschwarz who suggested a temporary fix/workaround by modifying the code in Before we close this issue, we wanted to check with you if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself or it will be automatically closed in 7 days. Thank you for your understanding and contribution to the LangChain project! |
Trying to initialize a
ChatOpenAI
is resulting in this error:I've upgraded all my packages to latest...
The text was updated successfully, but these errors were encountered: