ChromaX: An experimental utilities package for Chroma AI application database
Installation
pip install chromadbx
Features
- Query Builder - build queries using a builder pattern
- ID generation - generate IDs for documents
- Embeddings - generate embeddings for your documents:
- OnnxRuntime embeddings
- Llama.cpp embeddings
- Google Vertex AI embeddings
- Mistral AI embeddings
- Cloudflare Workers AI embeddings
- SpaCy embeddings
- Together embeddings.
- Nomic embeddings.
- Reranking - rerank documents and query results using Cohere, OpenAI, or custom reranking functions.
- Cohere - rerank documents and query results using Cohere.
Usage
Queries
Supported filters:
$eq- equal to (string, int, float)$ne- not equal to (string, int, float)$gt- greater than (int, float)$gte- greater than or equal to (int, float)$lt- less than (int, float)$lte- less than or equal to (int, float)$in- in (list of strings, ints, floats,bools)$nin- not in (list of strings, ints, floats,bools)
Where:
import chromadb
from chromadbx.core.queries import eq, where, ne, and_
client = chromadb.PersistentClient(path="path/to/db")
collection = client.get_collection("collection_name")
collection.query(where=where(and_(eq("a", 1), ne("b", "2"))))
# {'$and': [{'a': ['$eq', 1]}, {'b': ['$ne', '2']}]}
Where Document:
import chromadb
from chromadbx.core.queries import where_document, contains, not_contains, LogicalOperator
client = chromadb.PersistentClient(path="path/to/db")
collection = client.get_collection("collection_name")
collection.query(where_document=where_document(contains("this is a document", "this is another document")))
# {'$and': [{'$contains': 'this is a document'}, {'$contains': 'this is another document'}]}
collection.query(
where_document=where_document(contains("this is a document", "this is another document", op=LogicalOperator.OR)))
# {'$or': [{'$contains': 'this is a document'}, {'$contains': 'this is another document'}]}
ID Generation
import chromadb
from chromadbx import IDGenerator
from functools import partial
from typing import Generator
def sequential_generator(start: int = 0) -> Generator[str, None, None]:
_next = start
while True:
yield f"{_next}"
_next += 1
client = chromadb.Client()
col = client.get_or_create_collection("test")
my_docs = [f"Document {_}" for _ in range(10)]
idgen = IDGenerator(len(my_docs), generator=partial(sequential_generator, start=10))
col.add(ids=idgen, documents=my_docs)
UUIDs (default)
import chromadb
from chromadbx import UUIDGenerator
client = chromadb.Client()
col = client.get_or_create_collection("test")
my_docs = [f"Document {_}" for _ in range(10)]
col.add(ids=UUIDGenerator(len(my_docs)), documents=my_docs)
ULIDs
import chromadb
from chromadbx import ULIDGenerator
client = chromadb.Client()
col = client.get_or_create_collection("test")
my_docs = [f"Document {_}" for _ in range(10)]
col.add(ids=ULIDGenerator(len(my_docs)), documents=my_docs)
Hashes
Random SHA256:
import chromadb
from chromadbx import RandomSHA256Generator
client = chromadb.Client()
col = client.get_or_create_collection("test")
my_docs = [f"Document {_}" for _ in range(10)]
col.add(ids=RandomSHA256Generator(len(my_docs)), documents=my_docs)
Document-based SHA256:
import chromadb
from chromadbx import DocumentSHA256Generator
client = chromadb.Client()
col = client.get_or_create_collection("test")
my_docs = [f"Document {_}" for _ in range(10)]
col.add(ids=DocumentSHA256Generator(documents=my_docs), documents=my_docs)
NanoID
import chromadb
from chromadbx import NanoIDGenerator
client = chromadb.Client()
col = client.get_or_create_collection("test")
my_docs = [f"Document {_}" for _ in range(10)]
col.add(ids=NanoIDGenerator(len(my_docs)), documents=my_docs)
Metadata
Release files for chromadbx 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| chromadbx-0.1.0.tar.gz | 14.8 kB | Without provenance | Details for chromadbx-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| chromadbx-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for chromadbx-0.1.0-py3-none-any.whl |
Total release size: 35.7 kB
Release files / chromadbx-0.1.0.tar.gz
| Download URL | chromadbx-0.1.0.tar.gz |
|---|---|
| Size | 14.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a0b876dab50f4505cad193853086e83355e55c5b4963f8650695060f25ae4c2a
|
|
BLAKE2b-256 checksum How to use checksums |
b826886e01de604abd93da42b5c6de37e840ea62a3241fe802b44d8c9a472627
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.9.21 Linux/6.8.0-1017-azure
|
Release files / chromadbx-0.1.0-py3-none-any.whl
| Download URL | chromadbx-0.1.0-py3-none-any.whl |
|---|---|
| Size | 20.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5ad7ad6501887e47581354552b75dd78d2d5af083e4244cef6337eafbcabb15b
|
|
BLAKE2b-256 checksum How to use checksums |
6525819c22b757306a5deb4325977ab402694816f50f8d963407dcc03ab04bf1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.9.21 Linux/6.8.0-1017-azure
|
Security for chromadbx 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.