mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-04-28 03:30:20 +00:00
improved gemma toolcall handling
This commit is contained in:
parent
4e07c90eca
commit
4090400dff
1 changed files with 5 additions and 4 deletions
|
|
@ -3346,10 +3346,11 @@ def toolcall_to_normalized_json(text,start_tag,end_tag): #convert weird formats
|
||||||
def parse_gemma4(text: str) -> str:
|
def parse_gemma4(text: str) -> str:
|
||||||
if text.startswith("call:"):
|
if text.startswith("call:"):
|
||||||
text = text[len("call:"):]
|
text = text[len("call:"):]
|
||||||
text = text.replace('<|"|>', '!$$REAL_QUOTE$$!')
|
if '<|"|>' in text:
|
||||||
text = text.replace('\\', '\\\\')
|
text = text.replace('<|"|>', '!$$REAL_QUOTE$$!')
|
||||||
text = text.replace('"', '\\"')
|
text = text.replace('\\', '\\\\')
|
||||||
text = text.replace('!$$REAL_QUOTE$$!','"')
|
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
|
fn_match = re.match(r'^([a-zA-Z_][a-zA-Z0-9_]*)\{(.*)\}$', text.strip(), re.DOTALL) # extract fn name
|
||||||
if not fn_match:
|
if not fn_match:
|
||||||
return text
|
return text
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue