Skip to content

Commit

Permalink
Make tools and additionalContext optional (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
DePasqualeOrg authored Jan 31, 2025
1 parent ff81749 commit aeaf9e6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Sources/Tokenizers/Tokenizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ public protocol Tokenizer {
func applyChatTemplate(messages: [Message]) throws -> [Int]

/// The appropriate chat template is selected from the tokenizer config
func applyChatTemplate(messages: [Message], tools: [ToolSpec]) throws -> [Int]
func applyChatTemplate(messages: [Message], tools: [ToolSpec]?) throws -> [Int]

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

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

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

public func applyChatTemplate(messages: [Message], tools: [ToolSpec], additionalContext: [String: Any]) throws
public func applyChatTemplate(messages: [Message], tools: [ToolSpec]? = nil, additionalContext: [String: Any]? = nil) throws
-> [Int]
{
try applyChatTemplate(
Expand Down

0 comments on commit aeaf9e6

Please sign in to comment.