mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-03 09:53:45 +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
1db4800c9c
commit
6b299f24af
1 changed files with 9 additions and 2 deletions
|
|
@ -48,10 +48,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), (
|
||||||
|
|
@ -92,7 +93,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(self, query_string: str, k: int, score_threshold: float) -> QueryChunksResponse:
|
async def query_keyword(self, query_string: str, k: int, score_threshold: float) -> QueryChunksResponse:
|
||||||
raise NotImplementedError("Keyword search is not supported in Chroma")
|
raise NotImplementedError("Keyword search is not supported in Chroma")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue