Package issue in the code

Question:
I have installed openai==0.28.1 and langchain==0.0.316 and unable to execute the code
Repl link:
https://replit.com/@KvspChoudary/apiConversion

code snippet

these are the errors I’m getting

Traceback (most recent call last):
  File "/home/runner/apiConversion/main.py", line 13, in <module>
    embed = OpenAIEmbeddings(model="text-embedding-ada-002")
  File "/home/runner/apiConversion/.pythonlibs/lib/python3.10/site-packages/pydantic/v1/main.py", line 339, in __init__
    values, fields_set, validation_error = validate_model(__pydantic_self__.__class__, data)
  File "/home/runner/apiConversion/.pythonlibs/lib/python3.10/site-packages/pydantic/v1/main.py", line 1100, in validate_model
    values = validator(cls_, values)
  File "/home/runner/apiConversion/.pythonlibs/lib/python3.10/site-packages/langchain_openai/embeddings/base.py", line 224, in validate_environment
    values["client"] = openai.OpenAI(**client_params).embeddings
AttributeError: module 'openai' has no attribute 'OpenAI'

Try running poetry update openai==1.12.0 in the Shell maybe? This updates the package to the latest version available.
Hope this helps!

3 Likes

Thank you for the Solution :smile:

1 Like

No problem, happy to help!
Hope your project goes well!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.