diff --git a/chromadbx/__init__.py b/chromadbx/__init__.py index fae2426..3b4b1da 100644 --- a/chromadbx/__init__.py +++ b/chromadbx/__init__.py @@ -1,3 +1,11 @@ +try: + import chromadb # noqa: F401 +except ImportError: + raise ValueError( + "The chromadb is not installed. This package (chromadbx) requires that Chroma is installed to work. " + "Please install it with `pip install chromadb`" + ) + from chromadbx.core.ids import ( IDGenerator, NanoIDGenerator, diff --git a/pyproject.toml b/pyproject.toml index 9e418bd..5cd408a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,12 +15,13 @@ packages = [{ include = "chromadbx" }] [tool.poetry.dependencies] python = ">=3.9,<=4.0" pydantic = "^2.7.2" -chromadb = ">=0.4.0,<=0.6.0" +chromadb = { version = ">=0.4.0,<=0.6.0", optional = true } ulid-py = { version = "^1.1.0", optional = true } nanoid = { version = "^2.0.0", optional = true } llama-embedder = { version = "^0.0.7", optional = true } [tool.poetry.group.dev.dependencies] +chromadb = { version = ">=0.4.0,<=0.6.0" } pytest = "^8.2.1" black = "24.3.0" pre-commit = "^3.6.0" @@ -33,7 +34,7 @@ llama-embedder = "^0.0.7" [tool.poetry.extras] ids = ["ulid-py", "nanoid"] -embeddings = ["llama-embedder","onnxruntime"] +embeddings = ["llama-embedder", "onnxruntime"] [build-system] requires = ["poetry-core"]