fix(vector_stores): return None from ChromaDB.get() for missing IDs (#5561)

Co-authored-by: ly-wang19 <ly-wang19@users.noreply.github.com>
This commit is contained in:
ly-wang19
2026-06-15 16:11:03 +05:30
committed by GitHub
co-authored by ly-wang19
parent b90e3c0b76
commit 3ef034a9e4
2 changed files with 14 additions and 3 deletions
+4 -3
View File
@@ -187,7 +187,7 @@ class ChromaDB(VectorStoreBase):
"""
self.collection.update(ids=vector_id, embeddings=vector, metadatas=payload)
def get(self, vector_id: str) -> OutputData:
def get(self, vector_id: str) -> Optional[OutputData]:
"""
Retrieve a vector by ID.
@@ -195,10 +195,11 @@ class ChromaDB(VectorStoreBase):
vector_id (str): ID of the vector to retrieve.
Returns:
OutputData: Retrieved vector.
Optional[OutputData]: Retrieved vector, or None if the ID is not found.
"""
result = self.collection.get(ids=[vector_id])
return self._parse_output(result)[0]
parsed = self._parse_output(result)
return parsed[0] if parsed else None
def list_cols(self) -> List[chromadb.Collection]:
"""