mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-07 02:58:21 +00:00
Fix Chroma adapter
This commit is contained in:
parent
ec3ebb5bcf
commit
f20211a7c2
1 changed files with 4 additions and 3 deletions
|
@ -46,11 +46,12 @@ class ChromaIndex(EmbeddingIndex):
|
||||||
embeddings
|
embeddings
|
||||||
), f"Chunk length {len(chunks)} does not match embedding length {len(embeddings)}"
|
), f"Chunk length {len(chunks)} does not match embedding length {len(embeddings)}"
|
||||||
|
|
||||||
|
ids = [f"{c.metadata['document_id']}:chunk-{i}" for i, c in enumerate(chunks)]
|
||||||
await maybe_await(
|
await maybe_await(
|
||||||
self.collection.add(
|
self.collection.add(
|
||||||
documents=[chunk.model_dump_json() for chunk in chunks],
|
documents=[chunk.model_dump_json() for chunk in chunks],
|
||||||
embeddings=embeddings,
|
embeddings=embeddings,
|
||||||
ids=[f"{c.document_id}:chunk-{i}" for i, c in enumerate(chunks)],
|
ids=ids,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -140,11 +141,11 @@ class ChromaVectorIOAdapter(VectorIO, VectorDBsProtocolPrivate):
|
||||||
self,
|
self,
|
||||||
vector_db_id: str,
|
vector_db_id: str,
|
||||||
chunks: List[Chunk],
|
chunks: List[Chunk],
|
||||||
embeddings: NDArray,
|
ttl_seconds: Optional[int] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
index = await self._get_and_cache_vector_db_index(vector_db_id)
|
index = await self._get_and_cache_vector_db_index(vector_db_id)
|
||||||
|
|
||||||
await index.insert_chunks(chunks, embeddings)
|
await index.insert_chunks(chunks)
|
||||||
|
|
||||||
async def query_chunks(
|
async def query_chunks(
|
||||||
self,
|
self,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue