PyGen is a Python Generative AI Co-pilot designed to enhance productivity and streamline development processes for Python developers. This tool leverages state-of-the-art large language models (LLMs) such as GPT-4 and Claude 3.5 Sonnet to provide advanced features, including intelligent code and test generation, refactoring, linting, static analysis, and more. PyGen aims to offer a robust development experience powered by the latest advancements in AI.
- Convert: Convert various file types into Python code.
- Explain: Provide detailed explanations for the Python codebase, modules, classes, or functions.
- Generate: Automatically generate Python tests or docstrings for modules, classes, or functions.
- Git: Perform Git operations such as checking staged changes, generating commit messages, or creating pull request messages.
- Refactor: Refactor Python code including modules, classes, or functions to improve structure and readability.
- Resolve: Resolve issues detected by Python tools like Bandit, Flake8, Pylint, and Mypy.
- Review: Review the codebase, modules, classes, or functions and suggest improvements.
- Traceback: Provide guidance and suggestions to resolve Python traceback errors.
To install PyGen, use pip:
pip install pygenPyGen requires an environment file (.env) in the root directory with the following AWS credentials to access a Large Language Model (LLM) on AWS Bedrock:
AWS_ACCESS_KEY_ID=<your_access_key_id>
AWS_SECRET_ACCESS_KEY=<your_secret_access_key>Ensure you have set up an LLM on AWS Bedrock and provide the above keys in the .env file.
PyGen is a Python Typer command-line interface (CLI) tool. Below are some examples of how to use it:
You can set the logging level using the --level option:
pygen --level [DEBUG|INFO|WARNING|ERROR]Convert various file types into Python code:
pygen convert <file_path>Get detailed explanations for your code:
pygen explain codebase
pygen explain module <module_name>
pygen explain class <class_name>
pygen explain function <function_name>Generate code, tests, and docstrings:
pygen generate tests module <module_name>
pygen generate tests class <class_name>
pygen generate tests function <function_name>
pygen generate docstring module <module_name>
pygen generate docstring class <class_name>
pygen generate docstring function <function_name>Perform Git operations:
pygen git check
pygen git commit
pygen git pr
Refactor your Python code:
pygen refactor module <module_name>
pygen refactor class <class_name>
pygen refactor function <function_name>Resolve issues detected by Python tools:
pygen resolve bandit
pygen resolve flake8
pygen resolve pylint
pygen resolve mypyReview and suggest improvements for your code:
pygen review codebase
pygen review module <module_name>
pygen review class <class_name>
pygen review function <function_name>Provide guidance and suggestions to resolve Python traceback errors:
pygen tracebackWe welcome contributions to PyGen! If you would like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Make your changes.
- Commit your changes (
git commit -m 'Add new feature'). - Push to the branch (
git push origin feature-branch). - Open a pull request.
Please ensure your code adheres to our coding standards and includes appropriate tests.
If you encounter any issues or have questions about PyGen, please feel free to open an issue in the GitHub repository or contact the maintainer:
- Maintainer: Chris Jackett
This project is licensed under the MIT License. See the LICENSE file for more details.
