A sophisticated multi-agent system for teaching mathematics with interactive visualizations using Manim. This system uses a hierarchical agent architecture to understand user questions, generate mathematical explanations, and create educational visualizations.
The system consists of three specialized agents working together:
- Role: Main coordinator and user interface
- Responsibilities:
- Analyzes user queries and determines knowledge gaps
- Coordinates between other agents
- Synthesizes final responses
- Generates probing questions for better understanding
- Role: Mathematical reasoning and explanation
- Responsibilities:
- Provides step-by-step mathematical explanations
- Solves problems with detailed solutions
- Tailors content to user's knowledge level
- Identifies key concepts and common mistakes
- Role: Visualization creation and animation
- Responsibilities:
- Translates explanations into Manim code
- Creates educational animations and visualizations
- Handles different visualization types (graphs, geometric constructions, etc.)
- Optimizes visualizations for learning
- Intelligent Query Analysis: Understands user questions and knowledge levels
- Adaptive Explanations: Tailors mathematical content to user expertise
- Rich Visualizations: Creates beautiful, educational animations using Manim
- Multi-format Support: Generates MP4, GIF, and other video formats
- REST API: Easy integration with web applications
- Comprehensive Logging: Detailed logging for debugging and monitoring
- Extensible Design: Easy to add new agents and capabilities
# Clone the repository
git clone <repository-url>
cd multi-agent-math-system
# Run the automated setup script
./scripts/setup.sh# 1. Clone and navigate
git clone <repository-url>
cd multi-agent-math-system
# 2. Copy configuration
cp example-config.yaml config.yaml
# 3. Edit config.yaml with your API keys
nano config.yaml
# 4. Start with Docker Compose
docker-compose up -d./scripts/quick-start.shIf you prefer to run locally without Docker:
-
Clone the repository:
git clone <repository-url> cd multi-agent-math-system
-
Install dependencies:
pip install -r requirements.txt
-
Install Manim (if not already installed):
# For Ubuntu/Debian sudo apt update sudo apt install build-essential python3-dev libcairo2-dev libpango1.0-dev ffmpeg # For macOS brew install cairo pango ffmpeg # Then install manim pip install manim
docker-compose up -ddocker-compose downdocker-compose logs -f- API Documentation: http://localhost:8000/docs
- Health Check: http://localhost:8000/health
- Status: http://localhost:8000/status
Run the main script for interactive mode:
python main.pyStart the FastAPI server:
python -m src.api.fastapi_appThe API will be available at http://localhost:8000 with interactive docs at http://localhost:8000/docs.
POST /query- Process a math query and generate explanation with visualizationPOST /probing-questions- Get probing questions to better understand user needsGET /status- Get system status and capabilitiesGET /video/{filename}- Download generated video filesGET /health- Health check endpoint
import requests
# Process a query
response = requests.post("http://localhost:8000/query", json={
"query": "Explain derivatives",
"user_level": "intermediate"
})
result = response.json()
print(f"Explanation: {result['explanation']}")
print(f"Video: {result['visualization']['video_path']}")import asyncio
from src.core.multi_agent_system import MultiAgentMathSystem
async def main():
# Initialize the system
math_system = MultiAgentMathSystem()
# Process a query
result = await math_system.process_query("What is the derivative of xΒ²?")
print(f"Status: {result['status']}")
print(f"Video: {result['visualization']['video_path']}")
asyncio.run(main())Run the test suite:
# Run all tests
pytest
# Run specific test files
pytest tests/test_agents.py
pytest tests/test_system.py
# Run with coverage
pytest --cov=src- Optimized Build: Multi-stage Dockerfile for smaller image size
- Easy Setup: Runs as root for simple local development
- Health Checks: Automatic health monitoring
- Volume Mounts: Persistent data and easy configuration updates
- Resource Limits: Memory management for stable operation
# Setup and start
./scripts/setup.sh
# Quick start (if configured)
./scripts/quick-start.sh
# View logs
docker-compose logs -f
# Stop system
docker-compose downmulti-agent-math-system/
βββ src/
β βββ agents/ # Agent implementations
β β βββ orchestrator.py
β β βββ math_specialist.py
β β βββ manim_coding.py
β βββ core/ # Core system components
β β βββ multi_agent_system.py
β βββ tools/ # Specialized tools
β β βββ manim_tool.py
β βββ api/ # API implementation
β β βββ fastapi_app.py
β βββ utils/ # Utility functions
β βββ logging_config.py
βββ scripts/ # Setup and utility scripts
β βββ setup.sh # Automated setup script
β βββ quick-start.sh # Quick start script
β βββ deploy.sh # Deployment script
βββ docs/ # Documentation
β βββ GETTING_STARTED.md # Complete setup guide
β βββ DOCKER_SETUP.md # Docker setup guide
β βββ CUSTOMIZATION.md # Customization guide
βββ example-configs/ # Example configurations
β βββ config.openai.yaml
β βββ config.anthropic.yaml
β βββ config.local.yaml
βββ tests/ # Test files
βββ output/ # Generated visualizations
βββ logs/ # Log files
βββ media/ # Media files
βββ main.py # Main entry point
βββ requirements.txt # Dependencies
βββ Dockerfile.optimized # Optimized multi-stage Dockerfile
βββ docker-compose.yml # Docker Compose configuration
βββ config.yaml # Configuration file
βββ example-config.yaml # Example configuration
βββ README.md # This file
Configure logging in src/utils/logging_config.py:
from src.utils.logging_config import setup_logging
# Set up logging
setup_logging(
level="INFO", # DEBUG, INFO, WARNING, ERROR, CRITICAL
log_file="system.log", # Optional log file
log_dir="logs" # Log directory
)Change the output directory for generated visualizations:
math_system = MultiAgentMathSystem(output_dir="my_visualizations")- Function Graphs: Plot mathematical functions and their derivatives
- Geometric Constructions: Interactive geometric proofs and constructions
- Algebraic Manipulations: Step-by-step equation solving
- Statistical Plots: Data visualization and statistical concepts
- 3D Visualizations: Three-dimensional mathematical objects
- Animation Sequences: Complex multi-step mathematical processes
- Interactive Demos: User-controlled mathematical explorations
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Manim for beautiful mathematical animations
- Agno for the agent framework
- FastAPI for the REST API
- 3Blue1Brown for inspiration in mathematical visualization
- Getting Started Guide - Complete setup and usage guide
- Docker Setup Guide - Detailed Docker configuration
- Customization Guide - Advanced customization options
- API Documentation - Interactive API documentation (when running)
For questions, issues, or contributions, please open an issue on GitHub or contact the development team.