mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-04 12:07:34 +00:00
fix(test): chrome db test fails due to reusing deleted collection
Signed-off-by: Mustafa Elbehery <melbeher@redhat.com>
This commit is contained in:
parent
142bd248e7
commit
5a6c20313d
1 changed files with 9 additions and 2 deletions
|
@ -56,10 +56,11 @@ class ChromaIndex(EmbeddingIndex):
|
||||||
def __init__(self, client: ChromaClientType, collection, kvstore: KVStore | None = None):
|
def __init__(self, client: ChromaClientType, collection, kvstore: KVStore | None = None):
|
||||||
self.client = client
|
self.client = client
|
||||||
self.collection = collection
|
self.collection = collection
|
||||||
|
self.collection_name = collection.name
|
||||||
self.kvstore = kvstore
|
self.kvstore = kvstore
|
||||||
|
|
||||||
async def initialize(self):
|
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):
|
async def add_chunks(self, chunks: list[Chunk], embeddings: NDArray):
|
||||||
assert len(chunks) == len(embeddings), (
|
assert len(chunks) == len(embeddings), (
|
||||||
|
@ -106,7 +107,13 @@ class ChromaIndex(EmbeddingIndex):
|
||||||
return QueryChunksResponse(chunks=chunks, scores=scores)
|
return QueryChunksResponse(chunks=chunks, scores=scores)
|
||||||
|
|
||||||
async def delete(self):
|
async def delete(self):
|
||||||
|
try:
|
||||||
await maybe_await(self.client.delete_collection(self.collection.name))
|
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(
|
async def query_keyword(
|
||||||
self,
|
self,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue