Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-order the GenerativeModel convenience constructors in source #160

Merged
merged 1 commit into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Sources/GoogleAI/GenerativeModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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
)
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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
)
Expand Down
Loading