@@ -73,33 +73,53 @@ public struct Tool {
73
73
74
74
/// Configuration for specifying function calling behavior.
75
75
public struct FunctionCallingConfig {
76
- /// Defines the execution behavior for function calling by defining the
77
- /// execution mode.
78
- public enum Mode : String {
79
- /// The default behavior for function calling. The model calls functions to answer queries at
80
- /// its discretion.
81
- case auto = " AUTO "
76
+ /// Defines the execution behavior for function calling by defining the execution mode.
77
+ public struct Mode : EncodableProtoEnum {
78
+ enum Kind : String {
79
+ case auto = " AUTO "
80
+ case any = " ANY "
81
+ case none = " NONE "
82
+ }
83
+
84
+ /// The default behavior for function calling.
85
+ ///
86
+ /// The model calls functions to answer queries at its discretion.
87
+ public static var auto : Mode {
88
+ return self . init ( kind: . auto)
89
+ }
82
90
83
91
/// The model always predicts a provided function call to answer every query.
84
- case any = " ANY "
85
-
86
- /// The model will never predict a function call to answer a query. This can also be achieved by
87
- /// not passing any tools to the model.
88
- case none = " NONE "
92
+ public static var any : Mode {
93
+ return self . init ( kind: . any)
94
+ }
95
+
96
+ /// The model will never predict a function call to answer a query.
97
+ ///
98
+ /// > Note: This can also be achieved by not passing any ``FunctionDeclaration`` tools
99
+ /// > when instantiating the model.
100
+ public static var none : Mode {
101
+ return self . init ( kind: . none)
102
+ }
103
+
104
+ let rawValue : String
89
105
}
90
106
91
- /// Specifies the mode in which function calling should execute. If
92
- /// unspecified, the default value will be set to AUTO.
107
+ /// Specifies the mode in which function calling should execute.
93
108
let mode : Mode ?
94
109
95
- /// A set of function names that, when provided, limits the functions the model
96
- /// will call.
97
- ///
98
- /// This should only be set when the Mode is ANY. Function names
99
- /// should match [FunctionDeclaration.name]. With mode set to ANY, model will
100
- /// predict a function call from the set of function names provided.
110
+ /// A set of function names that, when provided, limits the functions the model will call.
101
111
let allowedFunctionNames : [ String ] ?
102
112
113
+ /// Creates a new `FunctionCallingConfig`.
114
+ ///
115
+ /// - Parameters:
116
+ /// - mode: Specifies the mode in which function calling should execute; if unspecified, the
117
+ /// default behavior will be ``Mode/auto``.
118
+ /// - allowedFunctionNames: A set of function names that, when provided, limits the functions
119
+ /// the model will call.
120
+ /// Note: This should only be set when the ``Mode`` is ``Mode/any``. Function names should match
121
+ /// `[FunctionDeclaration.name]`. With mode set to ``Mode/any``, the model will predict a
122
+ /// function call from the set of function names provided.
103
123
public init ( mode: FunctionCallingConfig . Mode ? = nil , allowedFunctionNames: [ String ] ? = nil ) {
104
124
self . mode = mode
105
125
self . allowedFunctionNames = allowedFunctionNames
0 commit comments