mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-28 17:48:13 +00:00
refactor: streamline collection handling in RAGStorage (#3097)
Replaced the try-except block for collection retrieval with a single call to get_or_create_collection, simplifying the code and improving readability. Added logging to confirm whether the collection was found or created.
This commit is contained in:
@@ -71,14 +71,10 @@ class RAGStorage(BaseRAGStorage):
|
|||||||
|
|
||||||
self.app = chroma_client
|
self.app = chroma_client
|
||||||
|
|
||||||
try:
|
self.collection = self.app.get_or_create_collection(
|
||||||
self.collection = self.app.get_collection(
|
name=self.type, embedding_function=self.embedder_config
|
||||||
name=self.type, embedding_function=self.embedder_config
|
)
|
||||||
)
|
logging.info(f"Collection found or created: {self.collection}")
|
||||||
except Exception:
|
|
||||||
self.collection = self.app.create_collection(
|
|
||||||
name=self.type, embedding_function=self.embedder_config
|
|
||||||
)
|
|
||||||
|
|
||||||
def _sanitize_role(self, role: str) -> str:
|
def _sanitize_role(self, role: str) -> str:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user