diff --git a/VertexAISnippets/VertexAISnippets.xcodeproj/project.pbxproj b/VertexAISnippets/VertexAISnippets.xcodeproj/project.pbxproj new file mode 100644 index 00000000..96a6a887 --- /dev/null +++ b/VertexAISnippets/VertexAISnippets.xcodeproj/project.pbxproj @@ -0,0 +1,407 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 8D40F40E2BD1CDC30020872A /* VertexAISnippetsApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D40F40D2BD1CDC30020872A /* VertexAISnippetsApp.swift */; }; + 8D40F4102BD1CDC30020872A /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D40F40F2BD1CDC30020872A /* ContentView.swift */; }; + 8D40F4122BD1CDC40020872A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8D40F4112BD1CDC40020872A /* Assets.xcassets */; }; + 8D40F4162BD1CDC40020872A /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8D40F4152BD1CDC40020872A /* Preview Assets.xcassets */; }; + 8D40F4262BD1CE1A0020872A /* FirebaseAppCheck in Frameworks */ = {isa = PBXBuildFile; productRef = 8D40F4252BD1CE1A0020872A /* FirebaseAppCheck */; }; + 8D40F43B2BD1CE3E0020872A /* FirebaseVertexAI-Preview in Frameworks */ = {isa = PBXBuildFile; productRef = 8D40F43A2BD1CE3E0020872A /* FirebaseVertexAI-Preview */; }; + 8D40F43D2BD1CE910020872A /* VertexAISnippets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D40F43C2BD1CE910020872A /* VertexAISnippets.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 8D40F40A2BD1CDC30020872A /* VertexAISnippets.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VertexAISnippets.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 8D40F40D2BD1CDC30020872A /* VertexAISnippetsApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VertexAISnippetsApp.swift; sourceTree = ""; }; + 8D40F40F2BD1CDC30020872A /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + 8D40F4112BD1CDC40020872A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 8D40F4132BD1CDC40020872A /* VertexAISnippets.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = VertexAISnippets.entitlements; sourceTree = ""; }; + 8D40F4152BD1CDC40020872A /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + 8D40F43C2BD1CE910020872A /* VertexAISnippets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VertexAISnippets.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8D40F4072BD1CDC30020872A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D40F43B2BD1CE3E0020872A /* FirebaseVertexAI-Preview in Frameworks */, + 8D40F4262BD1CE1A0020872A /* FirebaseAppCheck in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 8D40F4012BD1CDC30020872A = { + isa = PBXGroup; + children = ( + 8D40F40C2BD1CDC30020872A /* VertexAISnippets */, + 8D40F40B2BD1CDC30020872A /* Products */, + 8D40F4392BD1CE3E0020872A /* Frameworks */, + ); + sourceTree = ""; + }; + 8D40F40B2BD1CDC30020872A /* Products */ = { + isa = PBXGroup; + children = ( + 8D40F40A2BD1CDC30020872A /* VertexAISnippets.app */, + ); + name = Products; + sourceTree = ""; + }; + 8D40F40C2BD1CDC30020872A /* VertexAISnippets */ = { + isa = PBXGroup; + children = ( + 8D40F40D2BD1CDC30020872A /* VertexAISnippetsApp.swift */, + 8D40F43C2BD1CE910020872A /* VertexAISnippets.swift */, + 8D40F40F2BD1CDC30020872A /* ContentView.swift */, + 8D40F4112BD1CDC40020872A /* Assets.xcassets */, + 8D40F4132BD1CDC40020872A /* VertexAISnippets.entitlements */, + 8D40F4142BD1CDC40020872A /* Preview Content */, + ); + path = VertexAISnippets; + sourceTree = ""; + }; + 8D40F4142BD1CDC40020872A /* Preview Content */ = { + isa = PBXGroup; + children = ( + 8D40F4152BD1CDC40020872A /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; + 8D40F4392BD1CE3E0020872A /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 8D40F4092BD1CDC30020872A /* VertexAISnippets */ = { + isa = PBXNativeTarget; + buildConfigurationList = 8D40F4192BD1CDC40020872A /* Build configuration list for PBXNativeTarget "VertexAISnippets" */; + buildPhases = ( + 8D40F4062BD1CDC30020872A /* Sources */, + 8D40F4072BD1CDC30020872A /* Frameworks */, + 8D40F4082BD1CDC30020872A /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = VertexAISnippets; + packageProductDependencies = ( + 8D40F4252BD1CE1A0020872A /* FirebaseAppCheck */, + 8D40F43A2BD1CE3E0020872A /* FirebaseVertexAI-Preview */, + ); + productName = VertexAISnippets; + productReference = 8D40F40A2BD1CDC30020872A /* VertexAISnippets.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 8D40F4022BD1CDC30020872A /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1520; + LastUpgradeCheck = 1520; + TargetAttributes = { + 8D40F4092BD1CDC30020872A = { + CreatedOnToolsVersion = 15.2; + }; + }; + }; + buildConfigurationList = 8D40F4052BD1CDC30020872A /* Build configuration list for PBXProject "VertexAISnippets" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 8D40F4012BD1CDC30020872A; + packageReferences = ( + 8D40F41C2BD1CE1A0020872A /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */, + ); + productRefGroup = 8D40F40B2BD1CDC30020872A /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8D40F4092BD1CDC30020872A /* VertexAISnippets */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8D40F4082BD1CDC30020872A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D40F4162BD1CDC40020872A /* Preview Assets.xcassets in Resources */, + 8D40F4122BD1CDC40020872A /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8D40F4062BD1CDC30020872A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D40F4102BD1CDC30020872A /* ContentView.swift in Sources */, + 8D40F43D2BD1CE910020872A /* VertexAISnippets.swift in Sources */, + 8D40F40E2BD1CDC30020872A /* VertexAISnippetsApp.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 8D40F4172BD1CDC40020872A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 8D40F4182BD1CDC40020872A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SWIFT_COMPILATION_MODE = wholemodule; + }; + name = Release; + }; + 8D40F41A2BD1CDC40020872A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = VertexAISnippets/VertexAISnippets.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"VertexAISnippets/Preview Content\""; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault; + "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 17.2; + LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; + "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 14.2; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.firebase.VertexAISnippets; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = auto; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 8D40F41B2BD1CDC40020872A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = VertexAISnippets/VertexAISnippets.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"VertexAISnippets/Preview Content\""; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault; + "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 17.2; + LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; + "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 14.2; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.firebase.VertexAISnippets; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = auto; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 8D40F4052BD1CDC30020872A /* Build configuration list for PBXProject "VertexAISnippets" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8D40F4172BD1CDC40020872A /* Debug */, + 8D40F4182BD1CDC40020872A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 8D40F4192BD1CDC40020872A /* Build configuration list for PBXNativeTarget "VertexAISnippets" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8D40F41A2BD1CDC40020872A /* Debug */, + 8D40F41B2BD1CDC40020872A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 8D40F41C2BD1CE1A0020872A /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/firebase/firebase-ios-sdk"; + requirement = { + branch = "vertexai-preview-0.1.0"; + kind = branch; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 8D40F4252BD1CE1A0020872A /* FirebaseAppCheck */ = { + isa = XCSwiftPackageProductDependency; + package = 8D40F41C2BD1CE1A0020872A /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */; + productName = FirebaseAppCheck; + }; + 8D40F43A2BD1CE3E0020872A /* FirebaseVertexAI-Preview */ = { + isa = XCSwiftPackageProductDependency; + package = 8D40F41C2BD1CE1A0020872A /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */; + productName = "FirebaseVertexAI-Preview"; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 8D40F4022BD1CDC30020872A /* Project object */; +} diff --git a/VertexAISnippets/VertexAISnippets/Assets.xcassets/AccentColor.colorset/Contents.json b/VertexAISnippets/VertexAISnippets/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/VertexAISnippets/VertexAISnippets/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/VertexAISnippets/VertexAISnippets/Assets.xcassets/AppIcon.appiconset/Contents.json b/VertexAISnippets/VertexAISnippets/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..532cd729 --- /dev/null +++ b/VertexAISnippets/VertexAISnippets/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,63 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "512x512" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "512x512" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/VertexAISnippets/VertexAISnippets/Assets.xcassets/Contents.json b/VertexAISnippets/VertexAISnippets/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/VertexAISnippets/VertexAISnippets/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/VertexAISnippets/VertexAISnippets/ContentView.swift b/VertexAISnippets/VertexAISnippets/ContentView.swift new file mode 100644 index 00000000..0c5e96f7 --- /dev/null +++ b/VertexAISnippets/VertexAISnippets/ContentView.swift @@ -0,0 +1,31 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import SwiftUI + +struct ContentView: View { + var body: some View { + VStack { + Image(systemName: "globe") + .imageScale(.large) + .foregroundStyle(.tint) + Text("Hello, world!") + } + .padding() + } +} + +#Preview { + ContentView() +} diff --git a/VertexAISnippets/VertexAISnippets/Preview Content/Preview Assets.xcassets/Contents.json b/VertexAISnippets/VertexAISnippets/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/VertexAISnippets/VertexAISnippets/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/VertexAISnippets/VertexAISnippets/VertexAISnippets.entitlements b/VertexAISnippets/VertexAISnippets/VertexAISnippets.entitlements new file mode 100644 index 00000000..f2ef3ae0 --- /dev/null +++ b/VertexAISnippets/VertexAISnippets/VertexAISnippets.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + + diff --git a/VertexAISnippets/VertexAISnippets/VertexAISnippets.swift b/VertexAISnippets/VertexAISnippets/VertexAISnippets.swift new file mode 100644 index 00000000..fb9823fe --- /dev/null +++ b/VertexAISnippets/VertexAISnippets/VertexAISnippets.swift @@ -0,0 +1,329 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#if canImport(UIKit) +import UIKit +#else +import AppKit +#endif + +// [START import_vertexai] +import FirebaseVertexAI +// [END import_vertexai] + +class Snippets { + + var model: GenerativeModel! + + func initializeModel() { + // [START initialize_model] + // Initialize the Vertex AI service + let vertex = VertexAI.vertexAI() + + // Initialize the generative model with a model that supports your use case + // Gemini 1.5 Pro is versatile and can accept both text-only or multimodal prompt inputs + let model = vertex.generativeModel(modelName: "gemini-1.5-pro-preview-0409") + // [END initialize_model] + + self.model = model + } + + func callGemini() async throws { + // [START call_gemini] + // Provide a prompt that contains text + let prompt = "Write a story about a magic backpack." + + // To generate text output, call generateContent with the text input + let response = try await model.generateContent(prompt) + if let text = response.text { + print(text) + } + // [END call_gemini] + } + + func callGeminiStreaming() async throws { + // [START call_gemini_streaming] + // Provide a prompt that contains text + let prompt = "Write a story about a magic backpack." + + // To stream generated text output, call generateContentStream with the text input + let contentStream = model.generateContentStream(prompt) + for try await chunk in contentStream { + if let text = chunk.text { + print(text) + } + } + // [END call_gemini_streaming] + } + + func sendTextOnlyPromptStreaming() async throws { + // [START text_only_prompt_streaming] + // Provide a prompt that contains text + let prompt = "Write a story about a magic backpack." + + // To stream generated text output, call generateContentStream with the text input + let contentStream = model.generateContentStream(prompt) + for try await chunk in contentStream { + if let text = chunk.text { + print(text) + } + } + // [END text_only_prompt_streaming] + } + + // Note: This is the same as the call gemini prompt, but may change in the future. + func sendTextOnlyPromt() async throws { + // [START text_only_prompt] + // Provide a prompt that contains text + let prompt = "Write a story about a magic backpack." + + // To generate text output, call generateContent with the text input + let response = try await model.generateContent(prompt) + if let text = response.text { + print(text) + } + // [END text_only_prompt] + } + + func sendMultimodalPromptStreaming() async throws { + // [START multimodal_prompt_streaming] + #if canImport(UIKit) + guard let image = UIImage(named: "image") else { fatalError() } + #else + guard let image = NSImage(named: "image") else { fatalError() } + #endif + + // Provide a text prompt to include with the image + let prompt = "What's in this picture?" + + // To stream generated text output, call generateContentStream and pass in the prompt + let contentStream = model.generateContentStream(image, prompt) + for try await chunk in contentStream { + if let text = chunk.text { + print(text) + } + } + // [END multimodal_prompt_streaming] + } + + func sendMultimodalPrompt() async throws { + // [START multimodal_prompt] + // Provide a text prompt to include with the image + #if canImport(UIKit) + guard let image = UIImage(named: "image") else { fatalError() } + #else + guard let image = NSImage(named: "image") else { fatalError() } + #endif + + let prompt = "What's in this picture?" + + // To generate text output, call generateContent and pass in the prompt + let response = try await model.generateContent(image, prompt) + if let text = response.text { + print(text) + } + // [END multimodal_prompt] + } + + func multiImagePromptStreaming() async throws { + // [START two_image_prompt_streaming] + #if canImport(UIKit) + guard let image1 = UIImage(named: "image1") else { fatalError() } + guard let image2 = UIImage(named: "image2") else { fatalError() } + #else + guard let image1 = NSImage(named: "image1") else { fatalError() } + guard let image2 = NSImage(named: "image2") else { fatalError() } + #endif + + // Provide a text prompt to include with the images + let prompt = "What's different between these pictures?" + + // To stream generated text output, call generateContentStream and pass in the prompt + let contentStream = model.generateContentStream(image1, image2, prompt) + for try await chunk in contentStream { + if let text = chunk.text { + print(text) + } + } + // [END two_image_prompt_streaming] + } + + func multiImagePrompt() async throws { + // [START two_image_prompt] + #if canImport(UIKit) + guard let image1 = UIImage(named: "image1") else { fatalError() } + guard let image2 = UIImage(named: "image2") else { fatalError() } + #else + guard let image1 = NSImage(named: "image1") else { fatalError() } + guard let image2 = NSImage(named: "image2") else { fatalError() } + #endif + + // Provide a text prompt to include with the images + let prompt = "What's different between these pictures?" + + // To generate text output, call generateContent and pass in the prompt + let response = try await model.generateContent(image1, image2, prompt) + if let text = response.text { + print(text) + } + // [END two_image_prompt] + } + + func textAndVideoPrompt() async throws { + // AVFoundation support coming soon™ + // [START text_video_prompt] + guard let fileURL = Bundle.main.url(forResource: "sample", + withExtension: "mp4") else { fatalError() } + let video = try Data(contentsOf: fileURL) + let prompt = "What's in this video?" + let videoContent = ModelContent.Part.data(mimetype: "video/mp4", video) + + // To generate text output, call generateContent and pass in the prompt + let response = try await model.generateContent(videoContent, prompt) + if let text = response.text { + print(text) + } + // [END text_video_prompt] + } + + func textAndVideoPromptStreaming() async throws { + // [START text_video_prompt_streaming] + guard let fileURL = Bundle.main.url(forResource: "sample", + withExtension: "mp4") else { fatalError() } + let video = try Data(contentsOf: fileURL) + let prompt = "What's in this video?" + let videoContent = ModelContent.Part.data(mimetype: "video/mp4", video) + + // To stream generated text output, call generateContentStream and pass in the prompt + let contentStream = model.generateContentStream(videoContent, prompt) + for try await chunk in contentStream { + if let text = chunk.text { + print(text) + } + } + // [END text_video_prompt_streaming] + } + + func chatStreaming() async throws { + // [START chat_streaming] + // Optionally specify existing chat history + let history = [ + ModelContent(role: "user", parts: "Hello, I have 2 dogs in my house."), + ModelContent(role: "model", parts: "Great to meet you. What would you like to know?"), + ] + + // Initialize the chat with optional chat history + let chat = model.startChat(history: history) + + // To stream generated text output, call sendMessageStream and pass in the message + let contentStream = chat.sendMessageStream("How many paws are in my house?") + for try await chunk in contentStream { + if let text = chunk.text { + print(text) + } + } + // [END chat_streaming] + } + + func chat() async throws { + // [START chat] + // Optionally specify existing chat history + let history = [ + ModelContent(role: "user", parts: "Hello, I have 2 dogs in my house."), + ModelContent(role: "model", parts: "Great to meet you. What would you like to know?"), + ] + + // Initialize the chat with optional chat history + let chat = model.startChat(history: history) + + // To generate text output, call sendMessage and pass in the message + let response = try await chat.sendMessage("How many paws are in my house?") + if let text = response.text { + print(text) + } + // [END chat] + } + + func countTokensText() async throws { + // [START count_tokens_text] + let response = try await model.countTokens("Why is the sky blue?") + print("Total Tokens: \(response.totalTokens)") + print("Total Billable Characters: \(response.totalBillableCharacters)") + // [END count_tokens_text] + } + + func countTokensTextAndImage() async throws { +#if canImport(UIKit) + guard let image = UIImage(named: "image") else { fatalError() } +#else + guard let image = NSImage(named: "image") else { fatalError() } +#endif + // [START count_tokens_text_image] + let response = try await model.countTokens(image, "What's in this picture?") + print("Total Tokens: \(response.totalTokens)") + print("Total Billable Characters: \(response.totalBillableCharacters)") + // [START count_tokens_text_image] + } + + func countTokensMultiImage() async throws { +#if canImport(UIKit) + guard let image1 = UIImage(named: "image1") else { fatalError() } + guard let image2 = UIImage(named: "image2") else { fatalError() } +#else + guard let image1 = NSImage(named: "image1") else { fatalError() } + guard let image2 = NSImage(named: "image2") else { fatalError() } +#endif + // [START count_tokens_multi_image] + let response = try await model.countTokens(image1, image2, "What's in this picture?") + print("Total Tokens: \(response.totalTokens)") + print("Total Billable Characters: \(response.totalBillableCharacters)") + // [END count_tokens_multi_image] + } + + func countTokensChat() async throws { + // [START count_tokens_chat] + let chat = model.startChat() + let history = chat.history + let message = try ModelContent(role: "user", "Why is the sky blue?") + let contents = history + [message] + let response = try await model.countTokens(contents) + print("Total Tokens: \(response.totalTokens)") + print("Total Billable Characters: \(response.totalBillableCharacters)") + // [END count_tokens_chat] + } + + func setSafetySetting() { + // [START set_safety_setting] + let model = VertexAI.vertexAI().generativeModel( + modelName: "MODEL_NAME", + safetySettings: [ + SafetySetting(harmCategory: .harassment, threshold: .blockOnlyHigh) + ] + ) + // [END set_safety_setting] + } + + func setMultipleSafetySettings() { + // [START set_safety_settings] + let harassmentSafety = SafetySetting(harmCategory: .harassment, threshold: .blockOnlyHigh) + let hateSpeechSafety = SafetySetting(harmCategory: .hateSpeech, threshold: .blockMediumAndAbove) + + let model = VertexAI.vertexAI().generativeModel( + modelName: "MODEL_NAME", + safetySettings: [harassmentSafety, hateSpeechSafety] + ) + // [END set_safety_settings] + } + +} diff --git a/VertexAISnippets/VertexAISnippets/VertexAISnippetsApp.swift b/VertexAISnippets/VertexAISnippets/VertexAISnippetsApp.swift new file mode 100644 index 00000000..cc626444 --- /dev/null +++ b/VertexAISnippets/VertexAISnippets/VertexAISnippetsApp.swift @@ -0,0 +1,24 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import SwiftUI + +@main +struct VertexAISnippetsApp: App { + var body: some Scene { + WindowGroup { + ContentView() + } + } +}