From ccafee36c42d4ca6df9d3b599fce234b945842b8 Mon Sep 17 00:00:00 2001 From: Derek Higgins Date: Fri, 18 Jul 2025 16:51:14 +0100 Subject: [PATCH] feat(vector-io): implement chunk deletion for Milvus provider Add delete_chunk() method using Milvus delete with chunk_id filter Implement _delete_openai_chunk_from_vector_store() for OpenAI compatibility --- .../providers/remote/vector_io/milvus/milvus.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/llama_stack/providers/remote/vector_io/milvus/milvus.py b/llama_stack/providers/remote/vector_io/milvus/milvus.py index d41c7eb8d..71a3571f0 100644 --- a/llama_stack/providers/remote/vector_io/milvus/milvus.py +++ b/llama_stack/providers/remote/vector_io/milvus/milvus.py @@ -247,6 +247,16 @@ class MilvusIndex(EmbeddingIndex): ) -> QueryChunksResponse: raise NotImplementedError("Hybrid search is not supported in Milvus") + async def delete_chunk(self, chunk_id: str) -> None: + """Remove a chunk from the Milvus collection.""" + try: + await asyncio.to_thread( + self.client.delete, collection_name=self.collection_name, filter=f'chunk_id == "{chunk_id}"' + ) + except Exception as e: + logger.error(f"Error deleting chunk {chunk_id} from Milvus collection {self.collection_name}: {e}") + raise + class MilvusVectorIOAdapter(OpenAIVectorStoreMixin, VectorIO, VectorDBsProtocolPrivate): def __init__( @@ -372,4 +382,9 @@ class MilvusVectorIOAdapter(OpenAIVectorStoreMixin, VectorIO, VectorDBsProtocolP async def _delete_openai_chunk_from_vector_store(self, store_id: str, chunk_id: str) -> None: """Delete a chunk from a milvus vector store.""" - pass # TODO + index = await self._get_and_cache_vector_db_index(store_id) + if not index: + raise ValueError(f"Vector DB {store_id} not found") + + # Use the index's delete_chunk method + await index.index.delete_chunk(chunk_id)