Skip to main content

CoderGPT

Project description

CoderGPT

CoderGPT is a versatile command-line interface (CLI) designed to enhance coding workflows. It leverages the capabilities of Large Language Models (LLM) and Generative Pre-trained Transformers (GPT) to assist developers in various tasks such as commenting, optimizing, documenting, and testing their code. This tool integrates seamlessly with langchain, providing a powerful backend for code generation and modification.

Model Providers Implemented

  • OpenAI [gpt-3.5-turbo, gpt-4, gpt-4-turbo-preview(default)]
  • Google [gemini-pro]
  • Anthropic [claude-2]

Prerequisites

Before you begin using CoderGPT, you must set the OPENAI_API_KEY, GOOGLE_API_KEY and ANTHROPIC_API_KEY environment variables on your machine. This key enables authentication with the OpenAI and Google APIs, which are essential for the language model's operation.

export OPENAI_API_KEY='your-api-key-here'
export GOOGLE_API_KEY='your-api-key-here'
export ANTHROPIC_API_KEY='your-api-key-here''

Ensure that you replace your-api-key-here with your actual OpenAI API key to enable the full functionality of CoderGPT.

Getting Started

Installation

Install CoderGPT easily using pip:

pip install codergpt

Basic Usage

Invoke the CoderGPT CLI with the following syntax:

codergpt [OPTIONS] COMMAND [ARGS]...

Options

  • -v, --verbose INTEGER: Adjust the verbosity level (0 for default, 1 for verbose, 2 for debug).
  • -q, --quiet: Suppress output.
  • --version: Show the version number and exit.
  • --model: Model to use for performing requests.
    • Available models:
      • OpenAI: [gpt-3.5-turbo, gpt-4, gpt-4-turbo-preview(default)]
      • Google: [gemini-pro]
      • Anthropic[claude-2]

Commands

Inspect

Analyze a package and display its file-language mapping.

codergpt --model <model-name> inspect <path>
Example
$ codergpt --model gpt-4 inspect src/codergpt/
Explain

Provide an explanation for a specific function or class within a package.

codergpt explain <path> [--function <function_name>] [--classname <class_name>]
Example
$ codergpt explain src/codergpt/explainer/explainer.py --function explain
Comment

Automatically add comments to your code. Choose whether to overwrite the existing file or create a new one.

codergpt comment <path> [--overwrite/--no-overwrite]
Example
$ codergpt comment greetings.py --overwrite
Optimize

Enhance your code by optimizing it and adding comments. You can decide to overwrite the original file or save the changes separately.

codergpt optimize <path> [--overwrite/--no-overwrite]
Example
$ codergpt optimize example.py --overwrite
Write Tests

Generate test cases for a specified code file, targeting particular functions and/or classes.

codergpt write-tests <filename> [--function <function_name>] [--class <classname>] [--outfile <output_filename>]
Example
$ codergpt write-tests example.py --function add --class Calculator
Document

Create documentation for a given code file by processing and explaining the code.

codergpt document <path> [--outfile <output_filename>]
Example
$ codergpt document example.py

Development & Contribution

The CoderGPT CLI is developed in Python, utilizing the click library for creating commands. Here's a template for adding a new command:

import click
from codergpt import CoderGPT

coder = CoderGPT()

@click.command()
@click.argument('path', type=click.Path(exists=True))
def new_command(path):
    # Implement command logic here
    pass

Contributions to CoderGPT are highly encouraged! Please review our contributing guidelines before making pull requests.

License

CoderGPT is open-sourced under the MIT License. For more details, refer to the LICENSE.md file.

Acknowledgments

This project was scaffolded using the cookiecutter framework, based on the monarch-project-template. Updates are managed through cruft.

For comprehensive details on the CoderGPT CLI, please refer to the official documentation.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codergpt-0.1.8.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

codergpt-0.1.8-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file codergpt-0.1.8.tar.gz.

File metadata

  • Download URL: codergpt-0.1.8.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for codergpt-0.1.8.tar.gz
Algorithm Hash digest
SHA256 037549505f6d2bc6c0d36a75d7990c7974490ae2fecaaa7095aed6c1ca40767a
MD5 bafef7c9c0f4aa2f0064986c094868dd
BLAKE2b-256 070839a20c8ef3eb9626e21a34603d23d2ae8fa41e6c1e7d5c68423e316eb8f2

See more details on using hashes here.

Provenance

File details

Details for the file codergpt-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: codergpt-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for codergpt-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 fbe701ff915d23c153fea6434d9c95a86c74d92127d3d64cc2f87bcc60492ffb
MD5 fb2cc51625c5d83182300e43fe60b9ec
BLAKE2b-256 0a4b8a17202785e0dd8b50214653806a5bb07ee6a28971573787def1d22b84cf

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page