mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-04-26 10:41:25 +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:
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue