Skip to content

Commit 3ad8c1c

Browse files
authored
Make system instruction accept String values only (#152)
1 parent e195730 commit 3ad8c1c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Sources/GoogleAI/GenerativeModel.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ 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.
58+
/// only text content is supported, e.g., "You are a cat. Your name is Neko."
5959
/// - toolConfig: Tool configuration for any `Tool` specified in the request.
6060
/// - requestOptions Configuration parameters for sending requests to the backend.
6161
public convenience init(name: String,
@@ -64,7 +64,7 @@ public final class GenerativeModel {
6464
safetySettings: [SafetySetting]? = nil,
6565
tools: [Tool]? = nil,
6666
toolConfig: ToolConfig? = nil,
67-
systemInstruction: any ThrowingPartsRepresentable...,
67+
systemInstruction: String,
6868
requestOptions: RequestOptions = RequestOptions()) {
6969
self.init(
7070
name: name,
@@ -73,7 +73,7 @@ public final class GenerativeModel {
7373
safetySettings: safetySettings,
7474
tools: tools,
7575
toolConfig: toolConfig,
76-
systemInstruction: try? ModelContent(role: "system", parts: systemInstruction),
76+
systemInstruction: ModelContent(role: "system", parts: systemInstruction),
7777
requestOptions: requestOptions,
7878
urlSession: .shared
7979
)
@@ -89,7 +89,8 @@ public final class GenerativeModel {
8989
/// - safetySettings: A value describing what types of harmful content your model should allow.
9090
/// - tools: A list of ``Tool`` objects that the model may use to generate the next response.
9191
/// - systemInstruction: Instructions that direct the model to behave a certain way; currently
92-
/// only text content is supported.
92+
/// only text content is supported, e.g.,
93+
/// `ModelContent(role: "system", parts: "You are a cat. Your name is Neko.")`.
9394
/// - toolConfig: Tool configuration for any `Tool` specified in the request.
9495
/// - requestOptions Configuration parameters for sending requests to the backend.
9596
public convenience init(name: String,

0 commit comments

Comments
 (0)