Skip to content

Commit 4090400

Browse files
committed
improved gemma toolcall handling
1 parent 4e07c90 commit 4090400

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

koboldcpp.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3346,10 +3346,11 @@ def parse_minimax(text: str) -> str:
33463346
def parse_gemma4(text: str) -> str:
33473347
if text.startswith("call:"):
33483348
text = text[len("call:"):]
3349-
text = text.replace('<|"|>', '!$$REAL_QUOTE$$!')
3350-
text = text.replace('\\', '\\\\')
3351-
text = text.replace('"', '\\"')
3352-
text = text.replace('!$$REAL_QUOTE$$!','"')
3349+
if '<|"|>' in text:
3350+
text = text.replace('<|"|>', '!$$REAL_QUOTE$$!')
3351+
text = text.replace('\\', '\\\\')
3352+
text = text.replace('"', '\\"')
3353+
text = text.replace('!$$REAL_QUOTE$$!','"')
33533354
fn_match = re.match(r'^([a-zA-Z_][a-zA-Z0-9_]*)\{(.*)\}$', text.strip(), re.DOTALL) # extract fn name
33543355
if not fn_match:
33553356
return text

0 commit comments

Comments
 (0)