You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// A chat template can optionally be provided or specified by name when several templates are included in the tokenizer config. Normally this is not necessary.
148
154
chatTemplate:ChatTemplateArgument?,
149
155
addGenerationPrompt:Bool,
150
156
truncation:Bool,
151
157
maxLength:Int?,
152
-
tools:[[String:Any]]?
158
+
tools:[ToolSpec]?
153
159
)throws->[Int]
154
160
}
155
161
@@ -358,20 +364,24 @@ public class PreTrainedTokenizer: Tokenizer {
/// Note: tool calling is not supported yet, it will be available in a future update.
385
-
tools:[[String:Any]]?=nil
394
+
tools:[ToolSpec]?=nil
386
395
)throws->[Int]{
387
396
varselectedChatTemplate:String?
388
397
iflet chatTemplate, case .literal(let template)= chatTemplate {
@@ -429,9 +438,12 @@ public class PreTrainedTokenizer: Tokenizer {
429
438
varcontext:[String:Any]=[
430
439
"messages": messages,
431
440
"add_generation_prompt": addGenerationPrompt,
432
-
// TODO: Add `tools` entry when support is added in Jinja
433
-
// "tools": tools
434
441
]
442
+
iflet tools {
443
+
context["tools"]= tools
444
+
// Performance might be better if the tools prompt is included in a system message rather than a user message, but then the system message must be present.
445
+
context["tools_in_user_message"]=false // Default is true in Llama 3.1 and 3.2 template
0 commit comments