This commit is contained in:
Timothy J. Baek 2024-10-03 20:58:56 -07:00
parent 57360b7a61
commit 124a17e826

View File

@ -49,6 +49,7 @@ class ChromaClient:
self, collection_name: str, vectors: list[list[float | int]], limit: int
) -> Optional[SearchResult]:
# Search for the nearest neighbor items based on the vectors and return 'limit' number of results.
try:
collection = self.client.get_collection(name=collection_name)
if collection:
result = collection.query(
@ -65,11 +66,15 @@ class ChromaClient:
}
)
return None
except Exception as e:
return None
def query(
self, collection_name: str, filter: dict, limit: int = 1
) -> Optional[GetResult]:
# Query the items from the collection based on the filter.
try:
collection = self.client.get_collection(name=collection_name)
if collection:
result = collection.get(
@ -85,6 +90,8 @@ class ChromaClient:
}
)
return None
except Exception as e:
return None
def get(self, collection_name: str) -> Optional[GetResult]:
# Get all the items in the collection.