Vectorstore Qdrant Backend

The Qdrant backend: self-hosted on Kubernetes, or Qdrant Cloud.

See https://qdrant.tech/. A vectorstore is one Qdrant collection, with one dense vector per chunk. Its text is in the payload’s page_content, and its metadata in metadata, as LangChain’s QdrantVectorStore stores them.

class smarter.apps.vectorstore.backends.qdrant.QdrantBackend(vectorstore, embeddings=None, client=None, kubernetes=None)[source]

Bases: SmarterVectorstoreBackend

The Qdrant backend.

Parameters:
  • client (QdrantClient | None) – A QdrantClient, e.g. an in-memory one in tests. By default it connects to the self-hosted server, or to the managed service of the vectorstore’s ApiConnection.

  • kubernetes (QdrantKubernetes | None) – The QdrantKubernetes of a self-hosted server. Created if needed.

__init__(vectorstore, embeddings=None, client=None, kubernetes=None)[source]
property client: QdrantClient
create()[source]

Create the index or collection.

Return type:

None

create_snapshot(name)[source]

Take a snapshot, or backup.

Return type:

SnapshotInfo

delete(ids)[source]

Delete chunks.

Ids that do not exist are ignored.

Return type:

None

delete_document(document_id)[source]

Delete every chunk of a document, whatever their number.

Return type:

None

delete_snapshot(name)[source]

Delete a snapshot, or backup.

Return type:

None

destroy()[source]

Delete the index or collection, and any infrastructure that Smarter runs.

Return type:

None

drop()[source]

Delete the index or collection, and its data.

Return type:

None

exists()[source]

Whether the index or collection exists.

Return type:

bool

infrastructure_ready()[source]

Whether the infrastructure that Smarter runs is ready, and why not.

A managed service always is.

Return type:

tuple[bool, str]

property kubernetes: QdrantKubernetes
logs(tail=200)[source]

The database server’s logs, if Smarter runs it.

Return type:

str | None

provision()[source]

Create the database’s infrastructure, if Smarter runs it.

It returns without waiting for it.

Return type:

None

restore_snapshot(name)[source]

Replace the index or collection’s data with a snapshot’s.

Return type:

None

search(query, k=4, search_type='similarity', score_threshold=None, fetch_k=None, lambda_mult=None, metadata_filter=None)[source]

Find the chunks that are closest in meaning to a query.

Parameters:
  • search_type (str) – similarity, similarity_score_threshold, or mmr (maximal marginal relevance).

  • metadata_filter (dict[str, Any] | None) – chunks whose metadata has these values, e.g. {“source”: “faq”}.

Return type:

list[SearchResult]

stats()[source]

The database’s statistics.

It includes vector_count.

Return type:

dict[str, Any]

stop()[source]

Stop the infrastructure that Smarter runs, keeping its data.

Return type:

None

upsert(ids, texts, metadatas, batch_size=64)[source]

Embed and insert, or replace, chunks.

Return type:

None

vector_store()[source]
Return type:

QdrantVectorStore

smarter.apps.vectorstore.backends.qdrant.qdrant_filter(metadata_filter)[source]

A Qdrant filter that matches chunks whose metadata has every value of metadata_filter.

Return type:

Filter | None