Skip to content

Commit 6276261

Browse files
vertexai: add system instructions snippet (#397)
* vertexai: add system instructions snippet * rename Vertex dir * update model name to 1.5 flash --------- Co-authored-by: Morgan Chen <morganchen12@gmail.com>
1 parent cdce007 commit 6276261

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

vertexai/VertexAISnippets/VertexAISnippets.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,20 @@ class Snippets {
343343
// [END set_multi_safety_settings]
344344
}
345345

346+
func setSystemInstructions() {
347+
// [START system_instructions_text]
348+
// Initialize the Vertex AI service
349+
let vertex = VertexAI.vertexAI()
350+
351+
// Initialize the generative model
352+
// Specify a model that supports system instructions, like a Gemini 1.5 model
353+
let model = vertex.generativeModel(
354+
modelName: "gemini-1.5-flash",
355+
systemInstruction: ModelContent(role: "system", parts: "You are a cat. Your name is Neko.")
356+
)
357+
// [END system_instructions_text]
358+
}
359+
346360
// MARK: - Function Calling
347361

348362
func functionCalling() async throws {

0 commit comments

Comments
 (0)