An AI-powered coding assistant that interprets natural language queries, generates optimized Python code, executes it securely, and provides detailed explanations.
- 🧠 Natural Language Understanding: Processes and understands coding requests in natural language
- 💻 Code Generation: Produces high-quality, optimized Python code tailored to your requirements
- 🔒 Secure Execution: Runs generated code in a sandboxed environment with resource limits
- 📚 Comprehensive Explanations: Provides detailed explanations of the generated code
- 🔄 Interactive Feedback: Learns from user feedback to improve over time
- 🌐 Multiple Interfaces: Command-line and REST API interfaces
The system is built with a modular architecture consisting of the following components:
- NLP Query Processor: Analyzes natural language coding requests
- Code Generator: Produces high-quality Python code using LLMs
- Security Validator: Checks code for security issues before execution
- Code Executor: Runs code in a secure sandbox environment
- Explanation Generator: Creates detailed explanations of generated code
- Feedback Handler: Processes user feedback to improve the system
-
Clone the repository:
git clone https://github.com/ShaileshKumar97/Intelligent-Python-Coding-Agent.git cd Intelligent-Python-Coding-Agent -
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
export CODEAGENT_OPENAI_API_KEY=your_api_key_here # Or create a .env file with the above
Run the agent in interactive mode:
python agent_cli.py --interactiveProcess a single query:
python agent_cli.py --query "Generate a Python function to compute the factorial of a number using recursion."For more options:
python agent_cli.py --helpStart the API server:
python agent_api.pyThe server will be available at http://localhost:8000 with Swagger documentation at http://localhost:8000/docs.
Example API request:
curl -X POST "http://localhost:8000/api/query" \
-H "Content-Type: application/json" \
-d '{"query": "Generate a Python function to compute the factorial of a number using recursion."}'The agent can be configured through the config/agent_config.json file. Key configuration options include:
- LLM Models: Choose which models to use for different components
- Execution Settings: Configure timeout, memory limits, and sandbox settings
- Security Options: Set security validation strictness
- Explanation Preferences: Configure technical level and detail level
- Feedback Settings: Enable/disable learning from feedback
intelligent-python-coding-agent/
├── agent/ # Core agent modules
│ ├── __init__.py
│ ├── code_executor.py # Secure code execution
│ ├── code_generator.py # Code generation module
│ ├── explanation_generator.py # Explanation generation
│ └── feedback_handler.py # Feedback processing
│ ├── intelligent_coding_agent.py # Main agent class
│ ├── nlp_processor.py # NLP query processor
├── config/ # Configuration
│ ├── __init__.py
│ ├── agent_config.json # Default configuration
│ └── settings.py # Configuration management
├── tests/ # Tests modules
│ └── tests_agent.py # Unit and Integration Test cases
├── utils/ # Utility modules
│ ├── __init__.py
│ ├── logger.py # Logging utilities
│ └── security.py # Security utilities
├── agent_cli.py # Command-line interface
├── agent_api.py # REST API interface
└── README.md # This file
├── requirements.txt # Dependencies
python agent_cli.py --query "Generate a Python function to compute the factorial of a number using recursion."python agent_cli.py --query "Create a script that reads a CSV file, filters rows where the 'age' column is above 30, and writes the result to a new CSV file."python agent_cli.py --query "Develop a Python solution for the knapsack problem using dynamic programming and explain the time complexity."Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- This project uses OpenAI's GPT models for natural language processing and code generation
- Built with LangChain for AI orchestration
- Support for additional programming languages
- Visual interface for code generation and execution
- Real-time collaboration features
- Integration with version control systems
- Support for more complex project structures and dependencies