Home / Class/ QdrantVectorStore Class — langchain Architecture

QdrantVectorStore Class — langchain Architecture

Architecture documentation for the QdrantVectorStore class in qdrant.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  6c2cb791_29a8_eff5_cb42_cc2f32736f88["QdrantVectorStore"]
  9d2a2799_754f_4de7_e4e6_081d8ea620e0["VectorStore"]
  6c2cb791_29a8_eff5_cb42_cc2f32736f88 -->|extends| 9d2a2799_754f_4de7_e4e6_081d8ea620e0
  c58e6864_9429_b081_883b_39ba15df0485["Embeddings"]
  6c2cb791_29a8_eff5_cb42_cc2f32736f88 -->|extends| c58e6864_9429_b081_883b_39ba15df0485
  962131d8_84d2_edbf_7e8e_31bc4e860264["qdrant.py"]
  6c2cb791_29a8_eff5_cb42_cc2f32736f88 -->|defined in| 962131d8_84d2_edbf_7e8e_31bc4e860264
  ae4d6615_56a3_f51b_ca9b_711fadb1fca0["__init__()"]
  6c2cb791_29a8_eff5_cb42_cc2f32736f88 -->|method| ae4d6615_56a3_f51b_ca9b_711fadb1fca0
  b2bf42e0_652f_c3d2_26bd_52a81cab2f86["client()"]
  6c2cb791_29a8_eff5_cb42_cc2f32736f88 -->|method| b2bf42e0_652f_c3d2_26bd_52a81cab2f86
  4bd99073_b463_478e_f97d_0d7d89e22a6a["embeddings()"]
  6c2cb791_29a8_eff5_cb42_cc2f32736f88 -->|method| 4bd99073_b463_478e_f97d_0d7d89e22a6a
  e1ed3b4a_65a9_96c1_6cf8_f8afa02a2fa4["_get_retriever_tags()"]
  6c2cb791_29a8_eff5_cb42_cc2f32736f88 -->|method| e1ed3b4a_65a9_96c1_6cf8_f8afa02a2fa4
  85f31431_278d_55cc_44d2_1c9628db313c["_require_embeddings()"]
  6c2cb791_29a8_eff5_cb42_cc2f32736f88 -->|method| 85f31431_278d_55cc_44d2_1c9628db313c
  a307f6a1_9626_cf1e_9491_637117815472["sparse_embeddings()"]
  6c2cb791_29a8_eff5_cb42_cc2f32736f88 -->|method| a307f6a1_9626_cf1e_9491_637117815472
  d6a5fbb6_6091_5593_ed48_7ecf1922c139["from_texts()"]
  6c2cb791_29a8_eff5_cb42_cc2f32736f88 -->|method| d6a5fbb6_6091_5593_ed48_7ecf1922c139
  7012fc82_c815_8e9c_9d3f_dd7bf096d1e6["from_existing_collection()"]
  6c2cb791_29a8_eff5_cb42_cc2f32736f88 -->|method| 7012fc82_c815_8e9c_9d3f_dd7bf096d1e6
  f87fcadf_38b5_a94c_0f24_2f845af34704["add_texts()"]
  6c2cb791_29a8_eff5_cb42_cc2f32736f88 -->|method| f87fcadf_38b5_a94c_0f24_2f845af34704
  3bffa226_3957_00ef_8a18_f8a49951e70f["similarity_search()"]
  6c2cb791_29a8_eff5_cb42_cc2f32736f88 -->|method| 3bffa226_3957_00ef_8a18_f8a49951e70f
  7300606d_9247_22dd_f225_1f91a1af7939["similarity_search_with_score()"]
  6c2cb791_29a8_eff5_cb42_cc2f32736f88 -->|method| 7300606d_9247_22dd_f225_1f91a1af7939

Relationship Graph

Source Code

libs/partners/qdrant/langchain_qdrant/qdrant.py lines 36–1295

class QdrantVectorStore(VectorStore):
    """Qdrant vector store integration.

    Setup:
        Install `langchain-qdrant` package.

        ```bash
        pip install -qU langchain-qdrant
        ```

    Key init args — indexing params:
        collection_name:
            Name of the collection.
        embedding:
            Embedding function to use.
        sparse_embedding:
            Optional sparse embedding function to use.

    Key init args — client params:
        client:
            Qdrant client to use.
        retrieval_mode:
            Retrieval mode to use.

    Instantiate:
        ```python
        from langchain_qdrant import QdrantVectorStore
        from qdrant_client import QdrantClient
        from qdrant_client.http.models import Distance, VectorParams
        from langchain_openai import OpenAIEmbeddings

        client = QdrantClient(":memory:")

        client.create_collection(
            collection_name="demo_collection",
            vectors_config=VectorParams(size=1536, distance=Distance.COSINE),
        )

        vector_store = QdrantVectorStore(
            client=client,
            collection_name="demo_collection",
            embedding=OpenAIEmbeddings(),
        )
        ```

    Add Documents:
        ```python
        from langchain_core.documents import Document
        from uuid import uuid4

        document_1 = Document(page_content="foo", metadata={"baz": "bar"})
        document_2 = Document(page_content="thud", metadata={"bar": "baz"})
        document_3 = Document(page_content="i will be deleted :(")

        documents = [document_1, document_2, document_3]
        ids = [str(uuid4()) for _ in range(len(documents))]
        vector_store.add_documents(documents=documents, ids=ids)
        ```

    Delete Documents:
        ```python
        vector_store.delete(ids=[ids[-1]])
        ```

    Search:
        ```python
        results = vector_store.similarity_search(
            query="thud",
            k=1,
        )
        for doc in results:
            print(f"* {doc.page_content} [{doc.metadata}]")
        ```

        ```python
        *thud[
            {
                "bar": "baz",
                "_id": "0d706099-6dd9-412a-9df6-a71043e020de",
                "_collection_name": "demo_collection",
            }

Frequently Asked Questions

What is the QdrantVectorStore class?
QdrantVectorStore is a class in the langchain codebase, defined in libs/partners/qdrant/langchain_qdrant/qdrant.py.
Where is QdrantVectorStore defined?
QdrantVectorStore is defined in libs/partners/qdrant/langchain_qdrant/qdrant.py at line 36.
What does QdrantVectorStore extend?
QdrantVectorStore extends VectorStore, Embeddings.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free