Skip to content

Commit aeaf9e6

Browse files
Make tools and additionalContext optional (#169)
1 parent ff81749 commit aeaf9e6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Sources/Tokenizers/Tokenizer.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ public protocol Tokenizer {
148148
func applyChatTemplate(messages: [Message]) throws -> [Int]
149149

150150
/// The appropriate chat template is selected from the tokenizer config
151-
func applyChatTemplate(messages: [Message], tools: [ToolSpec]) throws -> [Int]
151+
func applyChatTemplate(messages: [Message], tools: [ToolSpec]?) throws -> [Int]
152+
153+
/// The appropriate chat template is selected from the tokenizer config
154+
func applyChatTemplate(messages: [Message], tools: [ToolSpec]?, additionalContext: [String: Any]?) throws -> [Int]
152155

153156
/// The chat template is provided as a string literal or specified by name
154157
func applyChatTemplate(messages: [Message], chatTemplate: ChatTemplateArgument) throws -> [Int]
@@ -400,11 +403,11 @@ public class PreTrainedTokenizer: Tokenizer {
400403
try applyChatTemplate(messages: messages, addGenerationPrompt: true)
401404
}
402405

403-
public func applyChatTemplate(messages: [Message], tools: [ToolSpec]) throws -> [Int] {
406+
public func applyChatTemplate(messages: [Message], tools: [ToolSpec]? = nil) throws -> [Int] {
404407
try applyChatTemplate(messages: messages, addGenerationPrompt: true, tools: tools)
405408
}
406409

407-
public func applyChatTemplate(messages: [Message], tools: [ToolSpec], additionalContext: [String: Any]) throws
410+
public func applyChatTemplate(messages: [Message], tools: [ToolSpec]? = nil, additionalContext: [String: Any]? = nil) throws
408411
-> [Int]
409412
{
410413
try applyChatTemplate(

0 commit comments

Comments
 (0)