feat: add token for branch_name in custom prompts

This commit is contained in:
ndom91 2024-10-17 21:23:53 +02:00 committed by Nico Domino
parent 97937e242f
commit 99ada05663
2 changed files with 9 additions and 2 deletions

View File

@ -58,6 +58,7 @@ interface SummarizeCommitOpts extends BaseAIServiceOpts {
useEmojiStyle?: boolean;
useBriefStyle?: boolean;
commitTemplate?: Prompt;
branchName?: string;
}
interface SummarizeBranchOpts extends BaseAIServiceOpts {
@ -267,7 +268,8 @@ export class AIService {
useEmojiStyle = false,
useBriefStyle = false,
commitTemplate,
onToken
onToken,
branchName
}: SummarizeCommitOpts): Promise<Result<string, Error>> {
const aiClientResult = await this.buildClient();
if (isFailure(aiClientResult)) return aiClientResult;
@ -293,6 +295,10 @@ export class AIService {
: "Don't use any emoji.";
content = content.replaceAll('%{emoji_style}', emojiPart);
if (branchName) {
content = content.replaceAll('%{branch_name}', branchName);
}
return {
role: MessageRole.User,
content

View File

@ -89,7 +89,8 @@
hunks,
useEmojiStyle: $commitGenerationUseEmojis,
useBriefStyle: $commitGenerationExtraConcise,
commitTemplate: prompt
commitTemplate: prompt,
branchName: $branch.name
});
if (isFailure(generatedMessageResult)) {