@@ -29,6 +29,9 @@ public struct FunctionDeclaration: Sendable {
29
29
/// Describes the parameters to this function; must be of type `DataType.object`.
30
30
let parameters : Schema ?
31
31
32
+ // TODO: remove (added for testing)
33
+ let behavior : FunctionBehavior ?
34
+
32
35
/// Constructs a new `FunctionDeclaration`.
33
36
///
34
37
/// - Parameters:
@@ -40,8 +43,21 @@ public struct FunctionDeclaration: Sendable {
40
43
/// calls; by default, all parameters are considered required.
41
44
public init ( name: String , description: String , parameters: [ String : Schema ] ,
42
45
optionalParameters: [ String ] = [ ] ) {
46
+ self . init (
47
+ name: name,
48
+ description: description,
49
+ parameters: parameters,
50
+ optionalParameters: optionalParameters,
51
+ functionBehavior: nil
52
+ )
53
+ }
54
+
55
+ // TODO: remove (added for testing)
56
+ public init ( name: String , description: String , parameters: [ String : Schema ] ,
57
+ optionalParameters: [ String ] = [ ] , functionBehavior: FunctionBehavior ? = nil ) {
43
58
self . name = name
44
59
self . description = description
60
+ behavior = functionBehavior
45
61
self . parameters = Schema . object (
46
62
properties: parameters,
47
63
optionalProperties: optionalParameters,
@@ -50,6 +66,12 @@ public struct FunctionDeclaration: Sendable {
50
66
}
51
67
}
52
68
69
+ // TODO: remove (added for testing)
70
+ public enum FunctionBehavior : String , Sendable , Encodable {
71
+ case blocking = " BLOCKING "
72
+ case nonBlocking = " NON_BLOCKING "
73
+ }
74
+
53
75
/// A tool that allows the generative model to connect to Google Search to access and incorporate
54
76
/// up-to-date information from the web into its responses.
55
77
///
@@ -200,13 +222,15 @@ extension FunctionDeclaration: Encodable {
200
222
case name
201
223
case description
202
224
case parameters
225
+ case behavior // TODO: remove (added for testing)
203
226
}
204
227
205
228
public func encode( to encoder: Encoder ) throws {
206
229
var container = encoder. container ( keyedBy: CodingKeys . self)
207
230
try container. encode ( name, forKey: . name)
208
231
try container. encode ( description, forKey: . description)
209
232
try container. encode ( parameters, forKey: . parameters)
233
+ try container. encode ( behavior, forKey: . behavior) // TODO: remove (added for testing)
210
234
}
211
235
}
212
236
0 commit comments