Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 Multi-Agent System with CrewAI

A hands-on demo project exploring multi-agent architectures using the CrewAI framework. This project showcases how autonomous AI agents can collaborate, delegate tasks, and leverage specialized tools like SQL databases, vector stores (RAG), and web search.

Python CrewAI Azure OpenAI Streamlit


🏗️ Architecture Overview

The project implements multiple agent crews with different architectures:

Allrounder Crew (Hierarchical)

A Manager Agent coordinates specialized agents and delegates tasks based on user requests:

Allrounder Architecture

Tool Implementation

Newsletter Crew (Sequential)

A two-agent pipeline for automated newsletter generation:

Newsletter Architecture


✨ Features

Feature Description
🎭 Hierarchical Multi-Agent System Manager agent that delegates to specialized workers
🔍 RAG Pipeline FAISS vector store with Azure OpenAI embeddings for document retrieval
💾 SQL Agent Natural language queries on a SQLite database (Northwind)
🌐 Web Research Agent Real-time web search via Exa.ai
💬 Streamlit Chat UI Interactive chat interface with verbose output mode
📊 Observability OpenLit integration for tracing and monitoring

📁 Project Structure

src/crewai_demo/
├── config/              # Agent & Task definitions (YAML)
│   ├── agents.yaml      # Allrounder agent configurations
│   ├── tasks.yaml       # Allrounder task definitions
│   ├── newsletter_*.yaml
│   ├── database_*.yaml
│   ├── rag_*.yaml
│   └── web_*.yaml
├── tools/               # Custom CrewAI tools
│   ├── db.py            # SQL database tool
│   ├── rag.py           # Vector store search tool
│   └── research.py      # Exa.ai web search tools
├── rag_vectorstore/     # FAISS vector store management
├── sql_database/        # SQLite Northwind integration
├── services/            # Azure OpenAI service wrappers
├── crew.py              # Crew orchestration & agent definitions
└── main.py              # Entry points for different crews

src/gui/
└── app.py               # Streamlit Chat UI

🚀 Quick Start

Prerequisites

  • Python 3.10 - 3.12
  • Poetry for dependency management
  • API Keys: Azure OpenAI (or OpenAI), Exa.ai

Installation

# Install Poetry (if not already installed)
pip install poetry

# Install dependencies
poetry lock
poetry install

Configuration

Create a .env file based on .env_example with your API keys:

# Azure OpenAI
AZURE_OPENAI_API_KEY=your-key
AZURE_OPENAI_ENDPOINT=https://your-endpoint.openai.azure.com/
DEPLOYMENT_NAME=your-deployment
OPENAI_API_VERSION=2024-02-15-preview

# Exa.ai (for web search)
EXA_API_KEY=your-exa-key

Run

# Individual crews
poetry run crewai_newsletter    # Newsletter generation
poetry run crewai_database      # SQL database queries
poetry run crewai_rag           # RAG document retrieval
poetry run crewai_web           # Web research

# Allrounder with all agents
poetry run crewai_allrounder

# Chat UI (Streamlit)
streamlit run src/gui/app.py

Note: Disable/comment out openlit in crew.py & app.py if you don't have OpenLit running.
Or start OpenLit with Docker: OpenLit Setup Guide


🎯 Available Crews

Newsletter Crew

Generates a newsletter based on a given topic:

  1. Researcher Agent – Searches the web for recent articles (last 7 days) using Exa.ai
  2. Review Analyst Agent – Reviews and summarizes findings into a markdown report

Database Crew

Single agent with SQL capabilities:

  • Queries the Northwind database (customers, orders, products, etc.)
  • Translates natural language to SQL

RAG Crew

Single agent for document retrieval:

  • Uses FAISS vector store with pre-indexed documents
  • Retrieves relevant chunks based on semantic similarity

Web Crew

Single agent for real-time web research:

  • Searches the web via Exa.ai
  • Returns summarized results with source links

Allrounder Crew

Combines all specialized agents under a Manager Agent:

  • Manager handles chitchat and simple questions directly
  • Delegates specialized tasks (database, RAG, web) to appropriate agents
  • Uses hierarchical process for coordination

🛠️ Customization

  • Agents: Modify src/crewai_demo/config/*_agents.yaml
  • Tasks: Modify src/crewai_demo/config/*_tasks.yaml
  • Tools: Add custom tools in src/crewai_demo/tools/
  • Crew Logic: Adjust orchestration in src/crewai_demo/crew.py

📚 What This Project Demonstrates

  • Multi-agent orchestration with task delegation
  • Integration of LLMs (Azure OpenAI) with CrewAI
  • Building custom tools for agents
  • RAG implementation with FAISS and embeddings
  • SQL database integration for natural language queries
  • Building a chat interface with Streamlit

📖 Resources


📝 License

This is a personal demo project for learning and experimentation purposes.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages