Skip to content

Commit f975e49

Browse files
authored
refactoring v2 (#408)
1 parent fa1cf46 commit f975e49

21 files changed

+682
-596
lines changed

README.md

+22-37
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,19 @@ You can use OpenCommit by simply running it via the CLI like this `oco`. 2 secon
2828
npm install -g opencommit
2929
```
3030

31-
Alternatively run it via `npx opencommit` or `bunx opencommit`
32-
33-
MacOS may ask to run the command with `sudo` when installing a package globally.
34-
35-
2. Get your API key from [OpenAI](https://platform.openai.com/account/api-keys). Make sure that you add your payment details, so the API works.
31+
2. Get your API key from [OpenAI](https://platform.openai.com/account/api-keys) or other supported LLM providers (we support them all). Make sure that you add your OpenAI payment details to your account, so the API works.
3632

3733
3. Set the key to OpenCommit config:
3834

3935
```sh
40-
oco config set OCO_OPENAI_API_KEY=<your_api_key>
36+
oco config set OCO_API_KEY=<your_api_key>
4137
```
4238

4339
Your API key is stored locally in the `~/.opencommit` config file.
4440

4541
## Usage
4642

47-
You can call OpenCommit directly to generate a commit message for your staged changes:
48-
49-
```sh
50-
git add <files...>
51-
opencommit
52-
```
53-
54-
You can also use the `oco` shortcut:
43+
You can call OpenCommit with `oco` command to generate a commit message for your staged changes:
5544

5645
```sh
5746
git add <files...>
@@ -70,22 +59,17 @@ You can also run it with local model through ollama:
7059

7160
```sh
7261
git add <files...>
73-
oco config set OCO_AI_PROVIDER='ollama'
62+
oco config set OCO_AI_PROVIDER='ollama' OCO_MODEL='llama3:8b'
7463
```
7564

76-
If you want to use a model other than mistral (default), you can do so by setting the `OCO_AI_PROVIDER` environment variable as follows:
77-
78-
```sh
79-
oco config set OCO_AI_PROVIDER='ollama'
80-
oco config set OCO_MODEL='llama3:8b'
81-
```
65+
Default model is `mistral`.
8266

8367
If you have ollama that is set up in docker/ on another machine with GPUs (not locally), you can change the default endpoint url.
8468

85-
You can do so by setting the `OCO_OLLAMA_API_URL` environment variable as follows:
69+
You can do so by setting the `OCO_API_URL` environment variable as follows:
8670

8771
```sh
88-
oco config set OCO_OLLAMA_API_URL='http://192.168.1.10:11434/api/chat'
72+
oco config set OCO_API_URL='http://192.168.1.10:11434/api/chat'
8973
```
9074

9175
where 192.168.1.10 is example of endpoint URL, where you have ollama set up.
@@ -122,22 +106,21 @@ Create a `.env` file and add OpenCommit config variables there like this:
122106

123107
```env
124108
...
125-
OCO_OPENAI_API_KEY=<your OpenAI API token>
109+
OCO_AI_PROVIDER=<openai (default), anthropic, azure, ollama, gemini, flowise>
110+
OCO_API_KEY=<your OpenAI API token> // or other LLM provider API token
111+
OCO_API_URL=<may be used to set proxy path to OpenAI api>
126112
OCO_TOKENS_MAX_INPUT=<max model token limit (default: 4096)>
127113
OCO_TOKENS_MAX_OUTPUT=<max response tokens (default: 500)>
128-
OCO_OPENAI_BASE_PATH=<may be used to set proxy path to OpenAI api>
129114
OCO_DESCRIPTION=<postface a message with ~3 sentences description of the changes>
130115
OCO_EMOJI=<boolean, add GitMoji>
131116
OCO_MODEL=<either 'gpt-4o', 'gpt-4', 'gpt-4-turbo', 'gpt-3.5-turbo' (default), 'gpt-3.5-turbo-0125', 'gpt-4-1106-preview', 'gpt-4-turbo-preview' or 'gpt-4-0125-preview' or any Anthropic or Ollama model or any string basically, but it should be a valid model name>
132117
OCO_LANGUAGE=<locale, scroll to the bottom to see options>
133118
OCO_MESSAGE_TEMPLATE_PLACEHOLDER=<message template placeholder, default: '$msg'>
134119
OCO_PROMPT_MODULE=<either conventional-commit or @commitlint, default: conventional-commit>
135120
OCO_ONE_LINE_COMMIT=<one line commit message, default: false>
136-
OCO_AI_PROVIDER=<openai (default), anthropic, azure, ollama>
137-
...
138121
```
139122

140-
This are not all the config options, but you get the point.
123+
Global configs are same as local configs, but they are stored in the global `~/.opencommit` config file and set with `oco config set` command, e.g. `oco config set OCO_MODEL=gpt-4o`.
141124

142125
### Global config for all repos
143126

@@ -189,26 +172,26 @@ or for as a cheaper option:
189172
oco config set OCO_MODEL=gpt-3.5-turbo
190173
```
191174

192-
### Switch to Azure OpenAI
175+
### Switch to other LLM providers with a custom URL
193176

194177
By default OpenCommit uses [OpenAI](https://openai.com).
195178

196-
You could switch to [Azure OpenAI Service](https://learn.microsoft.com/azure/cognitive-services/openai/)🚀
179+
You could switch to [Azure OpenAI Service](https://learn.microsoft.com/azure/cognitive-services/openai/) or Flowise or Ollama.
197180

198181
```sh
199-
opencommit config set OCO_AI_PROVIDER=azure
200-
```
182+
oco config set OCO_AI_PROVIDER=azure OCO_API_KEY=<your_azure_api_key> OCO_API_URL=<your_azure_endpoint>
201183

202-
Of course need to set 'OCO_OPENAI_API_KEY'. And also need to set the
203-
'OPENAI_BASE_PATH' for the endpoint and set the deployment name to
204-
'model'.
184+
oco config set OCO_AI_PROVIDER=flowise OCO_API_KEY=<your_flowise_api_key> OCO_API_URL=<your_flowise_endpoint>
185+
186+
oco config set OCO_AI_PROVIDER=ollama OCO_API_KEY=<your_ollama_api_key> OCO_API_URL=<your_ollama_endpoint>
187+
```
205188

206189
### Locale configuration
207190

208191
To globally specify the language used to generate commit messages:
209192

210193
```sh
211-
# de, German ,Deutsch
194+
# de, German, Deutsch
212195
oco config set OCO_LANGUAGE=de
213196
oco config set OCO_LANGUAGE=German
214197
oco config set OCO_LANGUAGE=Deutsch
@@ -230,6 +213,8 @@ A prompt for pushing to git is on by default but if you would like to turn it of
230213
oco config set OCO_GITPUSH=false
231214
```
232215

216+
and it will exit right after commit is confirmed without asking if you would like to push to remote.
217+
233218
### Switch to `@commitlint`
234219

235220
OpenCommit allows you to choose the prompt module used to generate commit messages. By default, OpenCommit uses its conventional-commit message generator. However, you can switch to using the `@commitlint` prompt module if you prefer. This option lets you generate commit messages in respect with the local config.
@@ -404,7 +389,7 @@ jobs:
404389
# set openAI api key in repo actions secrets,
405390
# for openAI keys go to: https://platform.openai.com/account/api-keys
406391
# for repo secret go to: <your_repo_url>/settings/secrets/actions
407-
OCO_OPENAI_API_KEY: ${{ secrets.OCO_OPENAI_API_KEY }}
392+
OCO_API_KEY: ${{ secrets.OCO_API_KEY }}
408393
409394
# customization
410395
OCO_TOKENS_MAX_INPUT: 4096

0 commit comments

Comments
 (0)