tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Agentic AI > CrewAI > CrewAI Knowledge Sources and RAG Integration

CrewAI Knowledge Sources and RAG Integration

Author: Venkata Sudhakar

CrewAI's Knowledge feature lets you attach document sources directly to agents or crews so they can retrieve relevant information using RAG (Retrieval-Augmented Generation) before completing each task. Instead of cramming all reference material into the system prompt, the agent queries a vector store and injects only the most relevant chunks. For ShopMax India, this means agents can answer questions grounded in the product catalog, return policy, or warranty documentation without hallucinating details.

Knowledge sources are created using built-in classes like StringKnowledgeSource, TextFileKnowledgeSource, or PDFKnowledgeSource. Pass a list of sources to the knowledge_sources parameter of either an Agent (agent-level) or a Crew (shared across all agents). CrewAI automatically embeds the content using its default embedder and retrieves relevant passages at query time.

The following example creates a ShopMax India support agent with knowledge of the return policy document, so it answers customer questions accurately without needing to be retrained.


It gives the following output,

The customer in Hyderabad is eligible for a replacement under ShopMax India policy,
as damaged items qualify for a replacement dispatch within 48 hours after photo
verification. Return pickup is also available in Hyderabad.

For larger document collections, use TextFileKnowledgeSource or PDFKnowledgeSource to load files from disk. CrewAI uses ChromaDB as the default vector store and sentence-transformers for embeddings - both are installed automatically with pip install crewai[knowledge]. For ShopMax India's full product catalog with thousands of SKUs, chunking strategy and embedding model choice significantly affect retrieval quality.


 
  


  
bl  br