Skip to content

thependalorian/code_hero

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Code Hero πŸ¦Έβ€β™‚οΈ

A production-ready hierarchical multi-agent AI system built with LangGraph that provides specialized assistance across 19 expert domains with industry-standard prompts, dynamic tool binding, and comprehensive infrastructure integration.

🎯 Latest Major Updates

βœ… Devstral Model Integration (Just Implemented)

  • Added Mistral's Devstral 24B - Specialized coding model for Python development
  • Integrated as secondary model for coding agents in backend configuration
  • 46.8% SWE-Bench Verified score - Multi-file editing and codebase exploration
  • Available via API, HuggingFace, and Ollama - Flexible deployment options

βœ… Code Quality & Build System (Just Implemented)

  • Black formatting applied to all Python files (88 char line length)
  • isort import organization with Black-compatible profile
  • Frontend build fixes - All TypeScript errors resolved
  • Successful production build - Ready for deployment

βœ… File Structure Consolidation (Just Implemented)

  • Moved frontend utilities from backend to proper frontend location
  • Enhanced document management - Comprehensive FileUpload component
  • API client consolidation - Full document lifecycle support
  • Cleaned up duplicates - Removed temporary and redundant files

βœ… Industry-Standard Prompt System (Previously Implemented)

  • Replaced all hardcoded prompts with dynamic, context-aware system
  • Integrated with existing prompt infrastructure (prompts.py, config.py)
  • Scalable for any request type - no more limitations
  • Context-aware prompt building using build_enhanced_prompt()

βœ… Enhanced Tool Binding (Previously Implemented)

  • Dynamic tool binding based on agent roles and context
  • 11 tools available including web search, document search, code generation
  • Category-based assignment (development, research, documentation)
  • Fallback to all tools when category-specific binding fails

βœ… All Critical Issues Fixed (Just Implemented)

  • AgentRole enum references - all corrected
  • Tool binding system - fully functional
  • Error handling - comprehensive with fallbacks
  • LLM integration - primary + fallback models
  • Syntax validation - all files pass compilation

πŸš€ Quick Start

Backend Setup

# Install dependencies
pip install -r requirements.txt

# Start the backend server
python -m uvicorn src.code_hero.main:app --reload --port 8000

Frontend Setup

# Navigate to frontend directory
cd frontend

# Install dependencies
npm install

# Start development server
npm run dev

πŸ—οΈ Architecture

Hierarchical Multi-Agent System

  • 19 Specialized Agents: Each expert in specific domains
  • Hierarchical Team Structure: Development, Research, and Documentation teams
  • LLM-Based Routing: Intelligent task routing with structured output
  • Comprehensive Infrastructure: Full integration with all Code Hero components
  • Template-Based Prompts: Zero hardcoded responses
  • Model-Aware Selection: OpenAI, DeepSeek, Groq support

Hierarchical Team Structure

Development Team

  • FastAPI Expert - Backend development and API design
  • Next.js Expert - Frontend development and React components
  • Code Expert - General programming and implementation

Research Team

  • Research Expert - Information gathering and analysis
  • Strategic Expert - Strategic planning and architecture
  • Analysis Expert - Data analysis and insights

Documentation Team

  • Documentation Expert - Technical writing and guides
  • Implementation Expert - Implementation documentation and tutorials

Main Orchestrator

  • Supervisor - Routes between teams and manages workflow

Agent Domains

  1. SUPERVISOR - Multi-agent coordination and team routing
  2. RESEARCH - Research and analysis
  3. IMPLEMENTATION - Software development
  4. DOCUMENTATION - Technical documentation
  5. TRD_CONVERTER - Requirements conversion
  6. CODE_GENERATOR - Code generation
  7. CODE_REVIEWER - Code quality assurance
  8. STANDARDS_ENFORCER - Compliance enforcement
  9. STRATEGIC_EXPERT - Strategic planning
  10. LANGCHAIN_EXPERT - LangChain development
  11. LANGGRAPH_EXPERT - LangGraph workflows
  12. LLAMAINDEX_EXPERT - RAG systems
  13. FASTAPI_EXPERT - Backend development
  14. NEXTJS_EXPERT - Frontend development
  15. PYDANTIC_EXPERT - Data validation
  16. AGNO_EXPERT - Agno framework
  17. CREWAI_EXPERT - Multi-agent systems
  18. DOCUMENT_ANALYZER - Document processing
  19. PROMPT_ENGINEER - Prompt optimization

🎨 Code Quality

Formatting & Standards

  • Black: Python code formatting (88 char line length) - βœ… Applied to all files
  • isort: Import organization with Black-compatible profile - βœ… Applied
  • TypeScript: Frontend build errors resolved - βœ… Production ready
  • Pre-commit hooks: Automatic formatting on commits
  • Flake8: Code linting (230 minor issues remaining)

Quick Format

# Run formatting script
./format_code.sh

# Or manually
black src/ tests/ --line-length 88 --target-version py39
isort src/ tests/ --profile black

Build Commands

# Backend build
python setup.py build

# Frontend build (production ready)
npm run build

# Full build verification
npm run build && python setup.py build

πŸ§ͺ Testing

# Run all tests
python -m pytest tests/ -v

# Quick test
python -m pytest tests/ -q

# Test coverage
python -m pytest tests/ --cov=src/code_hero

πŸ“Š System Status

  • βœ… Backend: Running on port 8000
  • βœ… Frontend: Running on port 3000 (Next.js 15) - Production build successful
  • βœ… LangGraph: Running on port 2024 with hierarchical system loaded
  • βœ… Tests: 20/20 passing
  • βœ… Agents: 19 experts operational with industry-standard prompts
  • βœ… Hierarchical System: LLM-based routing with team structure
  • βœ… Tool Binding: Dynamic binding with 11 tools available
  • βœ… Infrastructure: Comprehensive integration with all components
  • βœ… Code Quality: Black + isort formatted (88 char line length)
  • βœ… Build System: Frontend TypeScript errors resolved, production ready
  • βœ… Devstral Integration: Mistral's coding model available for Python tasks
  • βœ… File Structure: Consolidated frontend/backend separation
  • βœ… Document Management: Enhanced upload/processing capabilities
  • βœ… AgentRole Enums: All references corrected and validated
  • βœ… Error Handling: Comprehensive fallbacks and recovery

πŸ”§ Configuration

Environment Variables

# Required API Keys
OPENAI_API_KEY=your_openai_key
MISTRAL_API_KEY=your_mistral_key    # For Devstral model access
DEEPSEEK_API_KEY=your_deepseek_key  # Optional
GROQ_API_KEY=your_groq_key          # Optional

# Database (Optional)
ASTRA_DB_TOKEN=your_astra_token
ASTRA_DB_ENDPOINT=your_astra_endpoint

# LangSmith Tracing (Optional)
LANGCHAIN_API_KEY=your_langsmith_key
LANGCHAIN_TRACING_V2=true
LANGCHAIN_PROJECT=code-hero

Model Configuration

The system intelligently selects models based on task requirements:

  • OpenAI GPT-4: Complex reasoning and analysis
  • Mistral Devstral 24B: Specialized Python coding and software engineering
  • DeepSeek: Cost-effective coding tasks
  • Groq: Fast inference for simple tasks

Devstral Integration

  • Specialized for coding: 46.8% score on SWE-Bench Verified
  • Multi-file editing: Advanced codebase exploration capabilities
  • Python optimization: Specifically tuned for Python development
  • Secondary model: Available as alternative for coding agents

πŸ›οΈ Infrastructure Components

Core Infrastructure

  • State Management: Comprehensive state tracking and persistence
  • Context Management: Cross-agent context sharing
  • Agent Manager: Task tracking and completion recording
  • Strategic Agent: Strategic guidance and planning
  • Service Validation: Health monitoring and validation
  • Logger: Structured logging with state tracking
  • Utils: Tool execution, ID generation, file handling

Advanced Features

  • Human-in-the-Loop: Interactive workflow management
  • Workflow Runner: Advanced workflow execution
  • Performance Metrics: Comprehensive monitoring
  • Error Handling: Graceful fallbacks and recovery
  • Service Health: Real-time component monitoring

πŸ“ Project Structure

