| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- """Milvus 向量数据库后端 —— 基于 pymilvus
- 状态:未实现。init() 会抛出 NotImplementedError。
- """
- import logging
- from typing import Any, Optional
- from supply.infra.database.ports import VectorBackend
- logger = logging.getLogger(__name__)
- class MilvusBackend(VectorBackend):
- """Milvus 向量数据库异步后端"""
- def __init__(self, name: str, config: Any):
- super().__init__(name, config)
- self._client = None
- # ==================== 生命周期 ====================
- async def init(self) -> None:
- raise NotImplementedError(
- "MilvusBackend 尚未实现。需要安装 pymilvus 并完成连接初始化逻辑。"
- )
- async def close(self) -> None:
- if self._client is not None:
- self._client = None
- self._initialized = False
- async def health(self) -> bool:
- return False
- # ==================== 向量操作 ====================
- async def insert(
- self,
- collection: str,
- vectors: list[list[float]],
- metadata: Optional[list[dict]] = None,
- ) -> list[int]:
- raise NotImplementedError("MilvusBackend 尚未实现")
- async def search(
- self,
- collection: str,
- query_vectors: list[list[float]],
- top_k: int = 10,
- filter_expr: Optional[str] = None,
- ) -> list[list[dict]]:
- raise NotImplementedError("MilvusBackend 尚未实现")
- async def delete(
- self,
- collection: str,
- ids: list[int],
- ) -> int:
- raise NotImplementedError("MilvusBackend 尚未实现")
|