File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
Original file line number Diff line number Diff line change @@ -2061,12 +2061,12 @@ def chatml_function_calling(
2061
2061
"\n functions.<function_name>:"
2062
2062
'\n { "arg1": "value1", "arg2": "value2" }'
2063
2063
"{% endif %}"
2064
- "\n <|im_end|>\n "
2064
+ "<|im_end|>\n "
2065
2065
"{% endif %}"
2066
2066
# User message
2067
2067
"{% if message.role == 'user' %}"
2068
2068
"{{ message.content }}"
2069
- "\n <|im_end|>\n "
2069
+ "<|im_end|>\n "
2070
2070
"{% endif %}"
2071
2071
# Assistant message
2072
2072
"{% if message.role == 'assistant' %}"
@@ -2076,19 +2076,19 @@ def chatml_function_calling(
2076
2076
"message:\n "
2077
2077
"{% endif %}"
2078
2078
"{{ message.content }}"
2079
- "\n <|im_end|>\n "
2079
+ "<|im_end|>\n "
2080
2080
"{% endif %}"
2081
2081
## Function calls
2082
2082
"{% if 'tool_calls' in message %}"
2083
2083
"{% for tool_call in message.tool_calls %}"
2084
2084
"functions.{{ tool_call.function.name }}:\n "
2085
2085
"{{ tool_call.function.arguments }}"
2086
2086
"{% endfor %}"
2087
- "\n <|im_end|>\n "
2087
+ "<|im_end|>\n "
2088
2088
"{% endif %}"
2089
2089
"{% endif %}"
2090
2090
"{% endfor %}"
2091
- "{% if add_generation_prompt %}{{ ' <|im_start|>assistant\n ' }} {% endif %}"
2091
+ "{% if add_generation_prompt %}<|im_start|>assistant\n {% endif %}"
2092
2092
)
2093
2093
template_renderer = jinja2 .Environment (
2094
2094
loader = jinja2 .BaseLoader (),
@@ -2120,6 +2120,8 @@ def chatml_function_calling(
2120
2120
},
2121
2121
}
2122
2122
2123
+ stop = [stop , "<|im_end|>" ] if isinstance (stop , str ) else stop + ["<|im_end|>" ] if stop else ["<|im_end|>" ]
2124
+
2123
2125
# Case 1: No tool choice by user
2124
2126
if (
2125
2127
tool_choice is None
You can’t perform that action at this time.
0 commit comments