Getting error while embedding the text

AttributeError: ‘str’ object has no attribute ‘embeddings’
def get_embeddings(articles, model=“text-embedding-ada-002”):
return openai_client.embeddings.create(inpu= articles, model=model)

query= “what is the berlin wall?”
embed = get_embeddings([query])

import openai
from copy import deepcopy
client = openai.Client()

    embed_object = client.embeddings.create(
      dimensions=1536,  # or 512 for 3-small
      input="what is the berlin wall?",
    # we make a copy of the pydantic return to print that isn't 100+ lines
    shortened_object = deepcopy(embed_object)[0].embedding = \[0].embedding[:5]
except Exception as e:
    print(f"API Error: {e}")

AttributeError: module ‘openai’ has no attribute ‘Client’

Update the library

Version 1.11.1 now currently, I believe.

1 Like