Skip to content

Commit 3e6b7d0

Browse files
committed
chore(llm): update prompt generation logic
- Add main prompt for generating a conventional commit message - Include specific instructions for the commit message format - Ensure all instructions are clearly outlined in the prompt [Therapy notes by Kommitment - github.com/cowboy-bebug/kommitment]
1 parent 14916f0 commit 3e6b7d0

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

internal/llm/openai.go

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,26 +113,38 @@ func chatStructured[T any](model, prompt string, schema openai.ResponseFormatJSO
113113
}
114114

115115
func GenerateCommitMessage(model, context, diff string) (string, error) {
116+
// main prompt
117+
prompt := "Generate a conventional commit message"
118+
116119
// constraints
117-
prompt := "Without wrapping in a code block"
118-
prompt += ", without using build as scope"
119-
prompt += ", without suggesting `feat` for build scripts"
120-
prompt += ", and without suggesting comments or remarks"
120+
prompt += ", without:\n"
121+
prompt += "- wrapping in a code block\n"
122+
prompt += "- using build as scope\n"
123+
prompt += "- suggesting `feat` for build scripts\n"
124+
prompt += "- suggesting comments or remarks\n"
121125

122-
// main prompt
123-
prompt += ", can you generate a conventional commit message"
126+
// type
127+
prompt += "\nUsing conventional commit types:\n"
128+
prompt += "- with type in lowercase\n"
129+
prompt += "- using chore for maintenance commits\n"
124130

125131
// scope
126-
prompt += ", with lowercase scope"
132+
prompt += "\nUsing conventional commit scopes:\n"
133+
prompt += "- in lowercase\n"
134+
135+
// subject
136+
prompt += "\nUsing conventional commit message subject:\n"
137+
prompt += "- in lowercase\n"
127138

128139
// message body
129-
prompt += ", with message body as bullet points for the changes"
130-
prompt += ", using the imperative mood (present tense), rather than past tense"
131-
prompt += ", using titlecase for the first letter of the message body"
132-
prompt += ", and breaking lines at 72 characters"
140+
prompt += "\nUsing conventional commit message body:\n"
141+
prompt += "- as bullet points for the changes\n"
142+
prompt += "- using the imperative mood (present tense)\n"
143+
prompt += "- using titlecase for the first letter of the message body\n"
144+
prompt += "- breaking lines at 72 characters\n"
133145

134146
// context and diff
135-
prompt += ", based on the following context and diff:\n"
147+
prompt += "\nBased on the following context and diff:\n"
136148
prompt += fmt.Sprintf("Here is context: %s\n", context)
137149
prompt += fmt.Sprintf("Here is the Git diff:\n%s\n", diff)
138150

0 commit comments

Comments
 (0)