An Intelligent AI-Powered Development Assistant
CodePilot is a sophisticated Python-based AI assistant that leverages the power of Groq's LLaMA 3.3 70B model to provide intelligent coding assistance, project generation, and task automation. Built with a robust action-observation cycle, CodePilot can understand complex development requests and execute them through a systematic approach involving thinking, planning, and execution phases.
- Multi-Step Reasoning: Employs a START → THINK → ACTION → OBSERVE → OUTPUT cycle for complex problem-solving
- Contextual Understanding: Analyzes user queries to determine the most appropriate resolution strategy
- Adaptive Processing: Continues processing until the task is fully completed
- Command Execution: Execute shell commands directly on your system with full stdout/stderr capture
- File Operations: Create, write, and manage files with automatic directory creation
- Weather Information: Built-in weather data retrieval for major cities
- Mathematical Operations: Perform calculations and numerical operations
- Project Generation: Automatically create complete project structures and applications
- Natural Language Processing: Understands complex development requests in plain English
- Code Generation: Creates complete applications with proper structure and formatting
- Project Organization: Automatically creates organized folder structures for new projects
- Error Handling: Robust error management with detailed feedback
Main Engine (main.py)
- Central orchestration system managing the AI interaction cycle
- JSON-structured communication protocol
- Tool mapping and execution management
- Continuous conversation flow handling
LLM Helper (llm_helper.py)
- Groq API integration and management
- Model configuration and response handling
- JSON-formatted response processing
- Environment-based API key management
- Initialization: Load environment variables and configure Groq client
- Query Processing: Accept and analyze user input
- Planning Phase: AI determines required actions and tools
- Execution Phase: Execute tools and commands as needed
- Observation Phase: Process tool outputs and responses
- Output Generation: Provide comprehensive results to user
| Tool | Purpose | Parameters | Return Type |
|---|---|---|---|
addTwoNumbers |
Mathematical operations | a: number, b: number |
number |
getWeatherInfo |
Weather data retrieval | city: string |
string |
executeCommand |
Shell command execution | command: string |
string |
writeToFile |
File creation and writing | filePath: string, content: string |
string |
- Python 3.7 or higher
- Groq API access and API key
- Terminal/Command line access
- Internet connectivity for AI model access
-
Clone the Repository
git clone https://github.com/devvrat-hans/codepilot.git cd codepilot -
Set Up Virtual Environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Dependencies
pip install -r requirements.txt
-
Configure Environment
cp .env.example .env # Edit .env file and add your GROQ_API_KEY
Create a .env file in the project root with your Groq API credentials:
GROQ_API_KEY=your_groq_api_key_here
Basic Execution
python main.pyInteractive Mode The application will prompt you to enter your development request. Examples:
- "Create a complete chess website with HTML, CSS, and JavaScript"
- "Build a REST API for a todo application"
- "Generate a responsive portfolio website"
- "Create a Python script for data analysis"
- Complete Website Generation: Create full-stack web applications
- Frontend Development: Generate responsive HTML, CSS, and JavaScript projects
- Backend Services: Build REST APIs and server-side applications
- Database Integration: Create database schemas and connection scripts
- File Organization: Automatically structure project directories
- Configuration Setup: Generate configuration files and environment setups
- Documentation: Create comprehensive project documentation
- Testing Framework: Set up testing environments and scripts
- Script Generation: Create automation scripts for system tasks
- Environment Setup: Configure development environments
- File Management: Batch file operations and organization
- System Monitoring: Create monitoring and logging scripts
- Analysis Scripts: Generate data processing and analysis tools
- Report Generation: Create automated reporting systems
- File Conversion: Build file format conversion utilities
- Data Validation: Create data quality and validation scripts
CodePilot automatically creates organized project structures with:
- Proper directory hierarchies
- Configuration files
- Documentation templates
- Development environment setup
- Version control initialization
- Technology Stack Selection: Chooses appropriate technologies based on requirements
- Best Practices: Implements industry-standard coding practices
- Security Considerations: Includes security best practices in generated code
- Performance Optimization: Optimizes code for performance and scalability
- Command Validation: Validates commands before execution
- Error Recovery: Attempts to recover from errors and provide alternatives
- Detailed Logging: Comprehensive error reporting and debugging information
- Graceful Degradation: Continues operation when non-critical errors occur
codepilot/
├── main.py # Main application orchestrator
├── llm_helper.py # Groq API integration helper
├── requirements.txt # Python dependencies
├── .env.example # Environment configuration template
├── .gitignore # Git ignore rules
└── README.md # Project documentation
- Environment variable-based configuration
- Secure API key storage practices
- Git-ignored sensitive files
- Shell command validation
- Error handling for malicious commands
- Subprocess security measures
- Directory validation before file creation
- Path traversal prevention
- Safe file writing practices
- macOS: Full support with zsh shell integration
- Linux: Compatible with bash and zsh shells
- Windows: PowerShell and Command Prompt support
- Python 3.7+
- Compatible with virtual environments
- pip package management
- groq: Groq API client for LLM integration
- python-dotenv: Environment variable management
- Internet connectivity for AI model access
- File system write permissions
- Shell command execution capabilities
API Key Issues
- Verify GROQ_API_KEY in .env file
- Check API key validity and permissions
- Ensure internet connectivity
Command Execution Errors
- Verify shell permissions
- Check command syntax and availability
- Review system compatibility
File Operation Errors
- Confirm write permissions
- Validate file paths and directories
- Check disk space availability
- Define tool function in main.py
- Add function to TOOLS_MAP dictionary
- Update SYSTEM_PROMPT with tool description
- Test tool integration
- Identify new use cases and requirements
- Design tool interface and parameters
- Implement tool logic with error handling
- Update documentation and examples
- Follow Python PEP 8 style guidelines
- Include comprehensive error handling
- Add docstrings for all functions
- Update documentation for new features
- Test with various input scenarios
- Verify cross-platform compatibility
- Validate security measures
- Check performance with large projects
- Streamlined API Calls: Optimized communication with Groq API
- Caching Strategy: Efficient response caching for repeated queries
- Resource Management: Proper memory and CPU usage optimization
- Parallel Processing: Multi-threaded operations where applicable
- Modular Architecture: Easy to extend and modify
- Tool Plugin System: Simple tool addition mechanism
- Configuration Management: Flexible configuration options
- Logging and Monitoring: Comprehensive system monitoring
- Multi-Language Support: Support for additional programming languages
- Integration Extensions: Database, cloud service, and API integrations
- Template System: Pre-built project templates and boilerplates
- Collaboration Tools: Multi-user development support
- Version Control Integration: Advanced Git operations and management
- Tool Contributions: Community-developed tools and extensions
- Template Library: Shared project templates and examples
- Documentation Improvements: Enhanced guides and tutorials
- Bug Reports and Fixes: Community-driven issue resolution
- Documentation: Comprehensive guides and API references
- Issue Tracking: GitHub Issues for bug reports and feature requests
- Community Forums: Discussion boards for user collaboration
- Developer Support: Direct support for advanced use cases
- Code Contributions: Pull requests welcome
- Documentation: Help improve guides and examples
- Testing: Assist with cross-platform testing
- Feature Ideas: Suggest new tools and capabilities
This project is open source and available under the MIT License.
- Groq: For providing powerful AI model access
- LLaMA 3.3: Advanced language model capabilities
- Python Community: Excellent libraries and frameworks
- Open Source Contributors: Community support and contributions
CodePilot - Transforming ideas into code with AI-powered intelligence. Build faster, code smarter, and create more with your intelligent development companion.