diff --git a/firebaseai/ChatExample/ViewModels/ConversationViewModel.swift b/firebaseai/ChatExample/ViewModels/ConversationViewModel.swift index 29cc06db4..7487efd7e 100644 --- a/firebaseai/ChatExample/ViewModels/ConversationViewModel.swift +++ b/firebaseai/ChatExample/ViewModels/ConversationViewModel.swift @@ -36,7 +36,7 @@ class ConversationViewModel: ObservableObject { private var chatTask: Task? init(firebaseService: FirebaseAI) { - model = firebaseService.generativeModel(modelName: "gemini-2.0-flash-001") + model = firebaseService.generativeModel(modelName: ModelNames.geminiFlash) chat = model.startChat() } diff --git a/firebaseai/Constants/ModelNames.swift b/firebaseai/Constants/ModelNames.swift new file mode 100644 index 000000000..a2841ee4b --- /dev/null +++ b/firebaseai/Constants/ModelNames.swift @@ -0,0 +1,18 @@ +// Copyright 2025 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. + +enum ModelNames { + static let geminiFlash = "gemini-2.5-flash" + static let imagenGenerate = "imagen-3.0-generate-002" +} \ No newline at end of file diff --git a/firebaseai/FirebaseAIExample.xcodeproj/project.pbxproj b/firebaseai/FirebaseAIExample.xcodeproj/project.pbxproj index e7ef45bc0..110544703 100644 --- a/firebaseai/FirebaseAIExample.xcodeproj/project.pbxproj +++ b/firebaseai/FirebaseAIExample.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 56; + objectVersion = 70; objects = { /* Begin PBXBuildFile section */ @@ -63,6 +63,10 @@ DEFECAA72D7B4CCD00EF9621 /* ImagenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagenViewModel.swift; sourceTree = ""; }; /* End PBXFileReference section */ +/* Begin PBXFileSystemSynchronizedRootGroup section */ + 119154B72E12FA4B006C75E6 /* Constants */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = Constants; sourceTree = ""; }; +/* End PBXFileSystemSynchronizedRootGroup section */ + /* Begin PBXFrameworksBuildPhase section */ 8848C82C2B0D04BC007B434F /* Frameworks */ = { isa = PBXFrameworksBuildPhase; @@ -144,6 +148,7 @@ 8848C8262B0D04BC007B434F = { isa = PBXGroup; children = ( + 119154B72E12FA4B006C75E6 /* Constants */, DEFECAA82D7B4CCD00EF9621 /* ImagenScreen */, 88B8A9352B0FCBA700424728 /* GenerativeAIUIComponents */, 869200B22B879C4F00482873 /* GoogleService-Info.plist */, @@ -302,6 +307,9 @@ ); dependencies = ( ); + fileSystemSynchronizedGroups = ( + 119154B72E12FA4B006C75E6 /* Constants */, + ); name = FirebaseAIExample; packageProductDependencies = ( 886F95D72B17BA420036F07A /* MarkdownUI */, diff --git a/firebaseai/FunctionCallingExample/ViewModels/FunctionCallingViewModel.swift b/firebaseai/FunctionCallingExample/ViewModels/FunctionCallingViewModel.swift index 8bd7f90ef..ce3093412 100644 --- a/firebaseai/FunctionCallingExample/ViewModels/FunctionCallingViewModel.swift +++ b/firebaseai/FunctionCallingExample/ViewModels/FunctionCallingViewModel.swift @@ -39,7 +39,7 @@ class FunctionCallingViewModel: ObservableObject { init(firebaseService: FirebaseAI) { // Accept FirebaseAI instance model = firebaseService.generativeModel( - modelName: "gemini-2.0-flash-001", + modelName: ModelNames.geminiFlash, tools: [.functionDeclarations([ FunctionDeclaration( name: "get_exchange_rate", diff --git a/firebaseai/GenerativeAIMultimodalExample/ViewModels/PhotoReasoningViewModel.swift b/firebaseai/GenerativeAIMultimodalExample/ViewModels/PhotoReasoningViewModel.swift index 24a2e96e2..d5b96e7e4 100644 --- a/firebaseai/GenerativeAIMultimodalExample/ViewModels/PhotoReasoningViewModel.swift +++ b/firebaseai/GenerativeAIMultimodalExample/ViewModels/PhotoReasoningViewModel.swift @@ -44,7 +44,7 @@ class PhotoReasoningViewModel: ObservableObject { private var model: GenerativeModel? init(firebaseService: FirebaseAI) { - model = firebaseService.generativeModel(modelName: "gemini-2.0-flash-001") + model = firebaseService.generativeModel(modelName: ModelNames.geminiFlash) } func reason() async { diff --git a/firebaseai/GenerativeAITextExample/ViewModels/GenerateContentViewModel.swift b/firebaseai/GenerativeAITextExample/ViewModels/GenerateContentViewModel.swift index a9272ef5b..2f5f3f069 100644 --- a/firebaseai/GenerativeAITextExample/ViewModels/GenerateContentViewModel.swift +++ b/firebaseai/GenerativeAITextExample/ViewModels/GenerateContentViewModel.swift @@ -32,7 +32,7 @@ class GenerateContentViewModel: ObservableObject { private var model: GenerativeModel? init(firebaseService: FirebaseAI) { - model = firebaseService.generativeModel(modelName: "gemini-2.0-flash-001") + model = firebaseService.generativeModel(modelName: ModelNames.geminiFlash) } func generateContent(inputText: String) async { diff --git a/firebaseai/ImagenScreen/ImagenViewModel.swift b/firebaseai/ImagenScreen/ImagenViewModel.swift index d4fc2b43f..38e737431 100644 --- a/firebaseai/ImagenScreen/ImagenViewModel.swift +++ b/firebaseai/ImagenScreen/ImagenViewModel.swift @@ -38,7 +38,7 @@ class ImagenViewModel: ObservableObject { private var generateImagesTask: Task? init(firebaseService: FirebaseAI) { - let modelName = "imagen-3.0-generate-002" + let modelName = ModelNames.imagenGenerate let safetySettings = ImagenSafetySettings( safetyFilterLevel: .blockLowAndAbove )