chatgpt-pre-commit-hooks


Namechatgpt-pre-commit-hooks JSON
Version 0.1.3 PyPI version JSON
download
home_page
SummaryPre-commit hooks collection that utilizes ChatGPT and OpenAI platform to validate modifications made to the codebase.
upload_time2023-04-23 06:13:33
maintainer
docs_urlNone
author
requires_python>=3.8
licenseMIT
keywords chatgpt openai pre-commit pre-commit-hooks pre-commit-hook
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 🤖 ChatGPT / OpenAI pre-commit-hooks

[![pre-commit][pre-commit-image]][pre-commit-link]
[![PyPI - version][pypi-version-image]][pypi-version-link]
[![PyPI - python version][pypi-pyversions-image]][pypi-pyversions-link]
[![PyPI - downloads][pypi-stats-image]][pypi-stats-link]
[![GitHub - CI][github-ci-image]][github-ci-link]

Pre-commit hooks collection that utilizes ChatGPT and OpenAI platform to validate changes made to the codebase.

- [🎣 Hooks](#-hooks)
  - [`chatgpt-commit-message`](#chatgpt-commit-message)
- [📥 Prerequisites setup](#-prerequisites-setup)
  - [OpenAI Platform](#openai-platform)
  - [Azure OpenAI Service](#azure-openai-service)
  - [Setting environment variables](#setting-environment-variables)
  - [pre-commit setup](#pre-commit-setup)
- [📦 Hooks setup](#-hooks-setup)
  - [Remote repository reference (preferred)](#remote-repository-reference-preferred)
  - [Local repository reference](#local-repository-reference)
- [🛠️ Advanced configuration](#️-advanced-configuration)
  - [Extra environment variables](#extra-environment-variables)
  - [Arguments](#arguments)
  - [`--env-prefix`](#--env-prefix)
  - [Variables precedence](#variables-precedence)
- [💸 Payments](#-payments)
- [👥 Contributing](#-contributing)
- [📄 License](#-license)

## 🎣 Hooks

### `chatgpt-commit-message`

Hook that uses OpenAI's ChatGPT API to generate a summary of changes made to a codebase and use it to populate the commit message automatically.

- ⚙️ Read about hook's specific [configuration](https://github.com/DariuszPorowski/chatgpt-pre-commit-hooks/blob/main/docs/chatgpt_commit_message.md).

![chatgpt-commit-message](https://raw.githubusercontent.com/dariuszporowski/chatgpt-pre-commit-hooks/main/docs/assets/demos/chatgpt_commit_message.gif)

## 📥 Prerequisites setup

Hooks support [OpenAI Platform](https://platform.openai.com) and [Azure OpenAI Service](https://azure.microsoft.com/products/cognitive-services/openai-service).

### OpenAI Platform

OpenAI API Key is mandatory to run hooks and has to be setup via an environment variable.

1. Create your [API Key](https://platform.openai.com/account/api-keys), and get your Organization ID from [Organization settings](https://platform.openai.com/account/org-settings)

    ![OpenAI API Key](https://raw.githubusercontent.com/dariuszporowski/chatgpt-pre-commit-hooks/main/assets/images/openai-platform-api-key.png)

    ![OpenAI Organization ID](https://raw.githubusercontent.com/dariuszporowski/chatgpt-pre-commit-hooks/main/assets/images/openai-platform-org-id.png)

1. Store values as an environment variables:
    - `OPENAI_API_KEY` for API Key
    - `OPENAI_ORGANIZATION` for Organization ID

    Example:

    ```shell
    export OPENAI_API_KEY="sk-xxxxxx"
    export OPENAI_ORGANIZATION="org-xxxxxx"
    ```

> 💡 **HINT**
>
> How to setup environment variables? see: [Setting environment variables](#setting-environment-variables)

### Azure OpenAI Service

1. Go to [Azure Portal](https://portal.azure.com), and get `API Key`, `Endpoint`, `Model deployment name`, and `api-version`.

    ![Azure OpenAI API Key and Endpoint](https://raw.githubusercontent.com/dariuszporowski/chatgpt-pre-commit-hooks/main/assets/images/azure-openai-service-key-endpoint.png)

    ![Azure OpenAI Model](https://raw.githubusercontent.com/dariuszporowski/chatgpt-pre-commit-hooks/main/assets/images/azure-openai-service-models.png)

    The latest supported `api-version` you can get from [Azure OpenAI Service](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/reference#chat-completions)

1. Store values as an environment variables:
    - `OPENAI_API_TYPE` put `azure` to specified OpenAI provider
    - `OPENAI_API_KEY` for API Key
    - `OPENAI_API_BASE` for Endpoint
    - `OPENAI_API_VERSION` for `api-version`
    - `OPENAI_MODEL` for Model deployment name

    Example:

    ```shell
    export OPENAI_API_TYPE="azure"
    export OPENAI_API_KEY="xxxxxx"
    export OPENAI_API_BASE="https://xxxxxx.openai.azure.com/"
    export OPENAI_API_VERSION="2023-03-15-preview"
    export OPENAI_MODEL="xxxxx-gpt-35-turbo"
    ```

> 💡 **HINT**
>
> How to setup environment variables? see: [Setting environment variables](#setting-environment-variables)

### Setting environment variables

Linux/MacOS example:

```shell
export OPENAI_API_KEY="sk-xxxxxx"
```

Windows `powershell` example:

```powershell
$env:OPENAI_API_KEY="sk-xxxxxx"
```

Windows `cmd` example:

```console
set OPENAI_API_KEY=sk-xxxxxx
```

> ⚠️ **NOTE**
>
> The above example stores the environment variable temporarily for the current session. To store it permanently, please follow [Best Practices for API Key Safety](https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety)

### pre-commit setup

Before you start, ensure you have `pre-commit` installed in your repository. Below is just an essential quick start. Follow official pre-commit [install](https://pre-commit.com/#install) documentation for advanced scenarios.

```shell
# install using pip
pip install pre-commit

# check if working - expected print with version like `pre-commit 3.2.2`
pre-commit --version
```

Add to your `.pre-commit-config.yaml` top level `default_install_hook_types` section (for more information, follow [Confining hooks to run at certain stages](https://pre-commit.com/#confining-hooks-to-run-at-certain-stages))

```yaml
default_install_hook_types:
  - pre-commit # this is default hook type, equivalent to classic `pre-commit install` command
  - prepare-commit-msg # this type is not enabled by default, please enable it - equivalent to `pre-commit install --hook-type prepare-commit-msg` command
  - ... # rest of hook types what are you using, if any
```

next:

```shell
# setup the git repo for hooks
pre-commit install

# (optional) periodically run updates to your pre-commit config to make sure you always have the latest version of the hooks
pre-commit autoupdate
```

## 📦 Hooks setup

### Remote repository reference (preferred)

Add to your `.pre-commit-config.yaml`

```yaml
default_install_hook_types:
  - pre-commit
  - prepare-commit-msg
repos:
  - repo: https://github.com/DariuszPorowski/chatgpt-pre-commit-hooks
    rev: vX.Y.Z  # Use the ref you want to point at, see ⚠️ NOTE below!
    hooks:
      - id: <id1> # follow 🎣 Hooks section to see available hooks IDs
      - id: <id2> # follow 🎣 Hooks section to see available hooks IDs
      - id: ...
```

Example:

```yaml
default_install_hook_types:
  - pre-commit
  - prepare-commit-msg
repos:
  - repo: https://github.com/DariuszPorowski/chatgpt-pre-commit-hooks
    rev: v0.1.3
    hooks:
      - id: chatgpt-commit-message
```

> ⚠️ **NOTE**
>
> For the `rev:` always try to use the latest version. You can check the latest release under [GitHub Releases](https://github.com/DariuszPorowski/chatgpt-pre-commit-hooks/releases/latest)

### Local repository reference

1. Install or add [PyPI](https://pypi.org/project/chatgpt-pre-commit-hooks) package to your project.

   - if you are using [pip](https://pip.pypa.io):

     ```shell
     pip install --upgrade chatgpt-pre-commit-hooks
     ```

   - or include it in a `requirements.txt` file in your project:

     ```text
     chatgpt-pre-commit-hooks~=0.1.3
     ```

      and run:

     ```shell
     pip install -r requirements.txt
     ```

   - or, even better, in the `dev` section of your `pyproject.toml` file:

     ```toml
     [project.optional-dependencies]
     dev = ["chatgpt-pre-commit-hooks"]
     ```

      and run:

     ```shell
     pip install .[dev]
     ```

   - or, if you are using [poetry](https://python-poetry.org) as a package manager:

     ```shell
     poetry add chatgpt-pre-commit-hooks --group dev
     ```

1. Add to your `.pre-commit-config.yaml`

    ```yaml
    default_install_hook_types:
      - pre-commit
      - prepare-commit-msg
    repos:
      - repo: local
        hooks:
          - id: <id> # follow 🎣 Hooks section to see available hooks IDs
            name: <name> # any name you'd like to set
            entry: chatgpt-pre-commit-hooks
            args:
              - "--hook"
              - "<id>" # follow 🎣 Hooks section to see available hooks IDs
              - "..." # rest of args what you'd like to set (optional)
            language: system
    ```

    Example:

    ```yaml
    default_install_hook_types:
      - pre-commit
      - prepare-commit-msg
    repos:
    - repo: local
        hooks:
        - id: chatgpt-commit-message
          name: ChatGPT commit message
          entry: chatgpt-pre-commit-hooks
          args:
            - "--hook"
            - "chatgpt-commit-message"
            - "--description"
            - "--emoji"
          language: system
    ```

## 🛠️ Advanced configuration

### Extra environment variables

In addition to the environment variables listed in the [📥 Prerequisites setup](#-prerequisites-setup) section, you can set several configurations using extra environment variables.

| Name                |  Type  |     Default     | Description                                                                                                                                  |
|:--------------------|:------:|:---------------:|:---------------------------------------------------------------------------------------------------------------------------------------------|
| `OPENAI_MAX_TOKENS` |  int   |      1024       | [What are tokens and how to count them?](https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them)                  |
| `OPENAI_MODEL`      | string | `gpt-3.5-turbo` | [Model endpoint compatibility](https://platform.openai.com/docs/models/model-endpoint-compatibility) - check `/v1/chat/completions` endpoint |
| `OPENAI_PROXY`      | string |    _not set_    | http/https client proxy                                                                                                                      |

### Arguments

Any environment variable can be overridden by hard-coded arguments in `pre-commit-config.yaml`, except `OPENAI_API_KEY`, `OPENAI_ORGANIZATION`.

| Name                  |  Type  |  Default  | Description                                                                                                       |
|:----------------------|:------:|:---------:|:------------------------------------------------------------------------------------------------------------------|
| `--env-prefix`        | string | _not set_ | Set prefix for environment variables allowing multiple configurations. Read more: [`--env-prefix`](#--env-prefix) |
| `--openai-max-tokens` |  int   | _not set_ | Overrides `OPENAI_MAX_TOKENS`                                                                                     |
| `--openai-proxy`      | string | _not set_ | Overrides `OPENAI_PROXY`                                                                                          |
| `--openai-model`      | string | _not set_ | Overrides `OPENAI_MODEL`                                                                                          |
| `--openai-api-base`   | string | _not set_ | Overrides `OPENAI_API_BASE`                                                                                       |
| `--openai-api-type`   | string | _not set_ | Overrides `OPENAI_API_TYPE`                                                                                       |

Example:

```yaml
default_install_hook_types:
  - pre-commit
  - prepare-commit-msg
repos:
  - repo: https://github.com/DariuszPorowski/chatgpt-pre-commit-hooks
    rev: vX.Y.Z
    hooks:
      - id: ... # follow 🎣 Hooks section to see available hooks IDs
        args:
          - "--env-prefix"
          - "personal"
          - "--openai-max-tokens"
          - "512"
          - ...
```

### `--env-prefix`

It's a special argument where you can mark prefixes for your environment variables. This allows you to set many configurations depending on the project, account, profile, etc., for example, `personal`, `work`. Fallback is a global environment variable if prefixed isn't found.

For instance, if your prefix is `personal`, then the environment variable must be set `PERSONAL__OPENAI_MAX_TOKENS`, meaning the structure is `<prefix>__<base_env_name>` - two underscores `__` between `prefix` and `base_env_name`.

Example:

```shell
export PERSONAL__OPENAI_API_KEY="sk-xxxxxx"
export WORK__OPENAI_API_KEY="sk-xxxxxx"
```

### Variables precedence

1. hard-coded arguments, for example `--openai-max-tokens`
1. prefixed environment variable, for example `PERSONAL__OPENAI_MAX_TOKENS`
1. global environment variable, for example `OPENAI_MAX_TOKENS`

## 💸 Payments

Project by default uses `gpt-3.5-turbo` model because of [its lower cost](https://openai.com/pricing). You have to pay for your own OpenAI API requests.

## 👥 Contributing

Contributions to the project are welcome! Please follow [Contributing Guide](https://github.com/DariuszPorowski/chatgpt-pre-commit-hooks/blob/main/CONTRIBUTING.md).

## 📄 License

This project is distributed under the terms of the [MIT](https://opensource.org/licenses/MIT) license.

[github-ci-image]: https://img.shields.io/github/actions/workflow/status/DariuszPorowski/chatgpt-pre-commit-hooks/workflow.ci.yml?style=flat-square&branch=main&event=push
[github-ci-link]: https://github.com/DariuszPorowski/chatgpt-pre-commit-hooks/actions/workflows/workflow.ci.yml?query=branch%3Amain+event%3Apush
[pre-commit-image]: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&style=flat-square
[pre-commit-link]: https://github.com/pre-commit/pre-commit
[pypi-version-image]: https://img.shields.io/pypi/v/chatgpt-pre-commit-hooks?style=flat-square
[pypi-version-link]: https://pypi.org/project/chatgpt-pre-commit-hooks
[pypi-pyversions-image]: https://img.shields.io/pypi/pyversions/chatgpt-pre-commit-hooks?style=flat-square
[pypi-pyversions-link]: https://pypi.org/project/chatgpt-pre-commit-hooks
[pypi-stats-image]: https://img.shields.io/pypi/dm/chatgpt-pre-commit-hooks?style=flat-square
[pypi-stats-link]: https://pypistats.org/packages/chatgpt-pre-commit-hooks

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "chatgpt-pre-commit-hooks",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "chatgpt,openai,pre-commit,pre-commit-hooks,pre-commit-hook",
    "author": "",
    "author_email": "Dariusz Porowski <3431813+dariuszporowski@users.noreply.github.com>",
    "download_url": "",
    "platform": null,
    "description": "# \ud83e\udd16 ChatGPT / OpenAI pre-commit-hooks\n\n[![pre-commit][pre-commit-image]][pre-commit-link]\n[![PyPI - version][pypi-version-image]][pypi-version-link]\n[![PyPI - python version][pypi-pyversions-image]][pypi-pyversions-link]\n[![PyPI - downloads][pypi-stats-image]][pypi-stats-link]\n[![GitHub - CI][github-ci-image]][github-ci-link]\n\nPre-commit hooks collection that utilizes ChatGPT and OpenAI platform to validate changes made to the codebase.\n\n- [\ud83c\udfa3 Hooks](#-hooks)\n  - [`chatgpt-commit-message`](#chatgpt-commit-message)\n- [\ud83d\udce5 Prerequisites setup](#-prerequisites-setup)\n  - [OpenAI Platform](#openai-platform)\n  - [Azure OpenAI Service](#azure-openai-service)\n  - [Setting environment variables](#setting-environment-variables)\n  - [pre-commit setup](#pre-commit-setup)\n- [\ud83d\udce6 Hooks setup](#-hooks-setup)\n  - [Remote repository reference (preferred)](#remote-repository-reference-preferred)\n  - [Local repository reference](#local-repository-reference)\n- [\ud83d\udee0\ufe0f Advanced configuration](#\ufe0f-advanced-configuration)\n  - [Extra environment variables](#extra-environment-variables)\n  - [Arguments](#arguments)\n  - [`--env-prefix`](#--env-prefix)\n  - [Variables precedence](#variables-precedence)\n- [\ud83d\udcb8 Payments](#-payments)\n- [\ud83d\udc65 Contributing](#-contributing)\n- [\ud83d\udcc4 License](#-license)\n\n## \ud83c\udfa3 Hooks\n\n### `chatgpt-commit-message`\n\nHook that uses OpenAI's ChatGPT API to generate a summary of changes made to a codebase and use it to populate the commit message automatically.\n\n- \u2699\ufe0f Read about hook's specific [configuration](https://github.com/DariuszPorowski/chatgpt-pre-commit-hooks/blob/main/docs/chatgpt_commit_message.md).\n\n![chatgpt-commit-message](https://raw.githubusercontent.com/dariuszporowski/chatgpt-pre-commit-hooks/main/docs/assets/demos/chatgpt_commit_message.gif)\n\n## \ud83d\udce5 Prerequisites setup\n\nHooks support [OpenAI Platform](https://platform.openai.com) and [Azure OpenAI Service](https://azure.microsoft.com/products/cognitive-services/openai-service).\n\n### OpenAI Platform\n\nOpenAI API Key is mandatory to run hooks and has to be setup via an environment variable.\n\n1. Create your [API Key](https://platform.openai.com/account/api-keys), and get your Organization ID from [Organization settings](https://platform.openai.com/account/org-settings)\n\n    ![OpenAI API Key](https://raw.githubusercontent.com/dariuszporowski/chatgpt-pre-commit-hooks/main/assets/images/openai-platform-api-key.png)\n\n    ![OpenAI Organization ID](https://raw.githubusercontent.com/dariuszporowski/chatgpt-pre-commit-hooks/main/assets/images/openai-platform-org-id.png)\n\n1. Store values as an environment variables:\n    - `OPENAI_API_KEY` for API Key\n    - `OPENAI_ORGANIZATION` for Organization ID\n\n    Example:\n\n    ```shell\n    export OPENAI_API_KEY=\"sk-xxxxxx\"\n    export OPENAI_ORGANIZATION=\"org-xxxxxx\"\n    ```\n\n> \ud83d\udca1 **HINT**\n>\n> How to setup environment variables? see: [Setting environment variables](#setting-environment-variables)\n\n### Azure OpenAI Service\n\n1. Go to [Azure Portal](https://portal.azure.com), and get `API Key`, `Endpoint`, `Model deployment name`, and `api-version`.\n\n    ![Azure OpenAI API Key and Endpoint](https://raw.githubusercontent.com/dariuszporowski/chatgpt-pre-commit-hooks/main/assets/images/azure-openai-service-key-endpoint.png)\n\n    ![Azure OpenAI Model](https://raw.githubusercontent.com/dariuszporowski/chatgpt-pre-commit-hooks/main/assets/images/azure-openai-service-models.png)\n\n    The latest supported `api-version` you can get from [Azure OpenAI Service](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/reference#chat-completions)\n\n1. Store values as an environment variables:\n    - `OPENAI_API_TYPE` put `azure` to specified OpenAI provider\n    - `OPENAI_API_KEY` for API Key\n    - `OPENAI_API_BASE` for Endpoint\n    - `OPENAI_API_VERSION` for `api-version`\n    - `OPENAI_MODEL` for Model deployment name\n\n    Example:\n\n    ```shell\n    export OPENAI_API_TYPE=\"azure\"\n    export OPENAI_API_KEY=\"xxxxxx\"\n    export OPENAI_API_BASE=\"https://xxxxxx.openai.azure.com/\"\n    export OPENAI_API_VERSION=\"2023-03-15-preview\"\n    export OPENAI_MODEL=\"xxxxx-gpt-35-turbo\"\n    ```\n\n> \ud83d\udca1 **HINT**\n>\n> How to setup environment variables? see: [Setting environment variables](#setting-environment-variables)\n\n### Setting environment variables\n\nLinux/MacOS example:\n\n```shell\nexport OPENAI_API_KEY=\"sk-xxxxxx\"\n```\n\nWindows `powershell` example:\n\n```powershell\n$env:OPENAI_API_KEY=\"sk-xxxxxx\"\n```\n\nWindows `cmd` example:\n\n```console\nset OPENAI_API_KEY=sk-xxxxxx\n```\n\n> \u26a0\ufe0f **NOTE**\n>\n> The above example stores the environment variable temporarily for the current session. To store it permanently, please follow [Best Practices for API Key Safety](https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety)\n\n### pre-commit setup\n\nBefore you start, ensure you have `pre-commit` installed in your repository. Below is just an essential quick start. Follow official pre-commit [install](https://pre-commit.com/#install) documentation for advanced scenarios.\n\n```shell\n# install using pip\npip install pre-commit\n\n# check if working - expected print with version like `pre-commit 3.2.2`\npre-commit --version\n```\n\nAdd to your `.pre-commit-config.yaml` top level `default_install_hook_types` section (for more information, follow [Confining hooks to run at certain stages](https://pre-commit.com/#confining-hooks-to-run-at-certain-stages))\n\n```yaml\ndefault_install_hook_types:\n  - pre-commit # this is default hook type, equivalent to classic `pre-commit install` command\n  - prepare-commit-msg # this type is not enabled by default, please enable it - equivalent to `pre-commit install --hook-type prepare-commit-msg` command\n  - ... # rest of hook types what are you using, if any\n```\n\nnext:\n\n```shell\n# setup the git repo for hooks\npre-commit install\n\n# (optional) periodically run updates to your pre-commit config to make sure you always have the latest version of the hooks\npre-commit autoupdate\n```\n\n## \ud83d\udce6 Hooks setup\n\n### Remote repository reference (preferred)\n\nAdd to your `.pre-commit-config.yaml`\n\n```yaml\ndefault_install_hook_types:\n  - pre-commit\n  - prepare-commit-msg\nrepos:\n  - repo: https://github.com/DariuszPorowski/chatgpt-pre-commit-hooks\n    rev: vX.Y.Z  # Use the ref you want to point at, see \u26a0\ufe0f NOTE below!\n    hooks:\n      - id: <id1> # follow \ud83c\udfa3 Hooks section to see available hooks IDs\n      - id: <id2> # follow \ud83c\udfa3 Hooks section to see available hooks IDs\n      - id: ...\n```\n\nExample:\n\n```yaml\ndefault_install_hook_types:\n  - pre-commit\n  - prepare-commit-msg\nrepos:\n  - repo: https://github.com/DariuszPorowski/chatgpt-pre-commit-hooks\n    rev: v0.1.3\n    hooks:\n      - id: chatgpt-commit-message\n```\n\n> \u26a0\ufe0f **NOTE**\n>\n> For the `rev:` always try to use the latest version. You can check the latest release under [GitHub Releases](https://github.com/DariuszPorowski/chatgpt-pre-commit-hooks/releases/latest)\n\n### Local repository reference\n\n1. Install or add [PyPI](https://pypi.org/project/chatgpt-pre-commit-hooks) package to your project.\n\n   - if you are using [pip](https://pip.pypa.io):\n\n     ```shell\n     pip install --upgrade chatgpt-pre-commit-hooks\n     ```\n\n   - or include it in a `requirements.txt` file in your project:\n\n     ```text\n     chatgpt-pre-commit-hooks~=0.1.3\n     ```\n\n      and run:\n\n     ```shell\n     pip install -r requirements.txt\n     ```\n\n   - or, even better, in the `dev` section of your `pyproject.toml` file:\n\n     ```toml\n     [project.optional-dependencies]\n     dev = [\"chatgpt-pre-commit-hooks\"]\n     ```\n\n      and run:\n\n     ```shell\n     pip install .[dev]\n     ```\n\n   - or, if you are using [poetry](https://python-poetry.org) as a package manager:\n\n     ```shell\n     poetry add chatgpt-pre-commit-hooks --group dev\n     ```\n\n1. Add to your `.pre-commit-config.yaml`\n\n    ```yaml\n    default_install_hook_types:\n      - pre-commit\n      - prepare-commit-msg\n    repos:\n      - repo: local\n        hooks:\n          - id: <id> # follow \ud83c\udfa3 Hooks section to see available hooks IDs\n            name: <name> # any name you'd like to set\n            entry: chatgpt-pre-commit-hooks\n            args:\n              - \"--hook\"\n              - \"<id>\" # follow \ud83c\udfa3 Hooks section to see available hooks IDs\n              - \"...\" # rest of args what you'd like to set (optional)\n            language: system\n    ```\n\n    Example:\n\n    ```yaml\n    default_install_hook_types:\n      - pre-commit\n      - prepare-commit-msg\n    repos:\n    - repo: local\n        hooks:\n        - id: chatgpt-commit-message\n          name: ChatGPT commit message\n          entry: chatgpt-pre-commit-hooks\n          args:\n            - \"--hook\"\n            - \"chatgpt-commit-message\"\n            - \"--description\"\n            - \"--emoji\"\n          language: system\n    ```\n\n## \ud83d\udee0\ufe0f Advanced configuration\n\n### Extra environment variables\n\nIn addition to the environment variables listed in the [\ud83d\udce5 Prerequisites setup](#-prerequisites-setup) section, you can set several configurations using extra environment variables.\n\n| Name                |  Type  |     Default     | Description                                                                                                                                  |\n|:--------------------|:------:|:---------------:|:---------------------------------------------------------------------------------------------------------------------------------------------|\n| `OPENAI_MAX_TOKENS` |  int   |      1024       | [What are tokens and how to count them?](https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them)                  |\n| `OPENAI_MODEL`      | string | `gpt-3.5-turbo` | [Model endpoint compatibility](https://platform.openai.com/docs/models/model-endpoint-compatibility) - check `/v1/chat/completions` endpoint |\n| `OPENAI_PROXY`      | string |    _not set_    | http/https client proxy                                                                                                                      |\n\n### Arguments\n\nAny environment variable can be overridden by hard-coded arguments in `pre-commit-config.yaml`, except `OPENAI_API_KEY`, `OPENAI_ORGANIZATION`.\n\n| Name                  |  Type  |  Default  | Description                                                                                                       |\n|:----------------------|:------:|:---------:|:------------------------------------------------------------------------------------------------------------------|\n| `--env-prefix`        | string | _not set_ | Set prefix for environment variables allowing multiple configurations. Read more: [`--env-prefix`](#--env-prefix) |\n| `--openai-max-tokens` |  int   | _not set_ | Overrides `OPENAI_MAX_TOKENS`                                                                                     |\n| `--openai-proxy`      | string | _not set_ | Overrides `OPENAI_PROXY`                                                                                          |\n| `--openai-model`      | string | _not set_ | Overrides `OPENAI_MODEL`                                                                                          |\n| `--openai-api-base`   | string | _not set_ | Overrides `OPENAI_API_BASE`                                                                                       |\n| `--openai-api-type`   | string | _not set_ | Overrides `OPENAI_API_TYPE`                                                                                       |\n\nExample:\n\n```yaml\ndefault_install_hook_types:\n  - pre-commit\n  - prepare-commit-msg\nrepos:\n  - repo: https://github.com/DariuszPorowski/chatgpt-pre-commit-hooks\n    rev: vX.Y.Z\n    hooks:\n      - id: ... # follow \ud83c\udfa3 Hooks section to see available hooks IDs\n        args:\n          - \"--env-prefix\"\n          - \"personal\"\n          - \"--openai-max-tokens\"\n          - \"512\"\n          - ...\n```\n\n### `--env-prefix`\n\nIt's a special argument where you can mark prefixes for your environment variables. This allows you to set many configurations depending on the project, account, profile, etc., for example, `personal`, `work`. Fallback is a global environment variable if prefixed isn't found.\n\nFor instance, if your prefix is `personal`, then the environment variable must be set `PERSONAL__OPENAI_MAX_TOKENS`, meaning the structure is `<prefix>__<base_env_name>` - two underscores `__` between `prefix` and `base_env_name`.\n\nExample:\n\n```shell\nexport PERSONAL__OPENAI_API_KEY=\"sk-xxxxxx\"\nexport WORK__OPENAI_API_KEY=\"sk-xxxxxx\"\n```\n\n### Variables precedence\n\n1. hard-coded arguments, for example `--openai-max-tokens`\n1. prefixed environment variable, for example `PERSONAL__OPENAI_MAX_TOKENS`\n1. global environment variable, for example `OPENAI_MAX_TOKENS`\n\n## \ud83d\udcb8 Payments\n\nProject by default uses `gpt-3.5-turbo` model because of [its lower cost](https://openai.com/pricing). You have to pay for your own OpenAI API requests.\n\n## \ud83d\udc65 Contributing\n\nContributions to the project are welcome! Please follow [Contributing Guide](https://github.com/DariuszPorowski/chatgpt-pre-commit-hooks/blob/main/CONTRIBUTING.md).\n\n## \ud83d\udcc4 License\n\nThis project is distributed under the terms of the [MIT](https://opensource.org/licenses/MIT) license.\n\n[github-ci-image]: https://img.shields.io/github/actions/workflow/status/DariuszPorowski/chatgpt-pre-commit-hooks/workflow.ci.yml?style=flat-square&branch=main&event=push\n[github-ci-link]: https://github.com/DariuszPorowski/chatgpt-pre-commit-hooks/actions/workflows/workflow.ci.yml?query=branch%3Amain+event%3Apush\n[pre-commit-image]: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&style=flat-square\n[pre-commit-link]: https://github.com/pre-commit/pre-commit\n[pypi-version-image]: https://img.shields.io/pypi/v/chatgpt-pre-commit-hooks?style=flat-square\n[pypi-version-link]: https://pypi.org/project/chatgpt-pre-commit-hooks\n[pypi-pyversions-image]: https://img.shields.io/pypi/pyversions/chatgpt-pre-commit-hooks?style=flat-square\n[pypi-pyversions-link]: https://pypi.org/project/chatgpt-pre-commit-hooks\n[pypi-stats-image]: https://img.shields.io/pypi/dm/chatgpt-pre-commit-hooks?style=flat-square\n[pypi-stats-link]: https://pypistats.org/packages/chatgpt-pre-commit-hooks\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Pre-commit hooks collection that utilizes ChatGPT and OpenAI platform to validate modifications made to the codebase.",
    "version": "0.1.3",
    "split_keywords": [
        "chatgpt",
        "openai",
        "pre-commit",
        "pre-commit-hooks",
        "pre-commit-hook"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0d1d29896f9de0e71b2179dfb4a3805e6866aa31b82a147a2d677cfc7e866b72",
                "md5": "1544080b2ae78844e37a6b37f8ddca6a",
                "sha256": "8a62f018e622196e00fcb80ddc2d1836b977fe957e61f06bbee0dee4098c8e13"
            },
            "downloads": -1,
            "filename": "chatgpt_pre_commit_hooks-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1544080b2ae78844e37a6b37f8ddca6a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 13581,
            "upload_time": "2023-04-23T06:13:33",
            "upload_time_iso_8601": "2023-04-23T06:13:33.823341Z",
            "url": "https://files.pythonhosted.org/packages/0d/1d/29896f9de0e71b2179dfb4a3805e6866aa31b82a147a2d677cfc7e866b72/chatgpt_pre_commit_hooks-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-23 06:13:33",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "chatgpt-pre-commit-hooks"
}
        
Elapsed time: 0.05985s