Skip to content

Commit 3619c56

Browse files
bump
1 parent 348515a commit 3619c56

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

index.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,21 @@ const gptCommit = async () => {
3939
console.log('No changes to commit. Commit canceled.');
4040
process.exit(0);
4141
}
42-
const prompt = `Generate a Git commit message based on the following summary: ${gitSummary}
43-
\n\nThe Commit message must wrap with double quote like this "your commit message"
44-
\n\nCommit message: `;
45-
console.log(model)
42+
43+
const messages = [
44+
{role: "system", content: "You are a helpful assistant."},
45+
{role: "user", content: `Generate a Git commit message based on the following summary: ${gitSummary}`}
46+
];
47+
4648
const parameters = {
4749
model,
48-
prompt,
49-
temperature: 0,
50+
messages,
5051
max_tokens: 50,
51-
n: 1,
52-
stop: null,
5352
};
5453

55-
const response = await openai.completions.create(parameters);
54+
const response = await openai.chat.completions.create(parameters);
5655

57-
const message = response.data.choices[0].text.trim();
56+
const message = response.data.choices[0].message.content.trim();
5857

5958
const confirm = await prompts({
6059
type: "confirm",
@@ -64,7 +63,7 @@ const gptCommit = async () => {
6463
});
6564

6665
if (confirm.value) {
67-
execSync(`git commit -m ${message}`);
66+
execSync(`git commit -m "${message}"`);
6867
console.log("Committed with the suggested message.");
6968
} else {
7069
console.log("Commit canceled.");

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@laststance/git-gpt-commit",
3-
"version": "0.7.0-beta03",
3+
"version": "0.7.0-beta04",
44
"description": "An AI-powered Git extension that generates commit messages using OpenAI's GPT-3, streamlining the commit process and improving developer productivity.",
55
"main": "index.js",
66
"type": "module",

0 commit comments

Comments
 (0)