A comprehensive template for creating RAG-enabled multi-agent systems using CrewAI and IBM WatsonxAI.
This template provides both basic multi-agent functionality and advanced RAG (Retrieval-Augmented Generation) capabilities. Choose from two implementations:
- Researcher Agent - Conducts web research using search tools
- Writer Agent - Creates written content based on research findings
- RAG-Powered Agents - Access local knowledge bases for document-based research
- Configurable Vector Databases - Support for ChromaDB, FAISS, and Pinecone
- Document Processing - Handle PDF, DOCX, TXT, and Markdown files
- Flexible Templates - Pre-built configurations for legal, technical, and support use cases
pip install -r requirements.txtSet your environment variables:
export API_KEY="your_watsonx_api_key"
export SERPER_API_KEY="your_serper_api_key" # Optional for web searchpython agent.py- Configure your settings in
config/rag_config_template.py - Add documents to
data/documents/ - Run the RAG system:
python rag_agent.py- ChromaDB - Local vector database (default)
- FAISS - High-performance similarity search
- Pinecone - Cloud-based vector database
- PDF - Extract text from PDF documents
- DOCX - Process Word documents
- TXT/MD - Plain text and Markdown files
- Chunking - Intelligent text splitting with overlap
- Sentence Transformers - Local embeddings (default)
- OpenAI - Cloud-based embeddings
- Custom - Easy integration of other models
class RAGConfig:
VECTOR_DB = "chroma" # or "faiss", "pinecone"
EMBEDDING_MODEL = "sentence-transformers"
CHUNK_SIZE = 500
RETRIEVAL_K = 3
# ... more optionsPre-built templates for common use cases:
- Legal Research - Legal document analysis and research
- Technical Documentation - API docs and technical guides
- Customer Support - FAQ and troubleshooting assistance
- Medical Research - Clinical literature review
- Business Analysis - Market research and intelligence
# See examples/legal_research_example.py
python examples/legal_research_example.py# See examples/technical_docs_example.py
python examples/technical_docs_example.py# See examples/customer_support_example.py
python examples/customer_support_example.pyMulti Agent/
├── agent.py # Basic multi-agent system
├── rag_agent.py # RAG-enabled system
├── config/
│ └── rag_config_template.py
├── rag/
│ ├── vector_stores/ # Vector database implementations
│ ├── document_processors/ # Document processing pipeline
│ ├── embeddings/ # Embedding model abstractions
│ ├── tools/ # RAG retrieval tools
│ └── knowledge_base_manager.py
├── templates/
│ ├── agent_templates.py # Pre-built agent configurations
│ └── task_templates.py # Pre-built task templates
├── examples/ # Complete use case examples
├── data/
│ └── documents/ # Your document storage
└── requirements.txt
from templates import AgentTemplates
custom_agent = AgentTemplates.create_custom_rag_agent(
llm=llm,
rag_tool=rag_tool,
role="Your Custom Role",
goal="Your Custom Goal",
backstory="Your Custom Backstory"
)from templates import TaskTemplates
custom_task = TaskTemplates.create_custom_task(
agent=agent,
description="Your task description",
expected_output="Your expected output format",
output_file="output.md"
)from rag.knowledge_base_manager import KnowledgeBaseManager
kb = KnowledgeBaseManager(config)
result = kb.add_documents_from_path("path/to/documents")
search_results = kb.search_knowledge_base("query", k=5)- CrewAI >= 0.28.8
- langchain-ibm >= 0.1.0
- IBM WatsonxAI access
- chromadb >= 0.4.15 (local)
- faiss-cpu >= 1.7.4 (local)
- pinecone-client >= 2.2.4 (cloud)
- PyPDF2 >= 3.0.1 (PDF support)
- python-docx >= 0.8.11 (DOCX support)
- sentence-transformers >= 2.2.2 (embeddings)
Switch between vector databases by changing configuration:
config = {"vector_db": "chroma"} # or "faiss", "pinecone"Implement custom embeddings:
from rag.embeddings import BaseEmbeddings
class CustomEmbeddings(BaseEmbeddings):
def embed_documents(self, texts):
# Your implementation
passProcess multiple document types:
from rag.document_processors import DocumentProcessorFactory
chunks = DocumentProcessorFactory.process_documents(file_paths, config)This template is provided as-is for educational and development purposes.