Introducing CodeGPT
CodeGPT is an innovative tool designed to enhance coding productivity by utilizing artificial intelligence (AI) for two main tasks: writing git commit messages and performing code reviews. Developed as a Command Line Interface (CLI) using the Go programming language, CodeGPT integrates with Git to streamline your workflow through the use of ChatGPT AI models, including gpt-3.5-turbo and gpt-4.
Key Features
-
AI-Powered Commit Messages: CodeGPT automatically generates commit messages based on your code changes. This feat reduces the burden of manual message writing while ensuring comprehensiveness and consistency according to the conventional commits specification.
-
Code Reviews: The tool can conduct brief code reviews, providing insights into code quality and potential areas for improvement, using AI technology.
-
Git Hook Integration: By installing a
prepare-commit-msg
hook, CodeGPT becomes part of your Git workflow, enabling the AI to draft commit messages automatically each time you commit. -
Support for Multiple APIs: CodeGPT offers support for various services including Azure OpenAI Service, OpenAI API, Gemini, Ollama, Groq, and OpenRouter. Users can configure which service to use based on their needs.
-
Customizable Settings: Users have extensive options for customization, such as choosing AI models, setting context lines for diffs, excluding files from diffs, and even translating commit messages into different languages.
-
Network Configurations: The tool includes support for configuring HTTP and socks proxies, facilitating its use in diverse network environments.
Installation and Setup
CodeGPT is available for multiple operating systems and can be installed conveniently via Homebrew for MacOS or Chocolatey for Windows. Additionally, pre-compiled binaries can be downloaded from its release page.
Initial configuration involves setting up an OpenAI API Key, which allows the tool to communicate with the AI models. The configuration details, such as the API key and other settings, are stored in a .codegpt.yaml
file, making it easy to adjust preferences.
For those using alternative API services like Azure, Gemini, or Groq, CodeGPT provides clear instructions for integrating these services by updating the configuration file with necessary credentials and endpoints.
Usage
-
CLI Mode: Using Command Line Interface, users can directly invoke CodeGPT to generate commit messages or reviews. This involves staging your changes with
git add
and then using commands likecodegpt commit --preview
to see the generated commit message. -
Git Hook Mode: This mode integrates CodeGPT deeply into your Git workflow by using the
prepare-commit-msg
hook. Once installed, this hook allows Git to automatically invoke CodeGPT to propose commit messages as you commit your changes, ensuring a seamless user experience. -
Customized Commit Templates: Users can alter the default commit message template to suit their needs by using template strings or files, allowing for enhanced flexibility in documenting code changes.
Code Review Capabilities
CodeGPT goes beyond commit messages by providing AI-assisted code reviews that analyze the staged changes and offer feedback. Users can also translate these reviews into various languages, aiding in multinational collaborative environments.
Advanced Configuration
For advanced users, CodeGPT allows switching between different AI models and APIs, such as Groq or OpenRouter, and customizing configurations extensively to fit specific requirements or preferences.
Testing and Development
Developers can verify the tool's functionality by running tests available through the make test
command, ensuring robustness and reliability in diverse coding environments.
Additional Resources
For those interested, additional resources including the OpenAI Chat completions documentation and information about the ChatGPT and Whisper APIs provide further insights into the underlying technologies powering CodeGPT.
In summary, CodeGPT stands as a powerful ally for developers, leveraging AI to automate and streamline the creation of commit messages and conduct insightful code reviews, thus improving efficiency and software quality.