From b6f90afe06addb15b162e59fab807f275d0793dc Mon Sep 17 00:00:00 2001 From: sfwn Date: Thu, 18 Jan 2024 11:37:08 +0800 Subject: [PATCH] fix: add content truncated flag to file code-review prompt (#6241) --- internal/tools/gittar/ai/cr/impl/cr_mr_file/file.go | 2 ++ internal/tools/gittar/ai/cr/impl/cr_mr_file/prompt.yaml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/tools/gittar/ai/cr/impl/cr_mr_file/file.go b/internal/tools/gittar/ai/cr/impl/cr_mr_file/file.go index 594cd2ad7a5..95939ca8cc6 100644 --- a/internal/tools/gittar/ai/cr/impl/cr_mr_file/file.go +++ b/internal/tools/gittar/ai/cr/impl/cr_mr_file/file.go @@ -132,11 +132,13 @@ func (r *OneChangedFile) constructAIRequest(i18n i18n.Translator, lang i18n.Lang FileName string FileContent string UserLang string + Truncated bool } tmplArgs.CodeLanguage = r.CodeLanguage tmplArgs.FileName = r.FileName tmplArgs.FileContent = r.FileContent tmplArgs.UserLang = i18nutil.GetUserLang(lang) + tmplArgs.Truncated = r.Truncated for i := range req.Messages { t, _ := template.New("").Parse(req.Messages[i].Content) diff --git a/internal/tools/gittar/ai/cr/impl/cr_mr_file/prompt.yaml b/internal/tools/gittar/ai/cr/impl/cr_mr_file/prompt.yaml index 1b494090f9a..ef5d744be1b 100644 --- a/internal/tools/gittar/ai/cr/impl/cr_mr_file/prompt.yaml +++ b/internal/tools/gittar/ai/cr/impl/cr_mr_file/prompt.yaml @@ -5,7 +5,7 @@ messages: - role: system content: | You are an expert Software Engineer. - Below is a file, please help me do a brief code review on it (don't print file name and file content in your review). + Below is a file (content truncated: {{.Truncated}}), please help me do a brief code review on it (don't print file name and file content in your review). Please summarize the code and identify potential problems (at most 5). Start with the most important findings. File `{{.FileName}}`: