Make your commit messages extremely catchy.
Project description
clickbait-commit-messages
Make your commit messages extremely catchy.
Prerequisites
Get yourself a Hugging Face access token if you haven't got one already. To do so, go to https://huggingface.co/settings/tokens and create a new token.
How to use
This tool is meant to be used in conjunction with pre-commit. In order to use it, you should:
- Install
clickbait-commit-messages
:pip install clickbait-commit-messages
- Add the following entry to your
.pre-commit-config.yaml
file:default_install_hook_types: [pre-commit, prepare-commit-msg] repos: - repo: local hooks: - id: make-clickbaity name: make-clickbaity entry: make-clickbaity language: python stages: [prepare-commit-msg]
Please note a couple of things:default_install_hook_types: [pre-commit, prepare-commit-msg]
tells pre-commit to install themake-clickbaity
git hook at a different stage than the default one (which ispre-commit
). If you omit this line,pre-commit
will not install this hook to run during theprepare-commit-msg
stage (i.e. after the commit is done but before the commit message is confirmed), which is indeed the only stage this hook is meant to run at (that's why we setstages: [prepare-commit-msg]
by the way)- Rather than specifying the repo URL in the
repo
field, you must put "local". This is because in order to run properly, this hook has to have access to your local environment. In particular, it needs to be able to access theHF_TOKEN
environment variable (see step 3)
- Run
pre-commit install
to install the hook - Run
export HF_TOKEN=hf_**********************************
(replace with your Hugging Face access token). This is needed as the hook needs to call the Hugging Face API to generate clickbait commit messages. If you'd rather avoid doing this every time, add that line to your~/.bashrc
(or equivalents for other shells)
Configuration options
The behavior of this hook can be customized using the following configuration options:
-
--model-name
: The Hugging Face model to use for generating the clickbaity message. Defaults tomistralai/Mixtral-8x7B-Instruct-v0.1
-
--style
: The style of clickbait to generate. Supported values:youtube
(akin to a catchy title of a YouTube video),news
(akin to a clickbaity title of a news article). Defaults tonews
-
--template
: The template to use for the chat prompt. Different models may require different chat templates. For example, Mistral/Mixtral models require this template:<s>[INST]{prompt}[/INST]
. Defaults toNone
(see--template-style
)NOTE: it is important that in the chat template you pass here, the actual prompt is abstracted away with the literal string
{prompt}
(as shown above) -
--template-style
: The style of template to use for the chat prompt, selected among a pre-defined set. Supported values:mistral
. This argument is meant to be used in a mutually exclusive way with--template
, meaning you should pass one or the other but not both. Defaults tomistral
, which corresponds to the chat template exemplified above -
--use-emojis
: Use emojis in the clickbaity message
As an example, here's how you would specify a custom configuration:
hooks:
- id: make-clickbaity
entry: make-clickbaity
args: [
"--model-name", "mistralai/Mixtral-8x7B-Instruct-v0.1",
"--style", "news",
"--template-style", "mistral",
"--use-emojis"
]
Things to keep in mind
-
Some Hugging Face models, such as
mistralai/Mixtral-8x7B-Instruct-v0.1
, are gated, meaning that you need to explicitly request access to them before you can use them via the API. To do that, visit the home page of the model in Hugging Face and follow the instructions to request access to it -
Some models, such as
meta-llama/Meta-Llama-3-8B-Instruct
, may not be usable on the free tier of the API. When trying to use them to generate a clickbait commit message, you might get an HTTP 403 error along the lines of:{"error":"The model meta-llama/Meta-Llama-3-8B-Instruct is too large to be loaded automatically (16GB > 10GB). Please use Spaces (https://huggingface.co/spaces) or Inference Endpoints (https://huggingface.co/inference-endpoints)."}
In order to probe whether a model will be usable or not, you can shoot a cURL request like the following and check the response (replace
${MODEL_NAME}
and${API_TOKEN}
appropriately):curl https://api-inference.huggingface.co/models/${MODEL_NAME} \ -X POST \ -d '{"inputs": "Some dummy prompt, the format and content are not important"}' \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${API_TOKEN}"
If you receive an error message like the one showed above, then it means you can't use that model on your current API tier. Otherwise, you're good to go 👍
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for clickbait_commit_messages-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe68eaf73e3019cb5027d86753f8a3b1813d260be477c5188c79ffe56ab465ee |
|
MD5 | ca68655611b55924063ddc4610373293 |
|
BLAKE2b-256 | 01cf7b80dd13ad4bfa2297cf9820de72cc92673e60d33ce5943b84ab6e7f1ffd |
Hashes for clickbait_commit_messages-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5488baab71ed84c4814296c2728be7bdf54ac1c0f03e7ea8cf39ffa04c7e5de |
|
MD5 | eb803c1c2b3c0a1fc24ab4a261a8082b |
|
BLAKE2b-256 | 1dcdcae8624180bebab8e00a1a8c59e87d6651b5b8ff41bd243fe631e876cfe6 |