diff --git a/docs/source/providers/vector_io/qdrant.md b/docs/source/providers/vector_io/qdrant.md index fb2275391..a4b9a39a2 100644 --- a/docs/source/providers/vector_io/qdrant.md +++ b/docs/source/providers/vector_io/qdrant.md @@ -3,7 +3,7 @@ orphan: true --- # Qdrant -[Qdrant](https://qdrant.tech/documentation/) is a inline and remote vector database provider for Llama Stack. It +[Qdrant](https://qdrant.tech/documentation/) is a inline and remote vector database provider for Llama Stack. It allows you to store and query vectors directly in memory. That means you'll get fast and efficient vector retrieval. diff --git a/llama_stack/providers/inline/vector_io/qdrant/__init__.py b/llama_stack/providers/inline/vector_io/qdrant/__init__.py index 7e80ae16b..8f0b91c61 100644 --- a/llama_stack/providers/inline/vector_io/qdrant/__init__.py +++ b/llama_stack/providers/inline/vector_io/qdrant/__init__.py @@ -11,7 +11,7 @@ from llama_stack.providers.datatypes import Api, ProviderSpec from .config import QdrantVectorIOConfig -async def get_provider_impl(config: QdrantVectorIOConfig, deps: Dict[Api, ProviderSpec]): +async def get_adapter_impl(config: QdrantVectorIOConfig, deps: Dict[Api, ProviderSpec]): from llama_stack.providers.remote.vector_io.qdrant.qdrant import QdrantVectorIOAdapter impl = QdrantVectorIOAdapter(config, deps[Api.inference]) diff --git a/llama_stack/providers/inline/vector_io/qdrant/config.py b/llama_stack/providers/inline/vector_io/qdrant/config.py index ff9d6ce58..282e951b0 100644 --- a/llama_stack/providers/inline/vector_io/qdrant/config.py +++ b/llama_stack/providers/inline/vector_io/qdrant/config.py @@ -5,6 +5,8 @@ # the root directory of this source tree. +from typing import Any, Dict + from pydantic import BaseModel from llama_stack.schema_utils import json_schema_type @@ -15,7 +17,7 @@ class QdrantVectorIOConfig(BaseModel): path: str @classmethod - def sample_run_config(cls, __distro_dir__: str) -> dict[str, any]: + def sample_run_config(cls, __distro_dir__: str) -> Dict[str, Any]: return { "path": "${env.QDRANT_PATH:~/.llama/" + __distro_dir__ + "}/" + "qdrant.db", } diff --git a/llama_stack/providers/registry/vector_io.py b/llama_stack/providers/registry/vector_io.py index 1f68f60fd..93031763d 100644 --- a/llama_stack/providers/registry/vector_io.py +++ b/llama_stack/providers/registry/vector_io.py @@ -92,16 +92,6 @@ def available_providers() -> List[ProviderSpec]: ), api_dependencies=[Api.inference], ), - remote_provider_spec( - api=Api.vector_io, - adapter=AdapterSpec( - adapter_type="sample", - pip_packages=[], - module="llama_stack.providers.remote.vector_io.sample", - config_class="llama_stack.providers.remote.vector_io.sample.SampleVectorIOConfig", - ), - api_dependencies=[], - ), InlineProviderSpec( api=Api.vector_io, provider_type="inline::qdrant", diff --git a/llama_stack/providers/remote/vector_io/qdrant/qdrant.py b/llama_stack/providers/remote/vector_io/qdrant/qdrant.py index f8e6fea1a..c850aef12 100644 --- a/llama_stack/providers/remote/vector_io/qdrant/qdrant.py +++ b/llama_stack/providers/remote/vector_io/qdrant/qdrant.py @@ -103,13 +103,17 @@ class QdrantVectorIOAdapter(VectorIO, VectorDBsProtocolPrivate): def __init__( self, config: Union[RemoteQdrantVectorIOConfig, InlineQdrantVectorIOConfig], inference_api: Api.inference ) -> None: + # TODO: this is required otherwise the precommit hook fails with + # _init__.py:17: error: Cannot instantiate abstract class "QdrantVectorIOAdapter" with abstract attribute "vector_db_store" [abstract] + # Will investigate further and remove it once fixed + self.vector_db_store = None self.config = config - self.client = AsyncQdrantClient(**self.config.model_dump(exclude_none=True)) + self.client: AsyncQdrantClient = None self.cache = {} self.inference_api = inference_api async def initialize(self) -> None: - pass + self.client = AsyncQdrantClient(**self.config.model_dump(exclude_none=True)) async def shutdown(self) -> None: self.client.close() @@ -126,6 +130,11 @@ class QdrantVectorIOAdapter(VectorIO, VectorDBsProtocolPrivate): self.cache[vector_db.identifier] = index + async def unregister_vector_db(self, vector_db_id: str) -> None: + if vector_db_id in self.cache: + await self.cache[vector_db_id].index.delete() + del self.cache[vector_db_id] + async def _get_and_cache_vector_db_index(self, vector_db_id: str) -> Optional[VectorDBWithIndex]: if vector_db_id in self.cache: return self.cache[vector_db_id]