Skip to content

Commit de514d7

Browse files
committed
fix(example): parse Gemma text tool bracket calls
1 parent 486987f commit de514d7

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

examples/server/configs/gemma-4-12b-it-qat.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
},
4545
"tool_calls": {
4646
"type": "array",
47-
"x-regex-iterator": "<\\|tool_call>(call:[^\\{]+\\{.*?\\})<tool_call\\|>",
47+
"x-regex-iterator": "<\\|tool_call>(call:[^\\{\\[]+[\\{\\[].*?[\\}\\]])<tool_call\\|>",
4848
"items": {
4949
"type": "object",
5050
"properties": {
@@ -56,11 +56,11 @@
5656
"properties": {
5757
"name": {
5858
"type": "string",
59-
"x-regex": "^call:(\\w+)\\{"
59+
"x-regex": "^call:(\\w+)[\\{\\[]"
6060
},
6161
"arguments": {
6262
"type": "object",
63-
"x-regex": "^call:\\w+(\\{.*\\})$",
63+
"x-regex": "^call:\\w+(\\{.*\\}|\\[.*\\])$",
6464
"x-parser": "gemma4-tool-call",
6565
"additionalProperties": true
6666
}

examples/server/server.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4389,6 +4389,9 @@ def capture(match: re.Match[str]) -> str:
43894389
strings.append(match.group(1))
43904390
return f"\x00{len(strings) - 1}\x00"
43914391

4392+
stripped = text.strip()
4393+
if stripped.startswith("[") and stripped.endswith("]"):
4394+
text = "{" + stripped[1:-1] + "}"
43924395
text = re.sub(r'<\|"\|>(.*?)<\|"\|>', capture, text, flags=re.S)
43934396
text = re.sub(r"(?<=[{,])(\w+):", r'"\1":', text)
43944397
for index, value in enumerate(strings):

0 commit comments

Comments
 (0)