Skip to content

Commit fcc1084

Browse files
authored
Re-order the GenerativeModel convenience constructors in source (#160)
1 parent f94bdba commit fcc1084

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Sources/GoogleAI/GenerativeModel.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ public final class GenerativeModel {
5555
/// - safetySettings: A value describing what types of harmful content your model should allow.
5656
/// - tools: A list of ``Tool`` objects that the model may use to generate the next response.
5757
/// - systemInstruction: Instructions that direct the model to behave a certain way; currently
58-
/// only text content is supported, e.g., "You are a cat. Your name is Neko."
58+
/// only text content is supported, e.g.,
59+
/// `ModelContent(role: "system", parts: "You are a cat. Your name is Neko.")`.
5960
/// - toolConfig: Tool configuration for any `Tool` specified in the request.
6061
/// - requestOptions Configuration parameters for sending requests to the backend.
6162
public convenience init(name: String,
@@ -64,7 +65,7 @@ public final class GenerativeModel {
6465
safetySettings: [SafetySetting]? = nil,
6566
tools: [Tool]? = nil,
6667
toolConfig: ToolConfig? = nil,
67-
systemInstruction: String...,
68+
systemInstruction: ModelContent? = nil,
6869
requestOptions: RequestOptions = RequestOptions()) {
6970
self.init(
7071
name: name,
@@ -73,10 +74,7 @@ public final class GenerativeModel {
7374
safetySettings: safetySettings,
7475
tools: tools,
7576
toolConfig: toolConfig,
76-
systemInstruction: ModelContent(
77-
role: "system",
78-
parts: systemInstruction.map { ModelContent.Part.text($0) }
79-
),
77+
systemInstruction: systemInstruction,
8078
requestOptions: requestOptions,
8179
urlSession: .shared
8280
)
@@ -92,8 +90,7 @@ public final class GenerativeModel {
9290
/// - safetySettings: A value describing what types of harmful content your model should allow.
9391
/// - tools: A list of ``Tool`` objects that the model may use to generate the next response.
9492
/// - systemInstruction: Instructions that direct the model to behave a certain way; currently
95-
/// only text content is supported, e.g.,
96-
/// `ModelContent(role: "system", parts: "You are a cat. Your name is Neko.")`.
93+
/// only text content is supported, e.g., "You are a cat. Your name is Neko."
9794
/// - toolConfig: Tool configuration for any `Tool` specified in the request.
9895
/// - requestOptions Configuration parameters for sending requests to the backend.
9996
public convenience init(name: String,
@@ -102,7 +99,7 @@ public final class GenerativeModel {
10299
safetySettings: [SafetySetting]? = nil,
103100
tools: [Tool]? = nil,
104101
toolConfig: ToolConfig? = nil,
105-
systemInstruction: ModelContent? = nil,
102+
systemInstruction: String...,
106103
requestOptions: RequestOptions = RequestOptions()) {
107104
self.init(
108105
name: name,
@@ -111,7 +108,10 @@ public final class GenerativeModel {
111108
safetySettings: safetySettings,
112109
tools: tools,
113110
toolConfig: toolConfig,
114-
systemInstruction: systemInstruction,
111+
systemInstruction: ModelContent(
112+
role: "system",
113+
parts: systemInstruction.map { ModelContent.Part.text($0) }
114+
),
115115
requestOptions: requestOptions,
116116
urlSession: .shared
117117
)

0 commit comments

Comments
 (0)