git-aicommit 5.0.0 → 5.2.0
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/autocommit.js +20 -5
- package/config.js +4 -1
- package/package.json +3 -3
package/autocommit.js
CHANGED
|
@@ -20,6 +20,7 @@ const config = rc(
|
|
|
20
20
|
{
|
|
21
21
|
...defaultConfig,
|
|
22
22
|
openAiKey: process.env.OPENAI_API_KEY,
|
|
23
|
+
azureOpenAIApiKey: process.env.AZURE_OPENAI_API_KEY
|
|
23
24
|
},
|
|
24
25
|
);
|
|
25
26
|
|
|
@@ -33,8 +34,16 @@ try {
|
|
|
33
34
|
process.exit(1);
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
if (!config.openAiKey) {
|
|
37
|
-
console.error("Please set OPENAI_API_KEY");
|
|
37
|
+
if (!config.openAiKey && !config.azureOpenAiKey) {
|
|
38
|
+
console.error("Please set OPENAI_API_KEY or AZURE_OPENAI_API_KEY");
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// if any settings related to AZURE are set, if there are items that are not set, will error.
|
|
43
|
+
if (config.azureOpenAiKey && !(
|
|
44
|
+
config.azureOpenAiInstanceName && config.azureOpenAiDeploymentName && config.azureOpenAiVersion
|
|
45
|
+
)){
|
|
46
|
+
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.");
|
|
38
47
|
process.exit(1);
|
|
39
48
|
}
|
|
40
49
|
|
|
@@ -43,9 +52,9 @@ const diffFilter = config.diffFilter || 'ACMRTUXB';
|
|
|
43
52
|
const diffCommand = `git diff --staged \
|
|
44
53
|
--no-ext-diff \
|
|
45
54
|
--diff-filter=${diffFilter} \
|
|
46
|
-
--
|
|
47
|
-
(pattern) =>
|
|
48
|
-
).join(' ')}
|
|
55
|
+
-- ${excludeFromDiff.map(
|
|
56
|
+
(pattern) => `':(exclude)${pattern}'`
|
|
57
|
+
).join(' ')}
|
|
49
58
|
`;
|
|
50
59
|
|
|
51
60
|
let diff = execSync(diffCommand, {encoding: 'utf8'});
|
|
@@ -58,6 +67,10 @@ if (!diff) {
|
|
|
58
67
|
const openai = new ChatOpenAI({
|
|
59
68
|
modelName: config.modelName,
|
|
60
69
|
openAIApiKey: config.openAiKey,
|
|
70
|
+
azureOpenAIApiKey: config.azureOpenAiKey,
|
|
71
|
+
azureOpenAIApiInstanceName: config.azureOpenAiInstanceName,
|
|
72
|
+
azureOpenAIApiDeploymentName: config.azureOpenAiDeploymentName,
|
|
73
|
+
azureOpenAIApiVersion: config.azureOpenAiVersion,
|
|
61
74
|
temperature: config.temperature,
|
|
62
75
|
maxTokens: config.maxTokens,
|
|
63
76
|
});
|
|
@@ -76,6 +89,7 @@ const chatPrompt = ChatPromptTemplate.fromPromptMessages([
|
|
|
76
89
|
]);
|
|
77
90
|
|
|
78
91
|
if (diff.length > 2000) {
|
|
92
|
+
console.log('Diff is too long. Splitting into multiple requests.')
|
|
79
93
|
const filenameRegex = /^a\/(.+?)\s+b\/(.+?)/;
|
|
80
94
|
const diffByFiles = diff
|
|
81
95
|
.split('diff ' + '--git ') // Wierd string concat in order to avoid splitting on this line when using autocommit in this repo :)
|
|
@@ -94,6 +108,7 @@ if (diff.length > 2000) {
|
|
|
94
108
|
language: config.language,
|
|
95
109
|
})
|
|
96
110
|
.then((prompt) => {
|
|
111
|
+
console.log(prompt)
|
|
97
112
|
return openai.call(prompt)
|
|
98
113
|
.then((res) => {
|
|
99
114
|
return {
|
package/config.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
openAiKey: process.env.OPENAI_API_KEY,
|
|
3
|
-
|
|
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,
|
|
4
7
|
autocommit: true,
|
|
5
8
|
openCommitTextEditor: false,
|
|
6
9
|
language: 'english',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "git-aicommit",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "Generates auto commit messages with OpenAI GPT3 model",
|
|
5
5
|
"main": "autocommit.js",
|
|
6
6
|
"repository": "https://github.com/shanginn/autocommit",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@dqbd/tiktoken": "^1.0.
|
|
12
|
-
"langchain": "^0.0.
|
|
11
|
+
"@dqbd/tiktoken": "^1.0.7",
|
|
12
|
+
"langchain": "^0.0.75",
|
|
13
13
|
"openai": "^3.2.1",
|
|
14
14
|
"rc": "^1.2.8"
|
|
15
15
|
},
|