Skip to content

Update gemini version to 2.5-flash in firebaseai #1723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ConversationViewModel: ObservableObject {
private var chatTask: Task<Void, Never>?

init(firebaseService: FirebaseAI) {
model = firebaseService.generativeModel(modelName: "gemini-2.0-flash-001")
model = firebaseService.generativeModel(modelName: ModelNames.geminiFlash)
chat = model.startChat()
}

Expand Down
18 changes: 18 additions & 0 deletions firebaseai/Constants/ModelNames.swift
Original file line number Diff line number Diff line change
@@ -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"
}
10 changes: 9 additions & 1 deletion firebaseai/FirebaseAIExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 56;
objectVersion = 70;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -63,6 +63,10 @@
DEFECAA72D7B4CCD00EF9621 /* ImagenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagenViewModel.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFileSystemSynchronizedRootGroup section */
119154B72E12FA4B006C75E6 /* Constants */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = Constants; sourceTree = "<group>"; };
/* End PBXFileSystemSynchronizedRootGroup section */

/* Begin PBXFrameworksBuildPhase section */
8848C82C2B0D04BC007B434F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
Expand Down Expand Up @@ -144,6 +148,7 @@
8848C8262B0D04BC007B434F = {
isa = PBXGroup;
children = (
119154B72E12FA4B006C75E6 /* Constants */,
DEFECAA82D7B4CCD00EF9621 /* ImagenScreen */,
88B8A9352B0FCBA700424728 /* GenerativeAIUIComponents */,
869200B22B879C4F00482873 /* GoogleService-Info.plist */,
Expand Down Expand Up @@ -302,6 +307,9 @@
);
dependencies = (
);
fileSystemSynchronizedGroups = (
119154B72E12FA4B006C75E6 /* Constants */,
);
name = FirebaseAIExample;
packageProductDependencies = (
886F95D72B17BA420036F07A /* MarkdownUI */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion firebaseai/ImagenScreen/ImagenViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ImagenViewModel: ObservableObject {
private var generateImagesTask: Task<Void, Never>?

init(firebaseService: FirebaseAI) {
let modelName = "imagen-3.0-generate-002"
let modelName = ModelNames.imagenGenerate
let safetySettings = ImagenSafetySettings(
safetyFilterLevel: .blockLowAndAbove
)
Expand Down