mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-04-20 03:02:51 -04:00
* 🐛 fix(api.ts): return message content instead of whole response object
* 🚀 chore(generateCommitMessageFromGitDiff.ts): filter out null promises and update TODO comment * 🚀 chore(tsconfig.json): update target to ES2020 and remove ES5 from lib
This commit is contained in:
@@ -92,17 +92,18 @@ export const generateCommitMessageWithChatCompletion = async (
|
||||
|
||||
const diffByFiles = diff.split(separator).slice(1);
|
||||
|
||||
const commitMessagePromises = diffByFiles.map((fileDiff) => {
|
||||
// TODO: split by files
|
||||
if (INIT_MESSAGES_PROMPT_LENGTH + fileDiff.length >= MAX_REQ_TOKENS)
|
||||
return null;
|
||||
const commitMessagePromises = diffByFiles
|
||||
.map((fileDiff) => {
|
||||
// TODO: split by files
|
||||
if (fileDiff.length >= MAX_REQ_TOKENS) return null;
|
||||
|
||||
const messages = generateCommitMessageChatCompletionPrompt(
|
||||
separator + fileDiff
|
||||
);
|
||||
const messages = generateCommitMessageChatCompletionPrompt(
|
||||
separator + fileDiff
|
||||
);
|
||||
|
||||
return api.generateCommitMessage(messages);
|
||||
});
|
||||
return api.generateCommitMessage(messages);
|
||||
})
|
||||
.filter(Boolean);
|
||||
|
||||
const commitMessages = await Promise.all(commitMessagePromises);
|
||||
|
||||
@@ -116,7 +117,7 @@ export const generateCommitMessageWithChatCompletion = async (
|
||||
if (!commitMessage)
|
||||
return { error: GenerateCommitMessageErrorEnum.emptyMessage };
|
||||
|
||||
return commitMessage.content;
|
||||
return commitMessage;
|
||||
} catch (error) {
|
||||
return { error: GenerateCommitMessageErrorEnum.internalError };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user