Skip to main content

good to generate a brief commit

Project description

code-savior

English | 中文


English Version

Introduction

code-savior is a Python package that empowers AI to automatically generate git commit messages. It supports multiple languages and has plans to extend its capabilities to auto-generate code documentation in the future.

Installation and Usage

  1. Install the package via pip:
    pip install code-savior
    
  2. Add files to the staging area using git:
    git add .
    
  3. Run code-savior:
    code-savior
    

The tool will automatically generate a commit message and prompt you for confirmation before committing.

Configuration Options

Configuring .env

Refer to the env.example file for available configurations:

  1. OpenAI related configurations:

    • CS_OPENAI_API_KEY: The API key for OpenAI, used for authentication and API requests.
    • CS_OPENAI_BASE_PATH: The base path for OpenAI's API, default is https://api.openai.com/v1.
    • CS_OPENAI_MODEL: The OpenAI model to use, default is gpt-3.5-turbo.
    • CS_OPENAI_MAX_TOKEN: The maximum token limit for OpenAI requests, default is 1000.
  2. code-savior related configurations:

    • CS_MAX_LENGTH: The maximum length of the message, default is 1000.
    • CS_LANGUAGE: Set the language (ISO 639-1 format), default is en.
    • CS_MAX_ITERATION: The number of messages to generate, default is 1.
    • CS_RESPONSE_TYPE(currently unavailable): Set the response type, default is empty.
    • CS_HTTP_PROXY, CS_HTTPS_PROXY: Set the network proxy, default is empty both.
    • CS_TIMEOUT: Set the network timeout in seconds, default is 10.
    • CS_EXCLUDE_FILES: List of files not to be added to the git staging area, separated by commas.

Command Line Arguments

The above environment variables can also be configured using command line arguments. Below are the purposes and examples of the command line arguments:

  1. OpenAI related configurations:
    • --api_key: Set the OpenAI API key. For example: --api_key=YOUR_API_KEY
    • --base_path: Set the base path for OpenAI's API. For example: --base_path=https://api.openai.com/v1
    • --model: Set the OpenAI model to use. For example: --model=gpt-3.5-turbo
    • --max_token: Set the maximum token limit for OpenAI requests. For example: --max_token=1000
  2. code-savior related configurations:
    • --max_length: Set the maximum length of the message. For example: --max_length=1000
    • --language: Set the language (ISO 639-1 format). For example: --language=en
    • --max_iteration: Set the number of messages to generate. For example: --max_iteration=3
    • --response_type(currently unavailable): Set the response type. For example: --response_type=TYPE
    • --http_proxy, --https_proxy: Set the network proxy. For example: --http_proxy=http://10.10.1.10:3128, --https_proxy=http://10.10.1.10:1080
    • --timeout: Set the network timeout in seconds. For example: --timeout=10
    • --exclude_files: Set the list of files not to be added to the git staging area. For example: --exclude_files file1.py file2.py

Note: In this command, apart from --exclude_files which adds files you don't want to track, all other command line arguments will override the corresponding settings in the .env file.

Code review

Comming soon.

Auto-generate Code Documentation

Comming soon.

中文版本

介绍

code-savior 是一个Python包,可以让AI自动生成git commit的描述文字。它支持多种语言,并计划在未来扩展其功能,以自动生成代码文档。

安装和使用方法

  1. 通过pip安装此包:
    pip install code-savior
    
  2. 使用git命令将文件添加到暂存区:
    git add .
    
  3. 运行 code-savior
    code-savior
    

工具会自动为您生成commit消息,并在提交前询问您是否确认。

相关可选项的配置

配置.env

参考env.example文件,可配置项如下:

  1. OpenAI相关配置:
    • CS_OPENAI_API_KEY:OpenAI的API密钥,用于身份验证和API请求。
    • CS_OPENAI_BASE_PATH:OpenAI的API基础路径,默认为https://api.openai.com/v1。
    • CS_OPENAI_MODEL:要使用的OpenAI模型,默认为gpt-3.5-turbo。
    • CS_OPENAI_MAX_TOKEN:OpenAI请求的最大令牌限制,默认为1000。
  2. code-savior相关配置:
    • CS_MAX_LENGTH:消息的最大长度,默认为1000。
    • CS_LANGUAGE:设置语言(ISO 639-1格式),默认为en。
    • CS_MAX_ITERATION:要生成的消息数量,默认为1。
    • CS_RESPONSE_TYPE(暂不支持):设置响应类型,默认为空。
    • CS_HTTP_PROXY, CS_HTTPS_PROXY:设置网络代理,默认均为空。
    • CS_TIMEOUT:设置网络超时(以秒为单位),默认为10。
    • CS_EXCLUDE_FILES:不添加到git暂存区的文件列表,文件之间用逗号分隔。

命令行参数

上述环境变量均能用命令行参数配置,以下是命令行参数的作用和示例:

  1. OpenAI相关配置:
    • --api_key:设置OpenAI API密钥。例如:--api_key=YOUR_API_KEY
    • --base_path:设置OpenAI的API基础路径。例如:--base_path=https://api.openai.com/v1
    • --model:设置要使用的OpenAI模型。例如:--model=gpt-3.5-turbo
    • --max_token:设置OpenAI请求的最大令牌限制。例如:--max_token=1000
  2. code-savior相关配置:
    • --max_length:设置消息的最大长度。例如:--max_length=1000
    • --language:设置语言(ISO 639-1格式)。例如:--language=en
    • --max_iteration:设置要生成的消息数量。例如:--max_iteration=3
    • --response_type(暂不支持):设置响应类型。例如:--response_type=TYPE
    • --http_proxy, --https_proxy:设置网络代理。例如:--http_proxy=http://10.10.1.10:3128, --https_proxy=http://10.10.1.10:1080
    • --timeout:设置网络超时(以秒为单位)。例如:--timeout=10
    • --exclude_files:设置不添加到git暂存区的文件列表。例如:--exclude_files file1.py file2.py

注意:在本次命令中,除了--exclude_files会添加不希望跟踪的文件,其余命令行参数均会覆盖.env文件中的相应设置。

代码审查

敬请期待

自动输出代码文档

敬请期待。

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

code-savior-1.0.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

code_savior-1.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file code-savior-1.0.tar.gz.

File metadata

  • Download URL: code-savior-1.0.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for code-savior-1.0.tar.gz
Algorithm Hash digest
SHA256 be20f7bf8d7ddae77a3e7c2971376e3b1ab70bf634c2bfb163dccbe5da9b98ba
MD5 54fced8a23be7b5bd5d41db857356a17
BLAKE2b-256 9165327087fffdb33a4844e6cf34659f82a2c845e3aa91b2c36ae5e9a433007c

See more details on using hashes here.

File details

Details for the file code_savior-1.0-py3-none-any.whl.

File metadata

  • Download URL: code_savior-1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for code_savior-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 462ed5293b3195ea7fb423dc8ca3d554a8c0036ebd43701b95eefa1f021475e5
MD5 2aaf785c08a6373ea537db13378c21f0
BLAKE2b-256 8debab92d3ee9a5f1a6ceccc20a3fc3826c95c88ab49d1ce2815bb340e8b2bce

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