diff --git a/Sources/GoogleAI/GenerativeModel.swift b/Sources/GoogleAI/GenerativeModel.swift index efcc0df..7ed2016 100644 --- a/Sources/GoogleAI/GenerativeModel.swift +++ b/Sources/GoogleAI/GenerativeModel.swift @@ -55,7 +55,8 @@ public final class GenerativeModel { /// - safetySettings: A value describing what types of harmful content your model should allow. /// - tools: A list of ``Tool`` objects that the model may use to generate the next response. /// - systemInstruction: Instructions that direct the model to behave a certain way; currently - /// only text content is supported, e.g., "You are a cat. Your name is Neko." + /// only text content is supported, e.g., + /// `ModelContent(role: "system", parts: "You are a cat. Your name is Neko.")`. /// - toolConfig: Tool configuration for any `Tool` specified in the request. /// - requestOptions Configuration parameters for sending requests to the backend. public convenience init(name: String, @@ -64,7 +65,7 @@ public final class GenerativeModel { safetySettings: [SafetySetting]? = nil, tools: [Tool]? = nil, toolConfig: ToolConfig? = nil, - systemInstruction: String..., + systemInstruction: ModelContent? = nil, requestOptions: RequestOptions = RequestOptions()) { self.init( name: name, @@ -73,10 +74,7 @@ public final class GenerativeModel { safetySettings: safetySettings, tools: tools, toolConfig: toolConfig, - systemInstruction: ModelContent( - role: "system", - parts: systemInstruction.map { ModelContent.Part.text($0) } - ), + systemInstruction: systemInstruction, requestOptions: requestOptions, urlSession: .shared ) @@ -92,8 +90,7 @@ public final class GenerativeModel { /// - safetySettings: A value describing what types of harmful content your model should allow. /// - tools: A list of ``Tool`` objects that the model may use to generate the next response. /// - systemInstruction: Instructions that direct the model to behave a certain way; currently - /// only text content is supported, e.g., - /// `ModelContent(role: "system", parts: "You are a cat. Your name is Neko.")`. + /// only text content is supported, e.g., "You are a cat. Your name is Neko." /// - toolConfig: Tool configuration for any `Tool` specified in the request. /// - requestOptions Configuration parameters for sending requests to the backend. public convenience init(name: String, @@ -102,7 +99,7 @@ public final class GenerativeModel { safetySettings: [SafetySetting]? = nil, tools: [Tool]? = nil, toolConfig: ToolConfig? = nil, - systemInstruction: ModelContent? = nil, + systemInstruction: String..., requestOptions: RequestOptions = RequestOptions()) { self.init( name: name, @@ -111,7 +108,10 @@ public final class GenerativeModel { safetySettings: safetySettings, tools: tools, toolConfig: toolConfig, - systemInstruction: systemInstruction, + systemInstruction: ModelContent( + role: "system", + parts: systemInstruction.map { ModelContent.Part.text($0) } + ), requestOptions: requestOptions, urlSession: .shared )