From af8c7059c53cc8f8063973a3d32f9be4028b98e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ros=C3=A1rio=20P=2E=20Fernandes?= Date: Wed, 29 May 2024 14:40:18 +0100 Subject: [PATCH 1/3] vertexai: add system instructions snippet --- .../VertexAISnippets/VertexAISnippets.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/VertexAISnippets/VertexAISnippets/VertexAISnippets.swift b/VertexAISnippets/VertexAISnippets/VertexAISnippets.swift index 2a11ae9a..049e9171 100644 --- a/VertexAISnippets/VertexAISnippets/VertexAISnippets.swift +++ b/VertexAISnippets/VertexAISnippets/VertexAISnippets.swift @@ -342,6 +342,20 @@ class Snippets { // [END set_multi_safety_settings] } + func setSystemInstructions() { + // [START system_instructions_text] + // Initialize the Vertex AI service + let vertex = VertexAI.vertexAI() + + // Initialize the generative model + // Specify a model that supports system instructions, like a Gemini 1.5 model + let model = vertex.generativeModel( + modelName: "{{generic_model_name_initialization}}", + systemInstruction: ModelContent(role: "system", parts: "You are a cat. Your name is Neko.") + ) + // [END system_instructions_text] + } + // MARK: - Function Calling func functionCalling() async throws { From ed470d77fe54132e3c4ac52d6077e873c1304c13 Mon Sep 17 00:00:00 2001 From: Morgan Chen Date: Thu, 30 May 2024 14:31:56 -0700 Subject: [PATCH 2/3] rename Vertex dir --- .github/workflows/vertexai.yml | 4 ++-- .../VertexAISnippets.xcodeproj/project.pbxproj | 0 .../Assets.xcassets/AccentColor.colorset/Contents.json | 0 .../Assets.xcassets/AppIcon.appiconset/Contents.json | 0 .../VertexAISnippets/Assets.xcassets/Contents.json | 0 .../VertexAISnippets/ContentView.swift | 0 .../Preview Content/Preview Assets.xcassets/Contents.json | 0 .../VertexAISnippets/VertexAISnippets.entitlements | 0 .../VertexAISnippets/VertexAISnippets.swift | 0 .../VertexAISnippets/VertexAISnippetsApp.swift | 0 10 files changed, 2 insertions(+), 2 deletions(-) rename {VertexAISnippets => vertexai}/VertexAISnippets.xcodeproj/project.pbxproj (100%) rename {VertexAISnippets => vertexai}/VertexAISnippets/Assets.xcassets/AccentColor.colorset/Contents.json (100%) rename {VertexAISnippets => vertexai}/VertexAISnippets/Assets.xcassets/AppIcon.appiconset/Contents.json (100%) rename {VertexAISnippets => vertexai}/VertexAISnippets/Assets.xcassets/Contents.json (100%) rename {VertexAISnippets => vertexai}/VertexAISnippets/ContentView.swift (100%) rename {VertexAISnippets => vertexai}/VertexAISnippets/Preview Content/Preview Assets.xcassets/Contents.json (100%) rename {VertexAISnippets => vertexai}/VertexAISnippets/VertexAISnippets.entitlements (100%) rename {VertexAISnippets => vertexai}/VertexAISnippets/VertexAISnippets.swift (100%) rename {VertexAISnippets => vertexai}/VertexAISnippets/VertexAISnippetsApp.swift (100%) diff --git a/.github/workflows/vertexai.yml b/.github/workflows/vertexai.yml index 51bceeaa..f5757908 100644 --- a/.github/workflows/vertexai.yml +++ b/.github/workflows/vertexai.yml @@ -1,7 +1,7 @@ on: pull_request: paths: - - 'VertexAISnippets/**' + - 'vertexai/**' - '.github/workflows/vertexai.yml' name: VertexAI jobs: @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@master - name: Build Swift snippets run: | - cd VertexAISnippets + cd vertexai xcodebuild -project VertexAISnippets.xcodeproj -scheme VertexAISnippets clean build -destination "${destination}" CODE_SIGNING_REQUIRED=NO env: destination: ${{ matrix.destination }} diff --git a/VertexAISnippets/VertexAISnippets.xcodeproj/project.pbxproj b/vertexai/VertexAISnippets.xcodeproj/project.pbxproj similarity index 100% rename from VertexAISnippets/VertexAISnippets.xcodeproj/project.pbxproj rename to vertexai/VertexAISnippets.xcodeproj/project.pbxproj diff --git a/VertexAISnippets/VertexAISnippets/Assets.xcassets/AccentColor.colorset/Contents.json b/vertexai/VertexAISnippets/Assets.xcassets/AccentColor.colorset/Contents.json similarity index 100% rename from VertexAISnippets/VertexAISnippets/Assets.xcassets/AccentColor.colorset/Contents.json rename to vertexai/VertexAISnippets/Assets.xcassets/AccentColor.colorset/Contents.json diff --git a/VertexAISnippets/VertexAISnippets/Assets.xcassets/AppIcon.appiconset/Contents.json b/vertexai/VertexAISnippets/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from VertexAISnippets/VertexAISnippets/Assets.xcassets/AppIcon.appiconset/Contents.json rename to vertexai/VertexAISnippets/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/VertexAISnippets/VertexAISnippets/Assets.xcassets/Contents.json b/vertexai/VertexAISnippets/Assets.xcassets/Contents.json similarity index 100% rename from VertexAISnippets/VertexAISnippets/Assets.xcassets/Contents.json rename to vertexai/VertexAISnippets/Assets.xcassets/Contents.json diff --git a/VertexAISnippets/VertexAISnippets/ContentView.swift b/vertexai/VertexAISnippets/ContentView.swift similarity index 100% rename from VertexAISnippets/VertexAISnippets/ContentView.swift rename to vertexai/VertexAISnippets/ContentView.swift diff --git a/VertexAISnippets/VertexAISnippets/Preview Content/Preview Assets.xcassets/Contents.json b/vertexai/VertexAISnippets/Preview Content/Preview Assets.xcassets/Contents.json similarity index 100% rename from VertexAISnippets/VertexAISnippets/Preview Content/Preview Assets.xcassets/Contents.json rename to vertexai/VertexAISnippets/Preview Content/Preview Assets.xcassets/Contents.json diff --git a/VertexAISnippets/VertexAISnippets/VertexAISnippets.entitlements b/vertexai/VertexAISnippets/VertexAISnippets.entitlements similarity index 100% rename from VertexAISnippets/VertexAISnippets/VertexAISnippets.entitlements rename to vertexai/VertexAISnippets/VertexAISnippets.entitlements diff --git a/VertexAISnippets/VertexAISnippets/VertexAISnippets.swift b/vertexai/VertexAISnippets/VertexAISnippets.swift similarity index 100% rename from VertexAISnippets/VertexAISnippets/VertexAISnippets.swift rename to vertexai/VertexAISnippets/VertexAISnippets.swift diff --git a/VertexAISnippets/VertexAISnippets/VertexAISnippetsApp.swift b/vertexai/VertexAISnippets/VertexAISnippetsApp.swift similarity index 100% rename from VertexAISnippets/VertexAISnippets/VertexAISnippetsApp.swift rename to vertexai/VertexAISnippets/VertexAISnippetsApp.swift From 9790027caae70ba3f3c1d6bc2f7aabfed02cb569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ros=C3=A1rio=20P=2E=20Fernandes?= Date: Wed, 5 Jun 2024 16:12:21 +0100 Subject: [PATCH 3/3] update model name to 1.5 flash --- vertexai/VertexAISnippets/VertexAISnippets.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vertexai/VertexAISnippets/VertexAISnippets.swift b/vertexai/VertexAISnippets/VertexAISnippets.swift index 049e9171..83dd360e 100644 --- a/vertexai/VertexAISnippets/VertexAISnippets.swift +++ b/vertexai/VertexAISnippets/VertexAISnippets.swift @@ -350,7 +350,7 @@ class Snippets { // Initialize the generative model // Specify a model that supports system instructions, like a Gemini 1.5 model let model = vertex.generativeModel( - modelName: "{{generic_model_name_initialization}}", + modelName: "gemini-1.5-flash", systemInstruction: ModelContent(role: "system", parts: "You are a cat. Your name is Neko.") ) // [END system_instructions_text]