|
42 | 42 | }, |
43 | 43 | "tool_calls": { |
44 | 44 | "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\\|>)", |
46 | 46 | "items": { |
47 | 47 | "type": "object", |
48 | 48 | "properties": { |
|
54 | 54 | "properties": { |
55 | 55 | "name": { |
56 | 56 | "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\\|>" |
58 | 58 | }, |
59 | 59 | "arguments": { |
60 | 60 | "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\\|>$", |
62 | 62 | "x-parser": "json", |
63 | 63 | "additionalProperties": true |
64 | 64 | } |
|
410 | 410 | "\n", |
411 | 411 | "{#- Generation prompt #}\n", |
412 | 412 | "{%- 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", |
413 | 426 | "<|start|>assistant\n", |
| 427 | + "{%- endif %}\n", |
414 | 428 | "{%- endif -%}" |
415 | 429 | ] |
416 | 430 | } |
|
0 commit comments