diff --git a/ee/lib/gitlab/llm/chain/tools/summarize_comments/executor.rb b/ee/lib/gitlab/llm/chain/tools/summarize_comments/executor.rb index 3293807e5172896c2895694e51152da3c4716480..13d4d977b2b0fb1f85e690423d128c25458dbe1a 100644 --- a/ee/lib/gitlab/llm/chain/tools/summarize_comments/executor.rb +++ b/ee/lib/gitlab/llm/chain/tools/summarize_comments/executor.rb @@ -30,16 +30,16 @@ class Executor < Tool Utils::Prompt.as_system( <<~PROMPT You are an assistant that extracts the most important information from the comments in maximum 10 bullet points. - Comments are between two identical sets of 3-digit numbers surrounded by < > sign. + Each comment is wrapped in a <comment> tag. - <%<num>s> %<notes_content>s - <%<num>s> Desired markdown format: **<summary_title>** - <bullet_points> - """ + - <bullet_point> + - <bullet_point> + - <bullet_point> + - ... Focus on extracting information related to one another and that are the majority of the content. Ignore phrases that are not connected to others. @@ -57,7 +57,6 @@ def perform(&block) content = if notes.exists? notes_content = notes_to_summarize(notes) # rubocop: disable CodeReuse/ActiveRecord options[:notes_content] = notes_content - options[:num] = Random.rand(100..999) if options[:raw_ai_response] request(&block) @@ -87,7 +86,7 @@ def notes_to_summarize(notes) break notes_content if notes_content.size + note[1].size >= input_content_limit - notes_content << note[1] + notes_content << (format("<comment>%<note>s</comment>", note: note[1])) end end diff --git a/ee/spec/lib/gitlab/llm/chain/tools/summarize_comments/prompts/anthropic_spec.rb b/ee/spec/lib/gitlab/llm/chain/tools/summarize_comments/prompts/anthropic_spec.rb index 2613fe8b35986416b278b35b99724485d12c143c..092d4f8d139bb5bc9d5a3dff60bccce6efb7ec8b 100644 --- a/ee/spec/lib/gitlab/llm/chain/tools/summarize_comments/prompts/anthropic_spec.rb +++ b/ee/spec/lib/gitlab/llm/chain/tools/summarize_comments/prompts/anthropic_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Gitlab::Llm::Chain::Tools::SummarizeComments::Prompts::Anthropic, feature_category: :duo_chat do describe '.prompt' do it 'returns prompt' do - prompt = described_class.prompt({ notes_content: 'foo', num: 123 })[:prompt] + prompt = described_class.prompt({ notes_content: '<comment>foo</comment>' })[:prompt] expect(prompt).to include('Human:') expect(prompt).to include('Assistant:') @@ -13,16 +13,16 @@ expect(prompt).to include( <<~PROMPT You are an assistant that extracts the most important information from the comments in maximum 10 bullet points. - Comments are between two identical sets of 3-digit numbers surrounded by < > sign. + Each comment is wrapped in a <comment> tag. - <123> - foo - <123> + <comment>foo</comment> Desired markdown format: **<summary_title>** - <bullet_points> - """ + - <bullet_point> + - <bullet_point> + - <bullet_point> + - ... Focus on extracting information related to one another and that are the majority of the content. Ignore phrases that are not connected to others. diff --git a/ee/spec/lib/gitlab/llm/chain/tools/summarize_comments/prompts/vertex_ai_spec.rb b/ee/spec/lib/gitlab/llm/chain/tools/summarize_comments/prompts/vertex_ai_spec.rb index 32bef186e4bf5a9826e7d62c3a3cc4949bdfcf55..1033e17a1c1c99f5bd5df6f70b9c51793de5cf6e 100644 --- a/ee/spec/lib/gitlab/llm/chain/tools/summarize_comments/prompts/vertex_ai_spec.rb +++ b/ee/spec/lib/gitlab/llm/chain/tools/summarize_comments/prompts/vertex_ai_spec.rb @@ -5,21 +5,21 @@ RSpec.describe Gitlab::Llm::Chain::Tools::SummarizeComments::Prompts::VertexAi, feature_category: :duo_chat do describe '.prompt' do it 'returns prompt' do - prompt = described_class.prompt({ notes_content: 'foo', num: 123 })[:prompt] + prompt = described_class.prompt({ notes_content: '<comment>foo</comment>' })[:prompt] expect(prompt).to include( <<~PROMPT You are an assistant that extracts the most important information from the comments in maximum 10 bullet points. - Comments are between two identical sets of 3-digit numbers surrounded by < > sign. + Each comment is wrapped in a <comment> tag. - <123> - foo - <123> + <comment>foo</comment> Desired markdown format: **<summary_title>** - <bullet_points> - """ + - <bullet_point> + - <bullet_point> + - <bullet_point> + - ... Focus on extracting information related to one another and that are the majority of the content. Ignore phrases that are not connected to others.