mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-13 18:18:29 +00:00
* feat: add crewai-tools workspace structure * Squashed 'temp-crewai-tools/' content from commit 9bae5633 git-subtree-dir: temp-crewai-tools git-subtree-split: 9bae56339096cb70f03873e600192bd2cd207ac9 * feat: configure crewai-tools workspace package with dependencies * fix: apply ruff auto-formatting to crewai-tools code * chore: update lockfile * fix: don't allow tool tests yet * fix: comment out extra pytest flags for now * fix: remove conflicting conftest.py from crewai-tools tests * fix: resolve dependency conflicts and test issues - Pin vcrpy to 7.0.0 to fix pytest-recording compatibility - Comment out types-requests to resolve urllib3 conflict - Update requests requirement in crewai-tools to >=2.32.0
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
import hashlib
|
|
from typing import Any
|
|
|
|
|
|
def compute_sha256(content: str) -> str:
|
|
return hashlib.sha256(content.encode("utf-8")).hexdigest()
|
|
|
|
|
|
def sanitize_metadata_for_chromadb(metadata: dict[str, Any]) -> dict[str, Any]:
|
|
"""Sanitize metadata to ensure ChromaDB compatibility.
|
|
|
|
ChromaDB only accepts str, int, float, or bool values in metadata.
|
|
This function converts other types to strings.
|
|
|
|
Args:
|
|
metadata: Dictionary of metadata to sanitize
|
|
|
|
Returns:
|
|
Sanitized metadata dictionary with only ChromaDB-compatible types
|
|
"""
|
|
sanitized = {}
|
|
for key, value in metadata.items():
|
|
if isinstance(value, (str, int, float, bool)) or value is None:
|
|
sanitized[key] = value
|
|
elif isinstance(value, (list, tuple)):
|
|
# Convert lists/tuples to pipe-separated strings
|
|
sanitized[key] = " | ".join(str(v) for v in value)
|
|
else:
|
|
# Convert other types to string
|
|
sanitized[key] = str(value)
|
|
return sanitized
|