mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-01 16:24:44 +00:00
fall to back to read from chroma when not in cache
This commit is contained in:
parent
89f5093dfc
commit
49a440acfb
1 changed files with 9 additions and 1 deletions
|
@ -161,6 +161,14 @@ class ChromaMemoryAdapter(Memory, MemoryBanksProtocolPrivate):
|
|||
) -> QueryDocumentsResponse:
|
||||
index = self.cache.get(bank_id, None)
|
||||
if not index:
|
||||
raise ValueError(f"Bank {bank_id} not found")
|
||||
# if not in cache, try to get from chroma directly
|
||||
bank = await self.memory_bank_store.get_memory_bank(bank_id)
|
||||
if not bank:
|
||||
raise ValueError(f"Bank {bank_id} not found in Llama Stack")
|
||||
collection = await self.client.get_collection(bank_id)
|
||||
if not collection:
|
||||
raise ValueError(f"Bank {bank_id} not found in Chroma")
|
||||
index = BankWithIndex(bank=bank, index=ChromaIndex(self.client, collection))
|
||||
self.cache[bank_id] = index
|
||||
|
||||
return await index.query_documents(query, params)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue