Skip to content

Commit e8191f0

Browse files
authored
fix(example): correct GPT-OSS tool calling config for server example (abetlen#2289)
1 parent d4ac2c2 commit e8191f0

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

examples/server/configs/gpt-oss-120b.json

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
},
4343
"tool_calls": {
4444
"type": "array",
45-
"x-regex-iterator": "(<\\|start\\|>assistant to=functions\\.\\w+<\\|channel\\|>commentary json<\\|message\\|>.*?<\\|call\\|>)",
45+
"x-regex-iterator": "(<\\|start\\|>assistant<\\|channel\\|>commentary to=functions\\.\\w+ <\\|constrain\\|>json<\\|message\\|>.*?<\\|call\\|>)",
4646
"items": {
4747
"type": "object",
4848
"properties": {
@@ -54,11 +54,11 @@
5454
"properties": {
5555
"name": {
5656
"type": "string",
57-
"x-regex": "^<\\|start\\|>assistant to=functions\\.(\\w+)<\\|channel\\|>commentary json<\\|message\\|>"
57+
"x-regex": "^<\\|start\\|>assistant<\\|channel\\|>commentary to=functions\\.(\\w+) <\\|constrain\\|>json<\\|message\\|>"
5858
},
5959
"arguments": {
6060
"type": "object",
61-
"x-regex": "^<\\|start\\|>assistant to=functions\\.\\w+<\\|channel\\|>commentary json<\\|message\\|>(.*?)<\\|call\\|>$",
61+
"x-regex": "^<\\|start\\|>assistant<\\|channel\\|>commentary to=functions\\.\\w+ <\\|constrain\\|>json<\\|message\\|>(.*?)<\\|call\\|>$",
6262
"x-parser": "json",
6363
"additionalProperties": true
6464
}
@@ -410,7 +410,21 @@
410410
"\n",
411411
"{#- Generation prompt #}\n",
412412
"{%- if add_generation_prompt -%}\n",
413+
"{%- set forced_tool_name = none %}\n",
414+
"{%- if tool_choice is mapping %}\n",
415+
" {%- if tool_choice.function is defined and tool_choice.function.name is defined %}\n",
416+
" {%- set forced_tool_name = tool_choice.function.name %}\n",
417+
" {%- elif tool_choice.name is defined %}\n",
418+
" {%- set forced_tool_name = tool_choice.name %}\n",
419+
" {%- endif %}\n",
420+
"{%- elif function_call is mapping and function_call.name is defined %}\n",
421+
" {%- set forced_tool_name = function_call.name %}\n",
422+
"{%- endif %}\n",
423+
"{%- if forced_tool_name %}\n",
424+
"{{- \"<|start|>assistant<|channel|>commentary to=functions.\" + forced_tool_name + \" <|constrain|>json<|message|>\" }}\n",
425+
"{%- else %}\n",
413426
"<|start|>assistant\n",
427+
"{%- endif %}\n",
414428
"{%- endif -%}"
415429
]
416430
}

0 commit comments

Comments
 (0)