code-hero/
β”œβ”€β”€ src/code_hero/              # Backend source code
β”‚   β”œβ”€β”€ hierarchical_agents.py  # Hierarchical multi-agent system
β”‚   β”œβ”€β”€ agent_expert.py         # Expert agent implementations
β”‚   β”œβ”€β”€ supervisor.py           # LangGraph supervisor
β”‚   β”œβ”€β”€ state.py               # Agent state management
β”‚   β”œβ”€β”€ tools.py               # Agent tools
β”‚   β”œβ”€β”€ prompts.py             # Prompt templates
β”‚   β”œβ”€β”€ config.py              # Configuration management (includes Devstral)
β”‚   β”œβ”€β”€ context.py             # Context management
β”‚   β”œβ”€β”€ logger.py              # Structured logging
β”‚   β”œβ”€β”€ manager.py             # State management
β”‚   β”œβ”€β”€ services.py            # Service management
β”‚   β”œβ”€β”€ utils.py               # Utility functions
β”‚   β”œβ”€β”€ interfaces.py          # Service interfaces
β”‚   β”œβ”€β”€ types.py               # Type definitions
β”‚   β”œβ”€β”€ agents_api.py          # Agent API endpoints
β”‚   β”œβ”€β”€ documents_api.py       # Document processing endpoints
β”‚   └── main.py                # FastAPI application
β”œβ”€β”€ frontend/                  # Next.js frontend (consolidated)
β”‚   β”œβ”€β”€ src/app/              # App router pages
β”‚   β”œβ”€β”€ src/components/       # React components
β”‚   β”‚   β”œβ”€β”€ documents/        # Document management components
β”‚   β”‚   β”‚   └── FileUpload.tsx # Enhanced file upload with TRD conversion
β”‚   β”‚   β”œβ”€β”€ agents/           # Agent interface components
β”‚   β”‚   └── ui/               # Reusable UI components
β”‚   β”œβ”€β”€ src/hooks/            # React hooks (moved from backend)
β”‚   β”‚   └── useDocuments.ts   # Document management hook
β”‚   β”œβ”€β”€ src/utils/            # Frontend utilities (consolidated)
β”‚   β”‚   └── api.ts            # API client with full document support
β”‚   └── public/               # Static assets
β”œβ”€β”€ tests/                    # Test suite
β”œβ”€β”€ docs/                     # Documentation
β”œβ”€β”€ .pre-commit-config.yaml   # Code formatting hooks
β”œβ”€β”€ format_code.sh            # Formatting script
β”œβ”€β”€ setup.py                  # Python package configuration
└── package.json              # Node.js dependencies and scripts

πŸš€ Deployment

Vercel (Recommended)

# Deploy frontend
cd frontend
vercel deploy

# Deploy backend (serverless functions)
vercel deploy --prod

Docker

# Build and run
docker-compose up --build

πŸ“š Documentation

  • System Status: SYSTEM_STATUS.md
  • Architecture: ARCHITECTURE.md
  • API Documentation: API_DOCUMENTATION.md
  • Deployment Guide: DEPLOYMENT_GUIDE.md
  • Quick Start: QUICK_START.md
  • Frontend Integration: frontend/FRONTEND_INTEGRATION.md
  • API Documentation: Available at /docs when backend is running

πŸ€– Hierarchical Agent Usage

Simple Requests

# Greeting - handled directly
curl -X POST "http://localhost:8000/api/chat/?message=hello"

# Development request - routed to Development Team
curl -X POST "http://localhost:8000/api/chat/?message=create%20a%20FastAPI%20endpoint"

# Research request - routed to Research Team  
curl -X POST "http://localhost:8000/api/chat/?message=research%20best%20practices%20for%20API%20design"

# Documentation request - routed to Documentation Team
curl -X POST "http://localhost:8000/api/chat/?message=write%20documentation%20for%20this%20API"

Infrastructure Status

# Check infrastructure health
python -c "
import asyncio
from src.code_hero.hierarchical_agents import validate_full_infrastructure
async def check():
    status = await validate_full_infrastructure()
    print(f'Status: {status[\"overall_status\"]}')
    print(f'Healthy: {status[\"healthy_components\"]}')
asyncio.run(check())
"

🀝 Contributing

  1. Code Formatting: Run ./format_code.sh before committing
  2. Tests: Ensure all tests pass with python -m pytest tests/
  3. Documentation: Update relevant docs for new features
  4. Pre-commit: Install hooks with pre-commit install

πŸ“„ License

MIT License - see LICENSE file for details.


Status: 🟒 FULLY OPERATIONAL WITH HIERARCHICAL AGENTS
Last Updated: January 2025 - Devstral Integration & Build System
Version: 3.1 - Enhanced Multi-Agent System with Specialized Coding Models

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors