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 1 commit
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: "gemini-2.5-flash")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While updating the model name is the goal of this PR, I've noticed that this model name string is hardcoded in multiple places (at least in this file, FunctionCallingViewModel, PhotoReasoningViewModel, and GenerateContentViewModel). This can lead to maintenance issues in the future if the model needs to be updated again, as it would be easy to miss one of the locations.

To improve maintainability and adhere to the Don't Repeat Yourself (DRY) principle, I recommend defining this model name as a shared constant.

For example, you could create a constants file or add it to a shared scope:

// In a shared constants file, e.g., ModelConstants.swift
enum ModelName {
  static let geminiFlash = "gemini-2.5-flash"
}

// Then use it like this:
model = firebaseService.generativeModel(modelName: ModelName.geminiFlash)

This would centralize the model name, making future updates safer and easier.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for defining a constant, but in the long run, I would prefer:

  1. Using Remote Config. This would educate users how to use Remote Config for remotely specifying which model to use.
  2. Look up available models and let the user choose via a picker

chat = model.startChat()
}

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: "gemini-2.5-flash",
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: "gemini-2.5-flash")
}

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: "gemini-2.5-flash")
}

func generateContent(inputText: String) async {
Expand Down