qdrant / qdrant-haystack

An integration of Qdrant ANN vector database backend with Haystack
Apache License 2.0
43 stars 12 forks source link

QdrantDocumentStore `init` error #30

Closed bilgeyucel closed 1 year ago

bilgeyucel commented 1 year ago

A community member reported an issue about QdrantDocumentStore. It raises a type error when initialized for some reason. I could reproduce the issue but don't have a clear idea of what is wrong. Can you guide us here @kacperlukawski?

Here's the discord thread: https://discord.com/channels/993534733298450452/1149609255062737028 Here's a colab notebook to reproduce the issue

TypeError                                 Traceback (most recent call last)
<ipython-input-2-0bda11689eaf> in <cell line: 3>()
      1 from qdrant_haystack import QdrantDocumentStore
      2 
----> 3 document_store = QdrantDocumentStore(
      4     ":memory:",
      5     index="Document",

/usr/local/lib/python3.10/dist-packages/haystack/nodes/base.py in wrapper_exportable_to_yaml(self, *args, **kwargs)
     44 
     45         # Call the actuall __init__ function with all the arguments
---> 46         init_func(self, *args, **kwargs)
     47 
     48     return wrapper_exportable_to_yaml

/usr/local/lib/python3.10/dist-packages/qdrant_haystack/document_stores/qdrant.py in __init__(self, location, url, port, grpc_port, prefer_grpc, https, api_key, prefix, timeout, host, path, index, embedding_dim, content_field, name_field, embedding_field, similarity, return_embedding, progress_bar, duplicate_documents, recreate_index, shard_number, replication_factor, write_consistency_factor, on_disk_payload, hnsw_config, optimizers_config, wal_config, quantization_config, init_from, wait_result_from_api, metadata)
     78         super().__init__()
     79 
---> 80         self.client = qdrant_client.QdrantClient(
     81             location=location,
     82             url=url,

/usr/local/lib/python3.10/dist-packages/qdrant_client/qdrant_client.py in __init__(self, location, url, port, grpc_port, prefer_grpc, https, api_key, prefix, timeout, host, path, **kwargs)
     75         **kwargs: Any,
     76     ):
---> 77         super().__init__(**kwargs)
     78         self._client: QdrantBase
     79 

/usr/local/lib/python3.10/dist-packages/qdrant_client/qdrant_fastembed.py in __init__(self, **kwargs)
     36     def __init__(self, **kwargs: Any):
     37         self.embedding_model_name = self.DEFAULT_EMBEDDING_MODEL
---> 38         super().__init__(**kwargs)
     39 
     40     def set_model(self, embedding_model_name: str) -> None:

TypeError: object.__init__() takes exactly one argument (the instance to initialize)
TuanaCelik commented 1 year ago

Some more info. Here's how they initialize the document store:

  document_store = QdrantDocumentStore(
           location=":memory:",
           index="Document",
           embedding_dim=768,
           recreate_index=True,
           similarity="cosine"
      )
TuanaCelik commented 1 year ago

Some more context from our community member:

I have a suspicion what the problem is https://github.com/qdrant/qdrant-client released four days ago 1.5.0 and now you have to initialize Qdrant like this:

client = QdrantClient(":memory:")

client.add(
    collection_name="demo_collection",
    documents=docs,
    metadata=metadata,
    ids=ids
)

But QdrantDocumentStore initialises it with more parameters. So the versions do not fit anymore

joein commented 1 year ago

Hey @TuanaCelik @bilgeyucel @MathiasSpanhove

Thanks for pointing it out

It seems that metadata argument was not passed correctly into the QdrantClient

31

TuanaCelik commented 1 year ago

Thank you @joein - I see there's a PR here which seems like will resolve this issue. Let us know if we have to inform people to update one of the packages 🙏

kacperlukawski commented 1 year ago

@TuanaCelik I'm already reviewing the PR and the new version will be released today. I'll let you know here and also answer on Discord.

kacperlukawski commented 1 year ago

@bilgeyucel @TuanaCelik We've just released version 1.0.8. This is a hotfix that allows using qdrant up to 1.4. There will be another release this week so that we can support Qdrant 1.5 as well. That requires fixing qdrant-client first.

kacperlukawski commented 1 year ago

The latest release, 1.0.10, allows using some newer versions of the qdrant-client.