Skip to main content

Generate intelligent Git commit messages with AI. Supports Conventional Commits, emoji, and multiple LLM providers like OpenAI, Ollama, and Gemini.

Project description

🤖 commity

PyPI version Python versions License

English | 简体中文

Generate intelligent Git commit messages with AI. Supports Conventional Commits, emoji, and multiple LLM providers like OpenAI, Ollama, and Gemini.

🤔 What is Commity?

Commity is an open-source, AI-powered Git commit message generation tool. It analyzes your staged code changes and automatically generates commit messages that follow the Conventional Commits specification, and can even add emojis for you!

With a simple commity --emoji command, you can get a professional and clear commit message like this:

feat(api): ✨ add user authentication endpoint

🔧 Installation

Install with pip:

pip install commity

Or install with uv:

uv tool install commity

⚙️ Configuration

commity supports three configuration methods, with the following priority: Command-line Arguments > Environment Variables > Configuration File.

Supported model providers are: Gemini (default), Ollama, OpenAI, OpenRouter, NVIDIA.

Gemini, OpenAI, OpenRouter, and NVIDIA always require an API key. Commity aborts early if those keys are missing so you get fast feedback before hitting the network.

✨ Method 1: Specify Model Parameters via Command-line

OpenAI

commity --provider openai --model gpt-3.5-turbo --api_key <your-api-key>

Ollama

commity --provider ollama --model llama2 --base_url http://localhost:11434

Gemini

commity --provider gemini --model gemini-2.5-flash --base_url https://generativelanguage.googleapis.com --api_key <your-api-key> --timeout 30

or

commity \
--provider gemini \
--model gemini-2.5-flash \
--base_url https://generativelanguage.googleapis.com \
--api_key <your-api-key> \
--timeout 30 \

OpenRouter

commity --provider openrouter --model openai/gpt-3.5-turbo --api_key <your-openrouter-api-key>

or

commity \
--provider openrouter \
--model anthropic/claude-3.5-sonnet \
--api_key <your-openrouter-api-key> \

NVIDIA

commity --provider nvidia --model nvidia/llama-3.1-70b-instruct --api_key <your-nvidia-api-key>

or

commity \
--provider nvidia \
--model nvidia/llama-3.1-nemotron-70b-instruct \
--api_key <your-nvidia-api-key> \

🌱 Method 2: Set Environment Variables as Defaults

You can add the following to your .bashrc, .zshrc, or .env file:

OpenAI

export COMMITY_PROVIDER=openai
export COMMITY_MODEL=gpt-3.5-turbo
export COMMITY_API_KEY=your-api-key

Ollama

export COMMITY_PROVIDER=ollama
export COMMITY_MODEL=llama2
export COMMITY_BASE_URL=http://localhost:11434

Gemini

export COMMITY_PROVIDER=gemini
export COMMITY_MODEL=gemini-2.5-flash
export COMMITY_BASE_URL=https://generativelanguage.googleapis.com
export COMMITY_API_KEY=your-api-key
export COMMITY_TEMPERATURE=0.5

OpenRouter

export COMMITY_PROVIDER=openrouter
export COMMITY_MODEL=openai/gpt-3.5-turbo
export COMMITY_API_KEY=your-openrouter-api-key
export COMMITY_TEMPERATURE=0.5

NVIDIA

export COMMITY_PROVIDER=nvidia
export COMMITY_MODEL=nvidia/llama-3.1-70b-instruct
export COMMITY_API_KEY=your-nvidia-api-key
export COMMITY_TEMPERATURE=0.5

📝 Method 3: Use a Configuration File (Recommended)

For easier configuration management, you can create a ~/.commity/config.json file in your user's home directory.

  1. Create the directory:

    mkdir -p ~/.commity
    
  2. Create and edit the config.json file:

    touch ~/.commity/config.json
    
  3. Add your configuration to config.json, for example:

    {
      "PROVIDER": "ollama",
      "MODEL": "llama3",
      "BASE_URL": "http://localhost:11434"
    }
    

    Or using Gemini:

    {
      "PROVIDER": "gemini",
      "MODEL": "gemini-1.5-flash",
      "BASE_URL": "https://generativelanguage.googleapis.com",
      "API_KEY": "your-gemini-api-key"
    }
    

    Or using OpenAI:

    {
      "PROVIDER": "openai",
      "MODEL": "gpt-3.5-turbo",
      "API_KEY": "your-openai-api-key"
    }
    

    Or using OpenRouter:

    {
      "PROVIDER": "openrouter",
      "MODEL": "openai/gpt-3.5-turbo",
      "API_KEY": "your-openrouter-api-key"
    }
    

    Or using NVIDIA:

    {
      "PROVIDER": "nvidia",
      "MODEL": "nvidia/llama-3.1-70b-instruct",
      "API_KEY": "your-nvidia-api-key"
    }
    

🚀 Usage

# Run
commity

# View help
commity --help

# Use Chinese (--lang is kept as an alias)
commity --language zh

# Include emojis
commity --emoji

# Use OpenRouter with specific model
commity --provider openrouter --model anthropic/claude-3.5-sonnet --api_key <your-openrouter-api-key>

# Use OpenRouter with emoji support
commity --provider openrouter --model openai/gpt-4o --api_key <your-openrouter-api-key> --emoji

# Use NVIDIA with specific model
commity --provider nvidia --model nvidia/llama-3.1-70b-instruct --api_key <your-nvidia-api-key>

# Use NVIDIA with emoji support
commity --provider nvidia --model nvidia/llama-3.1-nemotron-70b-instruct --api_key <your-nvidia-api-key> --emoji

# Skip interactive confirmation and commit immediately
commity --confirm n

# Run via Python module entry point
python -m commity --language zh --emoji

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

commity-0.1.18.tar.gz (93.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

commity-0.1.18-py3-none-any.whl (35.1 kB view details)

Uploaded Python 3

File details

Details for the file commity-0.1.18.tar.gz.

File metadata

  • Download URL: commity-0.1.18.tar.gz
  • Upload date:
  • Size: 93.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for commity-0.1.18.tar.gz
Algorithm Hash digest
SHA256 6d8b806ac24773ee7b6b67a1ce5b55424bae9cc3199b1183cfac5db678d26fd2
MD5 f49f9049bc1ec29abde1e8e90b089972
BLAKE2b-256 05d7ffd86d0733972207206b2c361817da7981ce969be34e9334cf96a1118059

See more details on using hashes here.

File details

Details for the file commity-0.1.18-py3-none-any.whl.

File metadata

  • Download URL: commity-0.1.18-py3-none-any.whl
  • Upload date:
  • Size: 35.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for commity-0.1.18-py3-none-any.whl
Algorithm Hash digest
SHA256 d84f5fab1fceaaa1d1dd2bf6700d561ce4c6c28d8b8bd2e34d7a51fb7ca3c19b
MD5 8ee76de59e32cd666adf41ec0d84e4a9
BLAKE2b-256 b96a32f30d4609f13995472bd3b46f92c5aff573b66934b403f4a2a76412fa51

See more details on using hashes here.

Supported by

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