Skip to content

Commit

Permalink
コミットメッセージ生成数を5件にした
Browse files Browse the repository at this point in the history
  • Loading branch information
soramimi committed Jun 4, 2024
1 parent ae47eb8 commit e2b65eb
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/CommitMessageGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,16 @@ QStringList CommitMessageGenerator::generate(GitPtr g)
std::string model = global->appsettings.openai_gpt_model.toStdString();
if (model.empty()) model = "gpt-4o";

std::string prompt = // Referring to https://github.com/Nutlope/aicommits
constexpr int max = 5;

// Referring to https://github.com/Nutlope/aicommits
std::string prompt = strformat(
"Generate a concise git commit message written in present tense for the following code diff with the given specifications below. "
"Exclude anything unnecessary such as translation. "
"Your entire response will be passed directly into git commit. "
"Please generate 3 messages, bulleted, and start writing with '-'. "
"Please generate %d messages, bulleted, and start writing with '-'. ")(max);
;
prompt = prompt + "\n\n" + diff.toStdString();
qDebug() << diff.size();

std::string json = R"---({
"model": "%s",
Expand Down Expand Up @@ -203,8 +205,8 @@ QStringList CommitMessageGenerator::generate(GitPtr g)
std::string text(data, size);
auto list = parse_openai_response(text);
QStringList out;
for (std::string const &line : list) {
out.push_back(QString::fromStdString(line));
for (int i = 0; i < max && i < list.size(); i++) {
out.push_back(QString::fromStdString(list[i]));
}
return out;
}
Expand Down

0 comments on commit e2b65eb

Please sign in to comment.