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