Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
Move Chroma lockfile to `db/` (#3342)
Vini Brasil2fdf3f3a6a84
diff --git a/src/crewai/utilities/chromadb.py b/src/crewai/utilities/chromadb.pyindex 7d2051ebf..60da9988d 100644--- a/src/crewai/utilities/chromadb.py+++ b/src/crewai/utilities/chromadb.py@@ -1,9 +1,10 @@+import osimport reimport portalockerfrom chromadb import PersistentClientfrom hashlib import md5from typing import Optional-+from crewai.utilities.paths import db_storage_pathMIN_COLLECTION_LENGTH = 3MAX_COLLECTION_LENGTH = 63@@ -27,7 +28,9 @@ def is_ipv4_pattern(name: str) -> bool:return bool(IPV4_PATTERN.match(name))-def sanitize_collection_name(name: Optional[str], max_collection_length: int = MAX_COLLECTION_LENGTH) -> str:+def sanitize_collection_name(+ name: Optional[str], max_collection_length: int = MAX_COLLECTION_LENGTH+) -> str:"""Sanitize a collection name to meet ChromaDB requirements:1. 3-63 characters long@@ -72,7 +75,8 @@ def create_persistent_client(path: str, **kwargs):concurrent creations. Works for both multi-threads and multi-processesenvironments."""- lockfile = f"chromadb-{md5(path.encode(), usedforsecurity=False).hexdigest()}.lock"+ lock_id = md5(path.encode(), usedforsecurity=False).hexdigest()+ lockfile = os.path.join(db_storage_path(), f"chromadb-{lock_id}.lock")with portalocker.Lock(lockfile):client = PersistentClient(path=path, **kwargs)