@@ -10,10 +10,10 @@ import Hub
1010import Jinja
1111
1212/// A type alias for chat messages, represented as key-value pairs.
13- public typealias Message = [ String : Any ]
13+ public typealias Message = [ String : any Sendable ]
1414
1515/// A type alias for tool specifications used in chat templating.
16- public typealias ToolSpec = [ String : Any ]
16+ public typealias ToolSpec = [ String : any Sendable ]
1717
1818/// Errors that can occur during tokenizer operations.
1919public enum TokenizerError : LocalizedError {
@@ -330,7 +330,7 @@ public protocol Tokenizer: Sendable {
330330 /// - additionalContext: Additional context variables for template rendering
331331 /// - Returns: Token IDs for the formatted conversation
332332 /// - Throws: `TokenizerError` if template application fails or no template is available
333- func applyChatTemplate( messages: [ Message ] , tools: [ ToolSpec ] ? , additionalContext: [ String : Any ] ? ) throws -> [ Int ]
333+ func applyChatTemplate( messages: [ Message ] , tools: [ ToolSpec ] ? , additionalContext: [ String : any Sendable ] ? ) throws -> [ Int ]
334334
335335 /// Applies a specific chat template to format messages.
336336 ///
@@ -389,7 +389,7 @@ public protocol Tokenizer: Sendable {
389389 truncation: Bool ,
390390 maxLength: Int ? ,
391391 tools: [ ToolSpec ] ? ,
392- additionalContext: [ String : Any ] ?
392+ additionalContext: [ String : any Sendable ] ?
393393 ) throws -> [ Int ]
394394}
395395
@@ -405,7 +405,7 @@ extension Tokenizer {
405405 truncation: Bool ,
406406 maxLength: Int ? ,
407407 tools: [ ToolSpec ] ? ,
408- additionalContext: [ String : Any ] ?
408+ additionalContext: [ String : any Sendable ] ?
409409 ) throws -> [ Int ] {
410410 if additionalContext == nil {
411411 try applyChatTemplate (
@@ -702,7 +702,7 @@ public class PreTrainedTokenizer: @unchecked Sendable, Tokenizer {
702702 try applyChatTemplate ( messages: messages, addGenerationPrompt: true , tools: tools)
703703 }
704704
705- public func applyChatTemplate( messages: [ Message ] , tools: [ ToolSpec ] ? = nil , additionalContext: [ String : Any ] ? = nil ) throws
705+ public func applyChatTemplate( messages: [ Message ] , tools: [ ToolSpec ] ? = nil , additionalContext: [ String : any Sendable ] ? = nil ) throws
706706 -> [ Int ]
707707 {
708708 try applyChatTemplate (
@@ -747,7 +747,7 @@ public class PreTrainedTokenizer: @unchecked Sendable, Tokenizer {
747747 // [chat templating guide](https://huggingface.co/docs/transformers/main/en/chat_templating#automated-function-conversion-for-tool-use)
748748 // for more information.
749749 tools: [ ToolSpec ] ? = nil ,
750- additionalContext: [ String : Any ] ? = nil
750+ additionalContext: [ String : any Sendable ] ? = nil
751751 ) throws -> [ Int ] {
752752 var selectedChatTemplate : String ?
753753 if let chatTemplate, case let . literal( template) = chatTemplate {
0 commit comments