add list, create, delete commands

This commit is contained in:
2026-04-21 14:32:10 +02:00
parent bac81cbd33
commit 2b07bf471d
3 changed files with 109 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
import chromadb
from typing import List
def list_collections() -> List[str]:
client = chromadb.PersistentClient()
collections = client.list_collections()
if not collections:
return []
return [getattr(collection, "name", str(collection)) for collection in collections]
def create_collection(name: str) -> str:
client = chromadb.PersistentClient()
collection = client.create_collection(name=name)
return getattr(collection, "name", name)
def delete_collection(name: str) -> None:
client = chromadb.PersistentClient()
client.delete_collection(name=name)
def count_collection(name: str) -> int:
# TODO Implement this method.
# The function must use the count method and return how many records are
# in the collection. It must handle non-existent collections.
raise NotImplemented()