feat: Add a tool to search a Chroma database
Hello from the Chroma team 👋
This adds a basic tool that lets agents query their data in Chroma.
We also unpinned the chromadb version. Ideally, we'd like to get you on >1.0.0 because CrewAI uses ChromaDB for short-term memory. Since we rewrote it in rust, upgrading to 1.0.0 should make Chroma 4x faster, instantly.
import chromadb
from crewai_tools import ChromaSearchTool
client = chromadb.PersistentClient(path="./chroma_db")
collection = client.get_or_create_collection(name="my_documents")
tool = ChromaSearchTool(
collection=collection,
)
@kylediaz I think bumping to > 1.0.0 is currently blocked by the embedchain dependency
Hey @kylediaz , could you record a Loom showing this tool in action with a Crew?
uv init
uv add chromadb crewai
cd [crewai-tools repo]
uv pip install -e .
import os
import crewai
from crewai_tools import ChromaSearchTool
import chromadb
client = chromadb.CloudClient(
api_key=os.getenv('CHROMA_API_KEY'),
tenant=os.getenv('CHROMA_TENANT'),
database='test-db'
)
collection = client.get_collection(name="demo-data-upload")
search_tool = ChromaSearchTool(collection=collection)
rag_agent = crewai.Agent(
role="RAG Agent",
goal="You are a helpful assistant that can answer questions about the documents in the collection.",
backstory="You are a helpful assistant that can answer questions about the documents in the collection.",
verbose=True,
model='openai/gpt-4o',
api_key=os.getenv('OPENAI_API_KEY'),
tools=[search_tool],
)
task = crewai.Task(
description="Answer the question: Tell me about the user's preferences?",
expected_output="The user's preferences",
agent=rag_agent,
)
crew = crewai.Crew(
agents=[rag_agent],
tasks=[task],
verbose=True,
)
crew.kickoff()
https://github.com/user-attachments/assets/d00a6ee5-7ce4-4aed-85da-a7eb3e867571
bump on this
@lucasgomide hi! bump on this :)
@lucasgomide @greysonlalonde bump!