@@ -36,6 +36,9 @@ public final class GenerativeModel {
36
36
/// A list of tools the model may use to generate the next response.
37
37
let tools : [ Tool ] ?
38
38
39
+ /// Tool configuration for any `Tool` specified in the request.
40
+ let toolConfig : ToolConfig ?
41
+
39
42
/// Configuration parameters for sending requests to the backend.
40
43
let requestOptions : RequestOptions
41
44
@@ -48,19 +51,22 @@ public final class GenerativeModel {
48
51
/// - generationConfig: The content generation parameters your model should use.
49
52
/// - safetySettings: A value describing what types of harmful content your model should allow.
50
53
/// - tools: A list of ``Tool`` objects that the model may use to generate the next response.
54
+ /// - toolConfig: Tool configuration for any `Tool` specified in the request.
51
55
/// - requestOptions Configuration parameters for sending requests to the backend.
52
56
public convenience init ( name: String ,
53
57
apiKey: String ,
54
58
generationConfig: GenerationConfig ? = nil ,
55
59
safetySettings: [ SafetySetting ] ? = nil ,
56
60
tools: [ Tool ] ? = nil ,
61
+ toolConfig: ToolConfig ? = nil ,
57
62
requestOptions: RequestOptions = RequestOptions ( ) ) {
58
63
self . init (
59
64
name: name,
60
65
apiKey: apiKey,
61
66
generationConfig: generationConfig,
62
67
safetySettings: safetySettings,
63
68
tools: tools,
69
+ toolConfig: toolConfig,
64
70
requestOptions: requestOptions,
65
71
urlSession: . shared
66
72
)
@@ -72,13 +78,15 @@ public final class GenerativeModel {
72
78
generationConfig: GenerationConfig ? = nil ,
73
79
safetySettings: [ SafetySetting ] ? = nil ,
74
80
tools: [ Tool ] ? = nil ,
81
+ toolConfig: ToolConfig ? = nil ,
75
82
requestOptions: RequestOptions = RequestOptions ( ) ,
76
83
urlSession: URLSession ) {
77
84
modelResourceName = GenerativeModel . modelResourceName ( name: name)
78
85
generativeAIService = GenerativeAIService ( apiKey: apiKey, urlSession: urlSession)
79
86
self . generationConfig = generationConfig
80
87
self . safetySettings = safetySettings
81
88
self . tools = tools
89
+ self . toolConfig = toolConfig
82
90
self . requestOptions = requestOptions
83
91
84
92
Logging . default. info ( """
@@ -125,6 +133,7 @@ public final class GenerativeModel {
125
133
generationConfig: generationConfig,
126
134
safetySettings: safetySettings,
127
135
tools: tools,
136
+ toolConfig: toolConfig,
128
137
isStreaming: false ,
129
138
options: requestOptions)
130
139
response = try await generativeAIService. loadRequest ( request: generateContentRequest)
@@ -197,6 +206,7 @@ public final class GenerativeModel {
197
206
generationConfig: generationConfig,
198
207
safetySettings: safetySettings,
199
208
tools: tools,
209
+ toolConfig: toolConfig,
200
210
isStreaming: true ,
201
211
options: requestOptions)
202
212
0 commit comments