Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Create a CHROMA_HOME variable to alter Download Path for Emebeddings. #2089

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion chromadb/api/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def _get(
documents=body.get("documents", None),
data=None,
uris=body.get("uris", None),
included=body["included"],
included=body.get("included", None),
)

@trace_method("FastAPI._delete", OpenTelemetryGranularity.OPERATION)
Expand Down
6 changes: 5 additions & 1 deletion chromadb/utils/embedding_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@ def __call__(self, input: Documents) -> Embeddings:

return cast(Embeddings, self._model.encode(texts_with_instructions).tolist())

def get_base_path() -> Path:
if "CHROMA_HOME" in os.environ:
return Path(os.environ["CHROMA_HOME"])
return Path.home()

# In order to remove dependencies on sentence-transformers, which in turn depends on
# pytorch and sentence-piece we have created a default ONNX embedding function that
Expand All @@ -379,7 +383,7 @@ def __call__(self, input: Documents) -> Embeddings:
# and verify the ONNX model.
class ONNXMiniLM_L6_V2(EmbeddingFunction[Documents]):
MODEL_NAME = "all-MiniLM-L6-v2"
DOWNLOAD_PATH = Path.home() / ".cache" / "chroma" / "onnx_models" / MODEL_NAME
DOWNLOAD_PATH = get_base_path() / ".cache" / "chroma" / "onnx_models" / MODEL_NAME
EXTRACTED_FOLDER_NAME = "onnx"
ARCHIVE_FILENAME = "onnx.tar.gz"
MODEL_DOWNLOAD_URL = (
Expand Down