Transform Python into High-Performance C++ with Autonomous AI Agents
A revolutionary code generation platform that uses multiple specialized AI agents to convert Python code into optimized C++, featuring parallel processing, comprehensive validation, and enterprise-grade reliability.
- 7 Specialized AI Agents working in orchestrated workflows
- Analyzer Agent: Code complexity assessment and conversion planning
- Translator Agent: Python-to-C++ conversion with semantic preservation
- Optimizer Agent: Performance optimization and algorithmic improvements
- Verifier Agent: Output validation and correctness verification
- Refiner Agent: Iterative improvement and error correction
- Parallel Processing: Concurrent file processing with ThreadPoolExecutor
- Intelligent Optimization: Compiler flags, memory management, and algorithmic improvements
- Performance Benchmarking: Automated Python vs C++ comparison with speedup metrics
- Input Validation: AST-based security scanning and code sanitization
- Circuit Breakers: Automatic failure recovery and resource protection
- Memory Management: Automatic cleanup and resource monitoring
- Run History Tracking: Complete audit trail of all conversions
- Agent Flow Visualization: Interactive workflow diagrams and step analysis
- Performance Analytics: Success rates, conversion times, and error patterns
# Python 3.9+
python --version
# uv (fast Python package manager)
curl -LsSf https://astral.sh/uv/install.sh | sh
# C++ Compiler (macOS)
brew install llvm# Clone repository
git clone https://github.com/surpradhan/agentic-codegen.git
cd agentic-codegen
# Install dependencies (creates .venv automatically)
uv sync
# Setup API key
echo "GROQ_API_KEY=your_api_key_here" > .envfrom agentic_codegen import CodeGenerator
# Initialize
generator = CodeGenerator()
# Convert Python to C++
python_code = """
def fibonacci(n):
if n <= 1:
return n
return fibonacci(n-1) + fibonacci(n-2)
print(fibonacci(10))
"""
cpp_code, metadata = generator.convert(python_code)
print(f"Success: {metadata['success']}")
print(cpp_code)# Start web UI
python main.py --web
class CodeGenerator:
def convert(self, code: str, target_lang: str = "cpp") -> Tuple[str, Dict]
def convert_file(self, input_path: str, output_path: str = None) -> Dict
def convert_directory(self, input_dir: str, output_dir: str, **kwargs) -> List[Dict]
def benchmark(self, code: str, iterations: int = 5) -> Dict- AnalyzerAgent: Complexity analysis, feature detection, conversion planning
- TranslatorAgent: Semantic translation with type inference and optimization
- OptimizerAgent: Algorithmic improvements and compiler optimization
- VerifierAgent: Functional correctness verification and output validation
- RefinerAgent: Error correction and iterative refinement
- AST Analysis: Abstract Syntax Tree parsing for security validation
- Code Sanitization: Removal of dangerous patterns and imports
- Complexity Assessment: Automatic difficulty classification
- Circuit Breakers: Resource protection and failure isolation
# Process entire directories with parallel workers
results = generator.convert_directory(
input_dir="./python_project",
output_dir="./cpp_output",
max_workers=4, # Parallel processing
recursive=True
)
# Results include success rates and performance metrics
success_rate = sum(1 for r in results if r['success']) / len(results)# Compare Python vs C++ performance
results = generator.benchmark(python_code, iterations=10)
print(f"Python time: {results['python_time_avg']:.4f}s")
print(f"C++ time: {results['cpp_time_avg']:.4f}s")
print(f"Speedup: {results['speedup']:.1f}x")from agentic_codegen.utils.run_history import get_run_history_manager
history = get_run_history_manager()
# Get recent runs
recent_runs = history.get_run_history(limit=10)
# Get performance statistics
stats = history.get_run_statistics(days=7)
print(f"Success rate: {stats['success_rate']:.1%}")
print(f"Average duration: {stats['avg_duration']:.2f}s")# API Keys
GROQ_API_KEY=your_groq_api_key
OPENAI_API_KEY=your_openai_key
ANTHROPIC_API_KEY=your_anthropic_key
# System Configuration
MAX_ITERATIONS=3
COMPILATION_TIMEOUT=30
OPTIMIZATION_LEVEL=1
# Model Preferences
PRIMARY_MODEL=openai/gpt-oss-120b
FALLBACK_MODEL=claude-3-sonnet{
"api_keys": {
"groq": "your_key",
"openai": "your_key"
},
"agents": {
"max_iterations": 3,
"optimization_level": 1
},
"compilation": {
"compiler": "clang++",
"flags": "-std=c++17 -Ofast"
}
}- Real-time Python to C++ conversion
- Syntax highlighting and error display
- Progress tracking and agent status
- Directory-wide conversion with progress bars
- Recursive processing and pattern matching
- Parallel worker configuration
- Automated Python vs C++ performance comparison
- Statistical analysis and speedup calculations
- Detailed timing breakdowns
- Interactive workflow visualization
- Step-by-step agent execution tracking
- Performance bottleneck identification
- Complete conversion history with filtering
- Success rate analytics and trends
- Detailed run inspection and debugging
- Model selection and API configuration
- Optimization level tuning
- Compiler flag customization
# Run comprehensive test suite
pytest tests/ -v --cov=agentic_codegen
# Test specific components
pytest tests/test_agents.py -k "translator"
pytest tests/test_validation.py# Test full conversion pipeline
python test_examples.py
# Test batch processing
python -m pytest tests/test_batch_processing.py# Benchmark different code patterns
python benchmark_examples.py
# Memory usage analysis
python -m memory_profiler main.py- Simple Functions: 98%+ accuracy
- Complex Algorithms: 95%+ accuracy
- Mathematical Code: 97%+ accuracy
- Data Processing: 94%+ accuracy
- Algorithmic Optimization: 2-10x speedup
- Memory Efficiency: 50-80% reduction
- Compilation Optimization: Additional 2-5x speedup
Fibonacci (n=30): Python 0.8s → C++ 0.02s (40x speedup)
Matrix Multiplication: Python 12.3s → C++ 0.8s (15x speedup)
Pi Calculation (1M iterations): Python 2.1s → C++ 0.15s (14x speedup)
├── core/
│ ├── main.py # Main CodeGenerator class
│ └── config.py # Configuration management
├── agents/
│ ├── orchestrator.py # Agent coordination
│ ├── analyzer.py # Code analysis
│ ├── translator.py # Code translation
│ ├── optimizer.py # Performance optimization
│ ├── verifier.py # Output verification
│ └── refiner.py # Iterative refinement
├── utils/
│ ├── validation.py # Security & syntax validation
│ ├── executor.py # Code execution & compilation
│ ├── memory_manager.py # Resource management
│ ├── circuit_breaker.py # Failure recovery
│ ├── run_history.py # Analytics & tracking
│ └── logger.py # Logging system
├── ui/
│ └── web_interface.py # Gradio web interface
└── tests/
├── unit/ # Unit tests
├── integration/ # Integration tests
└── benchmarks/ # Performance tests
Input Code → Validation → Analysis → Translation → Optimization → Verification → Refinement → Output
↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
Security Complexity Type Algorithm Compiler Correctness Error Final
Checks Assessment Inference Optimization Flags Verification Correction Code
# Fork and clone
git clone https://github.com/surpradhan/agentic-codegen.git
cd agentic-codegen
# Install all dependencies including dev (creates .venv automatically)
uv sync --dev
# Run tests
uv run pytest tests/- PEP 8 compliance with Black formatting
- Type hints for all function signatures
- Comprehensive docstrings with examples
- Unit test coverage > 95%
- Integration tests for all major features
from ..utils.base_agent import BaseAgent
class CustomAgent(BaseAgent):
def execute(self, input_data: Dict) -> Dict:
"""Implement custom agent logic."""
# Your implementation here
passThis project is licensed under the MIT License - see the LICENSE file for details.
- Groq for providing fast LLM inference
- Gradio for the excellent web interface framework
- Clang/LLVM for C++ compilation and optimization
- Open-source community for inspiration and tools
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Built with ❤️ for the future of AI-assisted software engineering
- ✅ Multi-agent architecture (7 specialized agents)
- ✅ Python to C++ conversion
- ✅ Web interface (Gradio)
- ✅ Parallel batch processing (directory-wide conversion)
- ✅ Performance benchmarking (Python vs C++ comparison)
- ✅ Language handler framework (Rust, Go handlers built; C++ fully integrated)
- ✅ Collaborative workspaces (team sharing, code reviews, role-based permissions)
- ✅ Metrics collection & performance analytics
- ✅ Database persistence (SQLAlchemy models, run history tracking)
- ✅ Security validation (AST-based scanning, circuit breakers)
- 🔄 Full Multi-language Integration: Wire Rust & Go handlers into main pipeline; add Julia support
- 🔄 Cloud Deployment: REST API endpoints (FastAPI), Docker containers
- 🔄 Advanced Optimization: SIMD vectorization, GPU acceleration hints
- 🔄 IDE Integration: VS Code extension, PyCharm plugin
- 🔄 Advanced Analytics: ML-powered optimization suggestions
- 🔄 Auto-scaling: Dynamic agent pool management and load balancing
- 🔄 Deep Code Understanding: Neural network-based semantic analysis
- 🔄 Cross-file Dependency Analysis: Import graph resolution and multi-file linking
- 🔄 Real-time Performance Profiling: Live optimization feedback during conversion
- 🔄 Enhanced Collaboration: Persistent database-backed reviews, team dashboards
Transform your Python code into high-performance C++ with the power of autonomous AI agents! 🚀