Skip to main content

No project description provided

Project description

Generate your code documentation with LLMs

Build Publish

Focus on writing your code, let LLMs write the documentation for you.
With just a few keystrokes in your terminal by using the OpenAI API or 100% local LLMs without any data leaks.

Built with langchain, lama.cpp and treesitter.

ezgif-4-53d6e634af

✨ Features

  • 📝  Generate documentation comment blocks for all methods in a file
    • e.g. Javadoc, JSDoc, Docstring, Rustdoc etc.
  • ✍️   Generate inline documentation comments in method bodies
  • 🌳  Treesitter integration
  • 💻  Local LLM support
  • 🌐  Azure OpenAI support

[!NOTE]
Documentations will only be added to files without unstaged changes, so nothing is overwritten.

🚀 Usage

Create documentations for any method in a file specified by <RELATIVE_FILE_PATH> with GPT-3.5-Turbo model:

aicomments <RELATIVE_FILE_PATH>

Create also documentation comments in the method body:

aicomments <RELATIVE_FILE_PATH> --inline

Use GPT-4 model (Default is GPT-3.5):

aicomments <RELATIVE_FILE_PATH> --gpt4

Use Azure OpenAI:

aicomments <RELATIVE_FILE_PATH> --azure-deployment <DEPLOYMENT_NAME>

Use a local LLM on your machine:

aicomments <RELATIVE_FILE_PATH> --local_model <MODEL_PATH>

Guided mode, confirm documentation generation for each method:

aicomments <RELATIVE_FILE_PATH> --guided

[!NOTE]
How to download models from huggingface for local usage see Local LLM usage

[!IMPORTANT]
The results by using a local LLM will highly be affected by your selected model. To get similar results compared to GPT-3.5/4 you need to select very large models which require a powerful hardware.

⚙️ Supported Languages

  • Python
  • Typescript
  • Javascript
  • Java
  • Rust
  • Kotlin
  • Go
  • C++
  • C
  • Scala

📋 Requirements

  • Python >= 3.9

🔧 Installation

Install with pipx:

pipx install doc-comments-ai

It is recommended to use pipx for installation, nonetheless it is also possible to use pip.

1. OpenAI usage

Create your personal OpenAI API key and add it as $OPENAI_API_KEY to your environment with:

export OPENAI_API_KEY = <YOUR_API_KEY>

2. Azure OpenAI usage

Add the following variables to your environment:

export AZURE_API_BASE = "https://<your-endpoint.openai.azure.com/"
export AZURE_API_KEY = <YOUR_AZURE_OPENAI_API_KEY>
export AZURE_API_VERSION = "2023-05-15"

3. Local LLM usage

By using a local LLM no API key is required. On first usage of --local_model you will be asked for confirmation to intall llama-cpp-python with its dependencies. The installation process will take care of the hardware-accelerated build tailored to your hardware and OS. For further details see: installation-with-hardware-acceleration

To download a model from huggingface for local usage the most convenient way is using the huggingface-cli:

huggingface-cli download TheBloke/CodeLlama-13B-Python-GGUF codellama-13b-python.Q5_K_M.gguf

This will download the codellama-13b-python.Q5_K_M model to ~/.cache/huggingface/. After the download has finished the absolute path of the .gguf file is printed to the console which can be used as the value for --local_model.

[!IMPORTANT]
Since llama.cpp is used the model must be in the .gguf format.

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

doc_comments_ai-0.1.11.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

doc_comments_ai-0.1.11-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file doc_comments_ai-0.1.11.tar.gz.

File metadata

  • Download URL: doc_comments_ai-0.1.11.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.9.18 Linux/6.2.0-1012-azure

File hashes

Hashes for doc_comments_ai-0.1.11.tar.gz
Algorithm Hash digest
SHA256 685dee2cdcf2b564b773eb22a624f63fcdaf582995789c0e133d60a94d129927
MD5 fcfe0c1e1edac8b686a3ffc19a8e4cc9
BLAKE2b-256 20d0d537e500b950312c0235c135a4dfc7b976d7bbb61ccbb8b4ae4ea145ea7b

See more details on using hashes here.

File details

Details for the file doc_comments_ai-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: doc_comments_ai-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.9.18 Linux/6.2.0-1012-azure

File hashes

Hashes for doc_comments_ai-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 46bc8b6e08d28f6490487995d15aa953455a3151bc1d301be796b464c4827965
MD5 bb487cd9dbc25e2e48d5a2343497c57f
BLAKE2b-256 2bafc8a69449f3806a267e400415d46cad0a070b46568b1ec95e97d314f12f86

See more details on using hashes here.

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