@@ -39,6 +39,9 @@ public final class GenerativeModel {
39
39
/// Tool configuration for any `Tool` specified in the request.
40
40
let toolConfig : ToolConfig ?
41
41
42
+ /// Instructions that direct the model to behave a certain way.
43
+ let systemInstruction : ModelContent ?
44
+
42
45
/// Configuration parameters for sending requests to the backend.
43
46
let requestOptions : RequestOptions
44
47
@@ -51,6 +54,8 @@ public final class GenerativeModel {
51
54
/// - generationConfig: The content generation parameters your model should use.
52
55
/// - safetySettings: A value describing what types of harmful content your model should allow.
53
56
/// - tools: A list of ``Tool`` objects that the model may use to generate the next response.
57
+ /// - systemInstruction: Instructions that direct the model to behave a certain way; currently
58
+ /// only text content is supported.
54
59
/// - toolConfig: Tool configuration for any `Tool` specified in the request.
55
60
/// - requestOptions Configuration parameters for sending requests to the backend.
56
61
public convenience init ( name: String ,
@@ -59,6 +64,7 @@ public final class GenerativeModel {
59
64
safetySettings: [ SafetySetting ] ? = nil ,
60
65
tools: [ Tool ] ? = nil ,
61
66
toolConfig: ToolConfig ? = nil ,
67
+ systemInstruction: ModelContent ? = nil ,
62
68
requestOptions: RequestOptions = RequestOptions ( ) ) {
63
69
self . init (
64
70
name: name,
@@ -67,6 +73,7 @@ public final class GenerativeModel {
67
73
safetySettings: safetySettings,
68
74
tools: tools,
69
75
toolConfig: toolConfig,
76
+ systemInstruction: systemInstruction,
70
77
requestOptions: requestOptions,
71
78
urlSession: . shared
72
79
)
@@ -79,6 +86,7 @@ public final class GenerativeModel {
79
86
safetySettings: [ SafetySetting ] ? = nil ,
80
87
tools: [ Tool ] ? = nil ,
81
88
toolConfig: ToolConfig ? = nil ,
89
+ systemInstruction: ModelContent ? = nil ,
82
90
requestOptions: RequestOptions = RequestOptions ( ) ,
83
91
urlSession: URLSession ) {
84
92
modelResourceName = GenerativeModel . modelResourceName ( name: name)
@@ -87,6 +95,7 @@ public final class GenerativeModel {
87
95
self . safetySettings = safetySettings
88
96
self . tools = tools
89
97
self . toolConfig = toolConfig
98
+ self . systemInstruction = systemInstruction
90
99
self . requestOptions = requestOptions
91
100
92
101
Logging . default. info ( """
@@ -134,6 +143,7 @@ public final class GenerativeModel {
134
143
safetySettings: safetySettings,
135
144
tools: tools,
136
145
toolConfig: toolConfig,
146
+ systemInstruction: systemInstruction,
137
147
isStreaming: false ,
138
148
options: requestOptions)
139
149
response = try await generativeAIService. loadRequest ( request: generateContentRequest)
@@ -207,6 +217,7 @@ public final class GenerativeModel {
207
217
safetySettings: safetySettings,
208
218
tools: tools,
209
219
toolConfig: toolConfig,
220
+ systemInstruction: systemInstruction,
210
221
isStreaming: true ,
211
222
options: requestOptions)
212
223
0 commit comments