fix types and print middle dot in collections list

This commit is contained in:
2026-04-24 18:28:03 +02:00
parent c5b6b196b5
commit c6ad060e85
2 changed files with 8 additions and 2 deletions
+6 -2
View File
@@ -8,6 +8,7 @@ import chromadb
from chromadb.api import ClientAPI from chromadb.api import ClientAPI
from chromadb.api.types import QueryResult, Where from chromadb.api.types import QueryResult, Where
from chromadb.errors import NotFoundError from chromadb.errors import NotFoundError
from rich.text import Text
from chromy.embed import EmbeddingRecord from chromy.embed import EmbeddingRecord
@@ -25,14 +26,17 @@ def _get_client_and_collection(
return client, collection return client, collection
def list_collections() -> list[str]: def list_collections() -> list[Text]:
client = chromadb.PersistentClient() client = chromadb.PersistentClient()
collections = client.list_collections() collections = client.list_collections()
if not collections: if not collections:
return [] return []
return [getattr(collection, "name", str(collection)) for collection in collections] return [
Text("· " + getattr(collection, "name", str(collection)))
for collection in collections
]
def create_collection(name: str) -> str: def create_collection(name: str) -> str:
+2
View File
@@ -6,9 +6,11 @@ from chromy.utilities import print_lines
def handle_list_collections() -> int: def handle_list_collections() -> int:
collections = list_collections() collections = list_collections()
if not collections: if not collections:
print("No collections found.") print("No collections found.")
return 0 return 0
print_lines(collections) print_lines(collections)
return 0 return 0