aldrin312 / AutoCommentingTool

BSD 3-Clause "New" or "Revised" License
2 stars 2 forks source link

About The Project

Autocomment is a Cli tool that automates the process of adding meaningful comments to your source code. By integrating with OpenAI’s language models, Autocomment generates insightful comments that enhance code readability and documentation.

Installation

  1. Get a free API Key at https://console.groq.com
  2. Clone the repo
    git clone https://github.com/aldrin312/AutoCommentingTool.git
  3. Install NPM packages
    npm install
    npm install --save groq-sdk
    npm install commander
    npm install dotenv
  4. Create a .env file and add your api into it
    GROQ_API_KEY=<api-key>

    Usage

To use the CLI tool make sure to change the excecution policies for windows.

To do this run windows powershell in administration mode and run the command:

    Set-ExecutionPolicy RemoteSigned

And then run the command:

    npm link

To create the CLI tool avialable to use in powershell in any directory.

Tool Execution:

    autocomment <filename> ...

Command can also be executed without changing execution policy or running npm link by running this command:

   node index.js <filename> ...

Demo:

Options:

New Feature: --token-usage

The --token-usage flag has been added to display token statistics when generating comments. This can help monitor the number of tokens used in API requests, providing insight into the cost and efficiency of the request.

Example Command

node index.js --token-usage <filename>

This will print the generated comments and output token usage statistics to the console.

Example Output

{
  "queue_time": 0.003453426,
  "prompt_tokens": 90,
  "prompt_time": 0.010868842,
  "completion_tokens": 123,
  "completion_time": 0.1025,
  "total_tokens": 213,
  "total_time": 0.113368842
}

Future features