Find answers from the community

Updated 2 months ago

openai` has no `ChatCompletion` attribute

Just started getting this problem - am running llama-index 0.8.63.post2 - and still getting it. Any thoughts?

Plain Text
ChatOpenAI
2023-11-07T14:17:04.805923173Z __root__
2023-11-07T14:17:04.805930274Z   `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)
2023-11-07T14:17:04.805936174Z Traceback (most recent call last):
2023-11-07T14:17:04.805941175Z   File "/tmp/8dbdf9b2c00d254/antenv/lib/python3.11/site-packages/chainlit/utils.py", line 39, in wrapper
2023-11-07T14:17:04.805946375Z     return await user_function(**params_values)
2023-11-07T14:17:04.805951175Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-11-07T14:17:04.805955976Z   File "/tmp/8dbdf9b2c00d254/app.py", line 60, in factory
2023-11-07T14:17:04.805960876Z     llm = LangChainLLM(ChatOpenAI(
2023-11-07T14:17:04.805972377Z                        ^^^^^^^^^^^
2023-11-07T14:17:04.805989079Z   File "/tmp/8dbdf9b2c00d254/antenv/lib/python3.11/site-packages/langchain/load/serializable.py", line 97, in __init__
2023-11-07T14:17:04.805994380Z     super().__init__(**kwargs)
2023-11-07T14:17:04.805999280Z   File "/tmp/8dbdf9b2c00d254/antenv/lib/python3.11/site-packages/pydantic/v1/main.py", line 341, in __init__
2023-11-07T14:17:04.806004280Z     raise validation_error
2023-11-07T14:17:04.806009081Z pydantic.v1.error_wrappers.ValidationError: 1 validation error for ChatOpenAI
2023-11-07T14:17:04.806013981Z __root__
2023-11-07T14:17:04.806018682Z   `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)`
N
L
11 comments
thanks in advance
I think you just need to run pip install --upgrade openai llama_index ?

Although I see you are maybe using ChatOpenAI, which is a langchain class
DOH!! forgot that was in there. Thanks for that
@Logan M
OK - I am trying to run the sample posted here
https://blog.llamaindex.ai/llamaindex-news-special-edition-openai-developer-day-e955f16db4e2

And I am getting this
Maybe try with a fresh venv?

Plain Text
python -m venv venv
source venv/bin/activate
pip install llama-index
I've been using the latest all morning and haven't had an issue πŸ€”
that is fresh - will try again in a few - on a different machine
@Logan M - that worked - thanks - now to undo a whole ton of stuff 😜
Glad it works!
Add a reply
Sign up and join the conversation on Discord