Skip to content

Commit aca4df8

Browse files
authored
api: improve commit message generation (#33)
* api: adjust default temperature parameter * Lower default temperature from 0.5 to 0.3 for more focused responses Signed-off-by: Qiming Chu <[email protected]> * api: improve commit message generation prompt * Add more detailed instructions for commit message format * Specify code block requirement for output * Clarify content restrictions for generated messages Signed-off-by: Qiming Chu <[email protected]> --------- Signed-off-by: Qiming Chu <[email protected]>
1 parent f8c2e55 commit aca4df8

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/api.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ fn build_request(
5656
// Prompt
5757
let format_instruction = config.format.get_prompt();
5858
let mut prompt = format!(
59-
"Please write a commit message for the following changes:\n\n{}\n\n{}",
59+
"Please ensure that the commit message is relevant to the changes made in the diff, \
60+
please write a commit message for the following changes:\n\n{}\n\n{}",
6061
format_instruction, diff
6162
);
6263

@@ -80,15 +81,26 @@ fn build_request(
8081
messages: vec![
8182
Message {
8283
role: "system".to_string(),
83-
content: "You are a Git commit message assistant. Your task is to generate concise and clear commit messages based on the provided Git diff.".to_string(),
84+
content: [
85+
"You are a Git commit message assistant. ",
86+
"Your task is to generate concise and clear commit messages based on the provided Git diff, ",
87+
"please put the generated content in a code block for easy copying. ",
88+
"please follow the format of the commit message: ",
89+
"{component}: {description} ",
90+
"* {first long description} ",
91+
"* {second long description} ",
92+
"* {maybe more long description} ",
93+
"You can also add some additional description if necessary, ",
94+
"but do not add any additional content outside the code block. ",
95+
].join("").to_string(),
8496
},
8597
Message {
8698
role: "user".to_string(),
8799
content: prompt,
88100
},
89101
],
90102
stream: true,
91-
temperature: 0.5,
103+
temperature: 0.3,
92104
}
93105
}
94106

0 commit comments

Comments
 (0)