Files
Chromy/cli_parser.py
T

60 lines
1.9 KiB
Python
Raw Normal View History

2026-04-21 14:32:10 +02:00
import argparse
def build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description="Inspect local Chroma collections.")
subparsers = parser.add_subparsers(dest="command")
2026-04-21 17:13:43 +02:00
# List existing collections
2026-04-21 14:32:10 +02:00
subparsers.add_parser(
"list-collections",
aliases=["lc"],
help="List all collections stored in the local Chroma database.",
)
2026-04-21 17:13:43 +02:00
# Create a new collection
2026-04-21 14:32:10 +02:00
create_parser = subparsers.add_parser(
"create-collection",
aliases=["cc"],
help="Create a collection in the local Chroma database.",
)
create_parser.add_argument("name", help="Name of the collection to create.")
2026-04-21 17:13:43 +02:00
# Delete a collection
2026-04-21 14:32:10 +02:00
delete_parser = subparsers.add_parser(
"delete-collection",
aliases=["dc"],
help="Delete a collection from the local Chroma database.",
)
delete_parser.add_argument("name", help="Name of the collection to delete.")
2026-04-21 17:13:43 +02:00
# Count documents in a collection
2026-04-21 14:45:01 +02:00
count_parser = subparsers.add_parser(
"count",
aliases=["co"],
help="Count records in a collection from the local Chroma database.",
)
count_parser.add_argument("name", help="Name of the collection to count.")
2026-04-21 14:32:10 +02:00
2026-04-21 17:13:43 +02:00
# Add documents to a collection
2026-04-21 15:28:20 +02:00
add_parser = subparsers.add_parser(
"add-data",
aliases=["ad"],
help="Chunk, embed, and add a file to a collection in the local Chroma database.",
)
add_parser.add_argument("collection", help="Name of the target collection.")
2026-04-21 17:13:43 +02:00
add_parser.add_argument(
"file", help="Path to the file to chunk and add to the collection."
)
# Query doc
query_parser = subparsers.add_parser(
"query",
aliases=["q"],
help="Query a collection with given text/s.",
)
query_parser.add_argument("collection", help="Name of the target collection.")
query_parser.add_argument("texts", help="The text/s to query.")
2026-04-21 15:28:20 +02:00
2026-04-21 14:32:10 +02:00
return parser