I am trying to run sample code from the openai website for getting embeddings for dataset: https://platform.openai.com/docs/guides/embeddings/use-cases. However, the code returns an error that I can't resolve looking at historical posts
I tried running this code where df is a dataframe I have created with my own data that loaded succesfully.
from openai import OpenAI
client = OpenAI()
def get_embedding(text, model="text-embedding-ada-002"):
text = text.replace("\n", " ")
return client.embeddings.create(input = [text], model=model)['data'][0]['embedding']
df['embedding'] = df.ITEM_DESCRIPTION.apply(lambda x: get_embedding(x, model='text-embedding-ada-002'))
df.to_csv('embedded_output.csv', index=False)
They didn't update their documentation. It is now: