diff --git a/llama_stack/providers/remote/vector_io/chroma/chroma.py b/llama_stack/providers/remote/vector_io/chroma/chroma.py index a9ec644ef..5612ed0fd 100644 --- a/llama_stack/providers/remote/vector_io/chroma/chroma.py +++ b/llama_stack/providers/remote/vector_io/chroma/chroma.py @@ -56,10 +56,11 @@ class ChromaIndex(EmbeddingIndex): def __init__(self, client: ChromaClientType, collection, kvstore: KVStore | None = None): self.client = client self.collection = collection + self.collection_name = collection.name self.kvstore = kvstore async def initialize(self): - pass + self.collection = await maybe_await(self.client.get_or_create_collection(self.collection_name)) async def add_chunks(self, chunks: list[Chunk], embeddings: NDArray): assert len(chunks) == len(embeddings), ( @@ -106,7 +107,13 @@ class ChromaIndex(EmbeddingIndex): return QueryChunksResponse(chunks=chunks, scores=scores) async def delete(self): - await maybe_await(self.client.delete_collection(self.collection.name)) + try: + await maybe_await(self.client.delete_collection(self.collection.name)) + except Exception as e: + if "does not exists" in str(e): + log.warning(f"Collection {self.collection.name} already deleted") + else: + raise async def query_keyword( self,