From f6e712d919d6343f650c1ce25e0e536689a98623 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Mon, 6 Apr 2026 19:20:44 +0800 Subject: [PATCH] universal gemma4 fix, add memory check --- gpttype_adapter.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gpttype_adapter.cpp b/gpttype_adapter.cpp index ed08a961c..19b9efa00 100644 --- a/gpttype_adapter.cpp +++ b/gpttype_adapter.cpp @@ -3857,12 +3857,14 @@ generation_outputs gpttype_generate(const generation_inputs inputs) const std::string channel_close = ""; const std::string channel_prefix = channel_open + channel_close; - const bool has_open = kcpp_data->prompt.find(channel_open) != std::string::npos; - const bool has_close = kcpp_data->prompt.find(channel_close) != std::string::npos; + const std::string fullbody = addedmemory + kcpp_data->prompt; + + const bool has_open = fullbody.find(channel_open) != std::string::npos; + const bool has_close = fullbody.find(channel_close) != std::string::npos; // If neither opening nor closing tag is present anywhere, prepend both if (!has_open && !has_close) { - kcpp_data->prompt = channel_prefix + kcpp_data->prompt; + addedmemory = channel_prefix + addedmemory; } } }