According to OpenAi's documentation and a large number of demonstrations I found online, the following code should run without a problem in Python:
import openai
response = openai.Embedding.create(
input="porcine pals say",
model="text-embedding-ada-002"
)
However, when I run this code on my local Jupyter instance, I receive the following error:
AttributeError Traceback (most recent call last)
>! <ipython-input-209-e3e908b35b81> in <module>
1 import openai
2 response = openai.Embedding.create(
3 input="porcine pals say",
4 model="text-embedding-ada-002"
5 )
AttributeError: module 'openai' has no attribute 'Embedding'
This is unique only for Embedding, as other Engines (like Completion) run fine on my local machine.
I upgraded my openai library to the newest version, but the error remained. I also asked ChatGPT for help, but its response appeared to be nothing more than a work-around using Completion (not Embedding). This did not work.
My question is whether others have encountered the same problem? If so, how did you resolve it? I presently don't have a workaround to retrieve embeddings from OpenAI's new 'text-embedding-ada-oo2' model. So even if there is a workaround I could use- that would be great.
I tested your code with:
3.11.1
and OpenAI Python library0.26.3
3.11.1
and OpenAI Python library0.26.5
(latest version)In both cases I ran
test.py
and the OpenAI API returned the embedding:test.py
Solution
STEP 1: Upgrade Python
See the instructions.
STEP 2: Upgrade OpenAI Python library