Skip to content

AttributeError: 'HuggingFaceEmbeddings' object has no attribute 'client' #155

@HeloiseS

Description

@HeloiseS

Hi!

I've been trying to follow your tutorials on my local machine (I followed the workshop where we did it in GH codespace)

When running the following code:

if not client.collection_exists(qdrant_collection):
    print("Creating collection:", qdrant_collection)
    client.create_collection(
        qdrant_collection,
        vectors_config=models.VectorParams(
            size=embedding.client.get_sentence_embedding_dimension(),
            distance=models.Distance.COSINE,
        ),
    )
    lcqdrant = Qdrant(
        client=client, collection_name=qdrant_collection, embeddings=embedding
    )
    uuids = lcqdrant.add_documents(documents=documents)
else:
    lcqdrant = Qdrant(
        client=client, collection_name=qdrant_collection, embeddings=embedding
    )

I get the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[14], line 6
      1 if not client.collection_exists(qdrant_collection):
      2     print("Creating collection:", qdrant_collection)
      3     client.create_collection(
      4         qdrant_collection,
      5         vectors_config=models.VectorParams(
----> 6             size=embedding.client.get_sentence_embedding_dimension(),
      7             distance=models.Distance.COSINE,
      8         ),
      9     )
     10     lcqdrant = Qdrant(
     11         client=client, collection_name=qdrant_collection, embeddings=embedding
     12     )
     13     uuids = lcqdrant.add_documents(documents=documents)

File ~/anaconda3/lib/python3.10/site-packages/pydantic/main.py:984, in BaseModel.__getattr__(self, item)
    981     return super().__getattribute__(item)  # Raises AttributeError if appropriate
    982 else:
    983     # this is the current error
--> 984     raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')

AttributeError: 'HuggingFaceEmbeddings' object has no attribute 'client'

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions