git-aicommit 7.7.0 → 8.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -36,10 +36,9 @@ touch $HOME/.git-aicommitrc
36
36
  // $HOME/.git-aicommitrc
37
37
  export default {
38
38
  openAiKey: process.env.OPENAI_API_KEY,
39
- azureOpenAiKey: process.env.AZURE_OPENAI_API_KEY,
40
- azureOpenAiInstanceName: process.env.AZURE_OPENAI_API_INSTANCE_NAME,
41
- azureOpenAiDeploymentName: process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME,
42
- azureOpenAiVersion: process.env.AZURE_OPENAI_API_VERSION,
39
+ baseURL: process.env.OPENAI_BASE_URL || null,
40
+ defaultHeaders: null,
41
+ defaultQuery: null,
43
42
  autocommit: true,
44
43
  openCommitTextEditor: false,
45
44
  language: 'english',
@@ -107,4 +106,27 @@ alias gai="git add --all && git-aicommit && git push"
107
106
  gai
108
107
  ```
109
108
 
109
+ ## Azure OpenAI Integration
110
+
111
+ To use Azure OpenAI instead of the official OpenAI API, set the following environment variables:
112
+
113
+ ```bash
114
+ export OPENAI_API_KEY="your-azure-api-key"
115
+ export OPENAI_BASE_URL="https://<your-instance>.openai.azure.com/openai/deployments/<your-deployment>"
116
+ export OPENAI_DEFAULT_HEADERS='{"api-key": "your-azure-api-key"}'
117
+ export OPENAI_DEFAULT_QUERY='{"api-version": "2024-02-15-preview"}'
118
+ ```
119
+
120
+ Or add them to your config file:
121
+
122
+ ```js
123
+ // $HOME/.git-aicommitrc
124
+ export default {
125
+ openAiKey: process.env.AZURE_OPENAI_API_KEY,
126
+ baseURL: process.env.AZURE_OPENAI_BASE_URL,
127
+ defaultHeaders: { 'api-key': process.env.AZURE_OPENAI_API_KEY },
128
+ defaultQuery: { 'api-version': '2024-02-15-preview' },
129
+ }
130
+ ```
131
+
110
132
  It's that simple!
package/autocommit.js CHANGED
@@ -11,7 +11,9 @@ const config = rc(
11
11
  {
12
12
  ...defaultConfig,
13
13
  openAiKey: process.env.OPENAI_API_KEY,
14
- azureOpenAIApiKey: process.env.AZURE_OPENAI_API_KEY
14
+ baseURL: process.env.OPENAI_BASE_URL,
15
+ defaultHeaders: process.env.OPENAI_DEFAULT_HEADERS ? JSON.parse(process.env.OPENAI_DEFAULT_HEADERS) : null,
16
+ defaultQuery: process.env.OPENAI_DEFAULT_QUERY ? JSON.parse(process.env.OPENAI_DEFAULT_QUERY) : null,
15
17
  },
16
18
  );
17
19
 
@@ -31,16 +33,8 @@ try {
31
33
  // Get current git branch name
32
34
  const branch = execSync('git rev-parse --abbrev-ref HEAD', {encoding: 'utf8'}).trim();
33
35
 
34
- if (!config.openAiKey && !config.azureOpenAiKey) {
35
- console.error("Please set OPENAI_API_KEY or AZURE_OPENAI_API_KEY");
36
- process.exit(1);
37
- }
38
-
39
- // if any settings related to AZURE are set, if there are items that are not set, will error.
40
- if (config.azureOpenAiKey && !(
41
- config.azureOpenAiInstanceName && config.azureOpenAiDeploymentName && config.azureOpenAiVersion
42
- )){
43
- console.error("Please set AZURE_OPENAI_API_KEY, AZURE_OPENAI_API_INSTANCE_NAME, AZURE_OPENAI_API_DEPLOYMENT_NAME, AZURE_OPENAI_API_VERSION when Azure OpenAI Service.");
36
+ if (!config.openAiKey) {
37
+ console.error("Please set OPENAI_API_KEY");
44
38
  process.exit(1);
45
39
  }
46
40
 
@@ -63,9 +57,9 @@ if (!diff) {
63
57
 
64
58
  const openai = new OpenAI({
65
59
  apiKey: config.openAiKey,
66
- baseURL: config.azureOpenAiKey ? `https://${config.azureOpenAiInstanceName}.openai.azure.com/openai/deployments/${config.azureOpenAiDeploymentName}` : undefined,
67
- defaultHeaders: config.azureOpenAiKey ? { 'api-key': config.azureOpenAiKey } : undefined,
68
- defaultQuery: config.azureOpenAiKey ? { 'api-version': config.azureOpenAiVersion } : undefined, // defaultQuery for api-version as per OpenAI SDK v4+ for Azure
60
+ baseURL: config.baseURL || undefined,
61
+ defaultHeaders: config.defaultHeaders || undefined,
62
+ defaultQuery: config.defaultQuery || undefined,
69
63
  });
70
64
 
71
65
  async function getChatCompletion(messages) {
package/config.js CHANGED
@@ -1,9 +1,8 @@
1
1
  export default {
2
2
  openAiKey: process.env.OPENAI_API_KEY,
3
- azureOpenAiKey: process.env.AZURE_OPENAI_API_KEY,
4
- azureOpenAiInstanceName: process.env.AZURE_OPENAI_API_INSTANCE_NAME,
5
- azureOpenAiDeploymentName: process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME,
6
- azureOpenAiVersion: process.env.AZURE_OPENAI_API_VERSION,
3
+ baseURL: process.env.OPENAI_BASE_URL || null,
4
+ defaultHeaders: null,
5
+ defaultQuery: null,
7
6
  autocommit: true,
8
7
  openCommitTextEditor: false,
9
8
  language: 'english',
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "git-aicommit",
3
- "version": "7.7.0",
3
+ "version": "8.0.3",
4
4
  "description": "Generates auto commit messages with OpenAI models",
5
5
  "main": "autocommit.js",
6
- "repository": "https://github.com/shanginn/autocommit",
6
+ "repository": "https://github.com/shanginn/git-aicommit",
7
7
  "author": "shanginn@gmail.com",
8
8
  "license": "MIT",
9
9
  "type": "module",