This commit is contained in:
di-sukharev
2023-05-20 12:38:35 +08:00
parent 17802dcbd6
commit 211ad20c34
2 changed files with 7 additions and 7 deletions

View File

@@ -27936,10 +27936,10 @@ async function improveCommitMessagesWithRebase(commits) {
(commit) => generateCommitMessageByDiff(commit.diff)
);
let improvedMessagesBySha = {};
const step = 3;
for (let i2 = 0; i2 < improvePromises.length; i2 + step) {
const chunkSize = improvePromises.length % 2 === 0 ? 2 : 3;
for (let i2 = 0; i2 < improvePromises.length; i2 += chunkSize) {
console.log({ i: i2, improvedMessagesBySha });
const promises = improvePromises.slice(i2, step);
const promises = improvePromises.slice(i2, i2 + chunkSize);
await Promise.all(promises).then((results) => {
return results.reduce((acc, improvedMsg, i3) => {
acc[commitDiffs[i3].sha] = improvedMsg;

View File

@@ -72,11 +72,11 @@ async function improveCommitMessagesWithRebase(commits: CommitsArray) {
);
let improvedMessagesBySha: MessageBySha = {};
// send batches of 3 diffs in parallel, because openAI restricts too many requests at once with 429 error
const step = 3;
for (let i = 0; i < improvePromises.length; i + step) {
// send chunks of 3 diffs in parallel, because openAI restricts too many requests at once with 429 error
const chunkSize = improvePromises.length % 2 === 0 ? 2 : 3;
for (let i = 0; i < improvePromises.length; i += chunkSize) {
console.log({ i, improvedMessagesBySha });
const promises = improvePromises.slice(i, step);
const promises = improvePromises.slice(i, i + chunkSize);
await Promise.all(promises)
.then((results) => {
return results.reduce((acc, improvedMsg, i) => {