From 933b7281351dcfeffaeda36fcb25e8edfbe2c475 Mon Sep 17 00:00:00 2001 From: Aaron Po Date: Sun, 19 Jul 2026 04:10:33 -0400 Subject: [PATCH] Formatted src/data_generation/prompt_formatting --- .../gemma4_jinja_prompt_formatter.cc | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tooling/pipeline/src/data_generation/prompt_formatting/gemma4_jinja_prompt_formatter.cc b/tooling/pipeline/src/data_generation/prompt_formatting/gemma4_jinja_prompt_formatter.cc index dfe94b69..7764197a 100644 --- a/tooling/pipeline/src/data_generation/prompt_formatting/gemma4_jinja_prompt_formatter.cc +++ b/tooling/pipeline/src/data_generation/prompt_formatting/gemma4_jinja_prompt_formatter.cc @@ -8,25 +8,25 @@ static constexpr std::string_view kWhitespace = " \t\n\r\f\v"; // Strips leading and trailing whitespace to ensure clean prompt injection. static std::string_view Trim(std::string_view value) { - const size_t first_index = value.find_first_not_of(kWhitespace); + const size_t first_index = value.find_first_not_of(kWhitespace); - const bool is_all_whitespace = (first_index == std::string_view::npos); - if (is_all_whitespace) { - return ""; - } + const bool is_all_whitespace = (first_index == std::string_view::npos); + if (is_all_whitespace) { + return ""; + } - const size_t last_index = value.find_last_not_of(kWhitespace); - return value.substr(first_index, last_index - first_index + 1); + const size_t last_index = value.find_last_not_of(kWhitespace); + return value.substr(first_index, last_index - first_index + 1); } std::string Gemma4JinjaPromptFormatter::Format( std::string_view system_prompt, std::string_view user_prompt) const { - std::string_view trimmed_system = Trim(system_prompt); - std::string_view trimmed_user = Trim(user_prompt); + std::string_view trimmed_system = Trim(system_prompt); + std::string_view trimmed_user = Trim(user_prompt); - return std::format( - "<|turn|>system\n<|think|>\n{}\n<|turn|>\n" - "<|turn|>user\n{}\n<|turn|>\n" - "<|turn|>model\n<|channel>thought\n", - trimmed_system, trimmed_user); + return std::format( + "<|turn|>system\n<|think|>\n{}\n<|turn|>\n" + "<|turn|>user\n{}\n<|turn|>\n" + "<|turn|>model\n<|channel>thought\n", + trimmed_system, trimmed_user); }