fix types and print middle dot in collections list
This commit is contained in:
@@ -8,6 +8,7 @@ import chromadb
|
||||
from chromadb.api import ClientAPI
|
||||
from chromadb.api.types import QueryResult, Where
|
||||
from chromadb.errors import NotFoundError
|
||||
from rich.text import Text
|
||||
|
||||
from chromy.embed import EmbeddingRecord
|
||||
|
||||
@@ -25,14 +26,17 @@ def _get_client_and_collection(
|
||||
return client, collection
|
||||
|
||||
|
||||
def list_collections() -> list[str]:
|
||||
def list_collections() -> list[Text]:
|
||||
client = chromadb.PersistentClient()
|
||||
collections = client.list_collections()
|
||||
|
||||
if not collections:
|
||||
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:
|
||||
|
||||
@@ -6,9 +6,11 @@ from chromy.utilities import print_lines
|
||||
|
||||
def handle_list_collections() -> int:
|
||||
collections = list_collections()
|
||||
|
||||
if not collections:
|
||||
print("No collections found.")
|
||||
return 0
|
||||
|
||||
print_lines(collections)
|
||||
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user