Skip to content

Commit 72c1096

Browse files
author
Chris
committed
updated transactional and prompt messages
1 parent 59a1be8 commit 72c1096

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

gitcommit.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,31 @@ func main() {
2727

2828
for {
2929
// Generate the commit message
30-
prompt := fmt.Sprintf("Generate a commit message for the following changes:\n%s", diff)
30+
prompt := fmt.Sprintf("Generate a git commit message for the following changes:\n%s", diff)
3131

3232
generatedText, err := generateCommitMessage(prompt, modelEngine, openaiAPIKey)
3333
if err != nil {
3434
log.Fatal("Failed to generate commit message:", err)
3535
}
3636

3737
// Modify the commit message and present it to the user
38-
message := generatedText[len("Commit message"):]
38+
message := generatedText
3939

40-
fmt.Printf("Generated commit message:\n%s\n", message)
41-
userInput := getUserInput("Accept commit message? (y/n/e): ")
40+
fmt.Printf("Suggested commit message:\n%s\n", message)
41+
userInput := getUserInput("Accept this generated commit message? (y/n/e): ")
4242

4343
// Commit the changes or regenerate the message
4444
if userInput == "y" {
4545
commitChanges(message)
4646
fmt.Println("Changes committed!")
4747
break
4848
} else if userInput == "e" {
49-
editedText := getUserInput("Enter edited commit message: ")
49+
editedText := getUserInput("Enter your commit message: ")
5050
commitChanges(editedText)
5151
fmt.Println("Changes committed!")
5252
break
5353
} else {
54-
fmt.Println("Regenerating commit message...")
54+
fmt.Println("Please wait...Regenerating commit message...")
5555
}
5656
}
5757
}
@@ -74,7 +74,7 @@ func generateCommitMessage(prompt, modelEngine, openaiAPIKey string) (string, er
7474
"model": modelEngine,
7575
"prompt": prompt,
7676
"max_tokens": 50, // Adjust the max tokens and other parameters as needed
77-
"temperature": 0.5, // Adjust the temperature value as needed
77+
"temperature": 0, // Adjust the temperature value as needed
7878
}).
7979
SetResult(&OpenAIResponse{}).
8080
Post("https://api.openai.com/v1/completions")
@@ -89,11 +89,11 @@ func generateCommitMessage(prompt, modelEngine, openaiAPIKey string) (string, er
8989

9090
openAIResp, ok := resp.Result().(*OpenAIResponse)
9191
if !ok {
92-
return "", fmt.Errorf("Unable to access the desired fields from resp.Result()")
92+
return "", fmt.Errorf("Unable to retrieve commit message from Open API")
9393
}
9494

9595
if len(openAIResp.Choices) == 0 {
96-
return "", fmt.Errorf("No choices returned in the response")
96+
return "", fmt.Errorf("No commit messages could be generated")
9797
}
9898

9999
return openAIResp.Choices[0].Text, nil

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy