mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-10 04:08:31 +00:00
rebase issues
Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
This commit is contained in:
parent
427f69f4f0
commit
dfffeb6dcf
5 changed files with 16 additions and 15 deletions
|
@ -3,7 +3,7 @@ orphan: true
|
||||||
---
|
---
|
||||||
# Qdrant
|
# 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.
|
allows you to store and query vectors directly in memory.
|
||||||
That means you'll get fast and efficient vector retrieval.
|
That means you'll get fast and efficient vector retrieval.
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ from llama_stack.providers.datatypes import Api, ProviderSpec
|
||||||
from .config import QdrantVectorIOConfig
|
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
|
from llama_stack.providers.remote.vector_io.qdrant.qdrant import QdrantVectorIOAdapter
|
||||||
|
|
||||||
impl = QdrantVectorIOAdapter(config, deps[Api.inference])
|
impl = QdrantVectorIOAdapter(config, deps[Api.inference])
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
# the root directory of this source tree.
|
# the root directory of this source tree.
|
||||||
|
|
||||||
|
|
||||||
|
from typing import Any, Dict
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from llama_stack.schema_utils import json_schema_type
|
from llama_stack.schema_utils import json_schema_type
|
||||||
|
@ -15,7 +17,7 @@ class QdrantVectorIOConfig(BaseModel):
|
||||||
path: str
|
path: str
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def sample_run_config(cls, __distro_dir__: str) -> dict[str, any]:
|
def sample_run_config(cls, __distro_dir__: str) -> Dict[str, Any]:
|
||||||
return {
|
return {
|
||||||
"path": "${env.QDRANT_PATH:~/.llama/" + __distro_dir__ + "}/" + "qdrant.db",
|
"path": "${env.QDRANT_PATH:~/.llama/" + __distro_dir__ + "}/" + "qdrant.db",
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,16 +92,6 @@ def available_providers() -> List[ProviderSpec]:
|
||||||
),
|
),
|
||||||
api_dependencies=[Api.inference],
|
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(
|
InlineProviderSpec(
|
||||||
api=Api.vector_io,
|
api=Api.vector_io,
|
||||||
provider_type="inline::qdrant",
|
provider_type="inline::qdrant",
|
||||||
|
|
|
@ -103,13 +103,17 @@ class QdrantVectorIOAdapter(VectorIO, VectorDBsProtocolPrivate):
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config: Union[RemoteQdrantVectorIOConfig, InlineQdrantVectorIOConfig], inference_api: Api.inference
|
self, config: Union[RemoteQdrantVectorIOConfig, InlineQdrantVectorIOConfig], inference_api: Api.inference
|
||||||
) -> None:
|
) -> 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.config = config
|
||||||
self.client = AsyncQdrantClient(**self.config.model_dump(exclude_none=True))
|
self.client: AsyncQdrantClient = None
|
||||||
self.cache = {}
|
self.cache = {}
|
||||||
self.inference_api = inference_api
|
self.inference_api = inference_api
|
||||||
|
|
||||||
async def initialize(self) -> None:
|
async def initialize(self) -> None:
|
||||||
pass
|
self.client = AsyncQdrantClient(**self.config.model_dump(exclude_none=True))
|
||||||
|
|
||||||
async def shutdown(self) -> None:
|
async def shutdown(self) -> None:
|
||||||
self.client.close()
|
self.client.close()
|
||||||
|
@ -126,6 +130,11 @@ class QdrantVectorIOAdapter(VectorIO, VectorDBsProtocolPrivate):
|
||||||
|
|
||||||
self.cache[vector_db.identifier] = index
|
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]:
|
async def _get_and_cache_vector_db_index(self, vector_db_id: str) -> Optional[VectorDBWithIndex]:
|
||||||
if vector_db_id in self.cache:
|
if vector_db_id in self.cache:
|
||||||
return self.cache[vector_db_id]
|
return self.cache[vector_db_id]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue