fix syntax and types
This commit is contained in:
@@ -58,7 +58,9 @@ def count_collection(collection_name: str) -> str:
|
||||
_, collection = _get_client_and_collection(collection_name)
|
||||
count = collection.count()
|
||||
|
||||
return f"The '{collection_name}' collection contains [bold green]{count}[/] records."
|
||||
return (
|
||||
f"The '{collection_name}' collection contains [bold green]{count}[/] records."
|
||||
)
|
||||
|
||||
|
||||
def add_data(
|
||||
@@ -71,8 +73,7 @@ def add_data(
|
||||
|
||||
_, collection = _get_client_and_collection(collection_name)
|
||||
|
||||
embeddings: list[Sequence[float]] = [record["embedding"]
|
||||
for record in data]
|
||||
embeddings: list[Sequence[float]] = [record["embedding"] for record in data]
|
||||
|
||||
collection.add(
|
||||
ids=[str(uuid4()) for _ in data],
|
||||
|
||||
+3
-4
@@ -3,16 +3,16 @@ from __future__ import annotations
|
||||
from typing import Annotated, Callable
|
||||
|
||||
import typer
|
||||
from rich import print
|
||||
from chromadb.errors import InternalError, NotFoundError
|
||||
from rich import print
|
||||
|
||||
from chromy.handlers.import_data import handle_import
|
||||
from chromy.handlers.count_collection import handle_count_collection
|
||||
from chromy.handlers.create_collection import handle_create_collection
|
||||
from chromy.handlers.delete_collection import (
|
||||
handle_delete_collection,
|
||||
handle_delete_records,
|
||||
)
|
||||
from chromy.handlers.import_data import handle_import
|
||||
from chromy.handlers.list_collections import handle_list_collections
|
||||
from chromy.handlers.query import handle_query
|
||||
|
||||
@@ -114,8 +114,7 @@ def import_data(
|
||||
],
|
||||
file: Annotated[
|
||||
str,
|
||||
typer.Argument(
|
||||
help="Path to the file to chunk and add to the collection."),
|
||||
typer.Argument(help="Path to the file to chunk and add to the collection."),
|
||||
],
|
||||
) -> None:
|
||||
try:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from rich import print
|
||||
|
||||
from chromy.chroma_functions import count_collection
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from rich import print
|
||||
|
||||
from chromy.chroma_functions import create_collection
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from rich import print
|
||||
|
||||
from chromy.chroma_functions import delete_collection, delete_data
|
||||
|
||||
|
||||
@@ -8,15 +9,13 @@ def _parse_where_clause(where_clause: str) -> dict[str, str]:
|
||||
condition, separator, value = where_clause.partition("=")
|
||||
|
||||
if separator == "":
|
||||
raise ValueError(
|
||||
"Invalid --where value. Expected <condition>=<value>.")
|
||||
raise ValueError("Invalid --where value. Expected <condition>=<value>.")
|
||||
|
||||
condition = condition.strip()
|
||||
value = value.strip()
|
||||
|
||||
if not condition or not value:
|
||||
raise ValueError(
|
||||
"Invalid --where value. Expected <condition>=<value>.")
|
||||
raise ValueError("Invalid --where value. Expected <condition>=<value>.")
|
||||
|
||||
return {condition: value}
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ from chromy.embed import embed
|
||||
CONSOLE = Console()
|
||||
|
||||
|
||||
def print_lines(lines: Sequence[str]) -> None:
|
||||
def print_lines(lines: Sequence[Rule | Text]) -> None:
|
||||
for line in lines:
|
||||
CONSOLE.print(line)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user