Skip to content

refactor(ai-logic): use vertexAI() for samples that use Cloud Storage #2675

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

Merged
merged 1 commit into from
Jun 13, 2025
Merged
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
2 changes: 1 addition & 1 deletion firebase-ai/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("org.jetbrains.kotlin.plugin.compose")
kotlin("plugin.serialization") version "2.1.20"
kotlin("plugin.serialization") version "2.1.21"
id("com.google.gms.google-services")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.google.firebase.quickstart.ai

import com.google.firebase.ai.type.GenerativeBackend
import com.google.firebase.ai.type.ResponseModality
import com.google.firebase.ai.type.content
import com.google.firebase.ai.type.generationConfig
Expand Down Expand Up @@ -86,10 +87,11 @@ val FIREBASE_AI_SAMPLES = listOf(
}
),
Sample(
title = "Translation from audio",
description = "Translate an audio file",
title = "Translation from audio (Vertex AI)",
description = "Translate an audio file stored in Cloud Storage",
navRoute = "chat",
categories = listOf(Category.AUDIO),
backend = GenerativeBackend.vertexAI(),
initialPrompt = content {
fileData(
"https://storage.googleapis.com/cloud-samples-data/generative-ai/audio/" +
Expand All @@ -100,10 +102,11 @@ val FIREBASE_AI_SAMPLES = listOf(
}
),
Sample(
title = "Blog post creator",
description = "Create a blog post from an image file.",
title = "Blog post creator (Vertex AI)",
description = "Create a blog post from an image file stored in Cloud Storage.",
navRoute = "chat",
categories = listOf(Category.IMAGE),
backend = GenerativeBackend.vertexAI(),
initialPrompt = content {
fileData(
"https://storage.googleapis.com/cloud-samples-data/generative-ai/image/meal-prep.jpeg",
Expand Down Expand Up @@ -145,10 +148,12 @@ val FIREBASE_AI_SAMPLES = listOf(
}
),
Sample(
title = "Document comparison",
description = "Compare the contents of 2 documents",
title = "Document comparison (Vertex AI)",
description = "Compare the contents of 2 documents." +
" Only supported by the Vertex AI Gemini API because the documents are stored in Cloud Storage",
navRoute = "chat",
categories = listOf(Category.DOCUMENT),
backend = GenerativeBackend.vertexAI(),
initialPrompt = content {
fileData(
"https://storage.googleapis.com/cloud-samples-data/generative-ai/pdf/form_1040_2013.pdf",
Expand All @@ -165,10 +170,11 @@ val FIREBASE_AI_SAMPLES = listOf(
}
),
Sample(
title = "Hashtags for a video",
description = "Generate hashtags for a video ad",
title = "Hashtags for a video (Vertex AI)",
description = "Generate hashtags for a video ad stored in Cloud Storage",
navRoute = "chat",
categories = listOf(Category.VIDEO),
backend = GenerativeBackend.vertexAI(),
initialPrompt = content {
fileData(
"https://storage.googleapis.com/cloud-samples-data/generative-ai/video/google_home_celebrity_ad.mp4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ChatViewModel(

init {
val generativeModel = Firebase.ai(
backend = GenerativeBackend.googleAI()
backend = sample.backend // GenerativeBackend.googleAI() by default
).generativeModel(
modelName = sample.modelName ?: "gemini-2.0-flash",
systemInstruction = sample.systemInstructions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.google.firebase.quickstart.ai.ui.navigation

import com.google.firebase.ai.type.Content
import com.google.firebase.ai.type.GenerationConfig
import com.google.firebase.ai.type.GenerativeBackend
import java.util.UUID

enum class Category(
Expand All @@ -22,6 +23,7 @@ data class Sample(
val categories: List<Category>,
// Optional parameters
val modelName: String? = null,
val backend: GenerativeBackend = GenerativeBackend.googleAI(),
val initialPrompt: Content? = null,
val systemInstructions: Content? = null,
val generationConfig: GenerationConfig? = null,
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
agp = "8.10.1"
coilCompose = "2.7.0"
firebaseBom = "33.15.0"
kotlin = "2.1.20"
kotlin = "2.1.21"
coreKtx = "1.16.0"
junit = "4.13.2"
junitVersion = "1.2.1"
Expand Down
Loading