Skip to content

Commit

Permalink
Make system instruction accept Strings only
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheard committed Apr 29, 2024
1 parent e195730 commit 4a49563
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Sources/GoogleAI/GenerativeModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,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.
/// 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 @@ -64,7 +64,7 @@ public final class GenerativeModel {
safetySettings: [SafetySetting]? = nil,
tools: [Tool]? = nil,
toolConfig: ToolConfig? = nil,
systemInstruction: any ThrowingPartsRepresentable...,
systemInstruction: String,
requestOptions: RequestOptions = RequestOptions()) {
self.init(
name: name,
Expand All @@ -73,7 +73,7 @@ public final class GenerativeModel {
safetySettings: safetySettings,
tools: tools,
toolConfig: toolConfig,
systemInstruction: try? ModelContent(role: "system", parts: systemInstruction),
systemInstruction: ModelContent(role: "system", parts: systemInstruction),
requestOptions: requestOptions,
urlSession: .shared
)
Expand All @@ -89,7 +89,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.
/// 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 Down

0 comments on commit 4a49563

Please sign in to comment.