From 4090400dff77ca8aa6566625386251b54956085e Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Sat, 25 Apr 2026 09:51:29 +0800 Subject: [PATCH] improved gemma toolcall handling --- koboldcpp.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/koboldcpp.py b/koboldcpp.py index 818d0fc9f..26341d5a4 100755 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -3346,10 +3346,11 @@ def toolcall_to_normalized_json(text,start_tag,end_tag): #convert weird formats def parse_gemma4(text: str) -> str: if text.startswith("call:"): text = text[len("call:"):] - text = text.replace('<|"|>', '!$$REAL_QUOTE$$!') - text = text.replace('\\', '\\\\') - text = text.replace('"', '\\"') - text = text.replace('!$$REAL_QUOTE$$!','"') + if '<|"|>' in text: + text = text.replace('<|"|>', '!$$REAL_QUOTE$$!') + text = text.replace('\\', '\\\\') + text = text.replace('"', '\\"') + text = text.replace('!$$REAL_QUOTE$$!','"') fn_match = re.match(r'^([a-zA-Z_][a-zA-Z0-9_]*)\{(.*)\}$', text.strip(), re.DOTALL) # extract fn name if not fn_match: return text