Skip to content
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
4 changes: 2 additions & 2 deletions ai-catalog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Browse the samples inside the `/samples` folder:
- More to come...

> **Requires Firebase setup** the samples relying on Google Cloud models (Gemini Pro, Gemini Flash, etc...)
> require setting up a Firebase project and connecting the app to Firebase (read more [here](https://firebase.google.com/docs/vertex-ai/get-started?platform=android#set-up-firebase)).
> require setting up a Firebase project and connecting the app to Firebase (read more [here](https://firebase.google.com/docs/ai-logic/get-started?platform=android&api=dev#set-up-firebase)).
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The link in the README is updated to point to the Firebase AI Logic documentation, which is great. However, consider adding a brief explanation of what Firebase AI Logic is and why it's being used in this project. This would provide more context for users who are new to the project.


> 🚧 **Work-in-Progress:** we are working on bringing more samples into the application.

Expand All @@ -33,7 +33,7 @@ Browse the samples inside the `/samples` folder:
1. Clone the repository
2. Open the whole project in Android Studio.
3. Set up a Firebase project and connect your app to Firebase by adding your Firebase configuration
file (google-services.json) to the app. Read more [here](https://firebase.google.com/docs/vertex-ai/get-started?platform=android#set-up-firebase).
file (google-services.json) to the app. Read more [here](https://firebase.google.com/docs/ai-logic/get-started?platform=android&api=dev#set-up-firebase).
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Same comment as above, consider adding a brief explanation of what Firebase AI Logic is and why it's being used in this project.

3. Sync & Run `app` configuration

The app will open with the samples list screen that allows you to navigate throughout the different
Expand Down
2 changes: 1 addition & 1 deletion ai-catalog/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ dependencies {
implementation(libs.hilt.android)
implementation(libs.hilt.navigation.compose)
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.vertexai)
implementation(libs.firebase.ai)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The dependency libs.firebase.ai is added, replacing libs.firebase.vertexai. This is the correct change for migrating to Firebase AI Logic. Ensure that all necessary configurations and initializations related to the new dependency are also handled correctly in the code.

ksp(libs.hilt.compiler)

implementation(project(":samples:gemini-multimodal"))
Expand Down
5 changes: 2 additions & 3 deletions ai-catalog/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
agp = "8.8.0"
coilCompose = "3.1.0"
firebaseBom = "33.12.0"
firebaseBom = "33.14.0"
mlkitGenAi = "1.0.0-beta1"
kotlin = "2.1.0"
coreKtx = "1.15.0"
Expand All @@ -23,15 +23,14 @@ ksp = "2.1.0-1.0.29"
runtimeLivedata = "1.7.6"
material3Android = "1.3.1"
media3 = "1.6.1"
material3AndroidVersion = "1.3.2"
firebaseCommonKtx = "21.0.0"
uiToolingPreviewAndroid = "1.8.1"

[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
coil-compose = { module = "io.coil-kt.coil3:coil-compose", version.ref = "coilCompose" }
firebase-bom = { module = "com.google.firebase:firebase-bom", version.ref = "firebaseBom" }
firebase-vertexai = { group = "com.google.firebase", name = "firebase-vertexai" }
firebase-ai = { group = "com.google.firebase", name = "firebase-ai" }
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The dependency firebase-ai is added, replacing firebase-vertexai. This is the correct change for migrating to Firebase AI Logic. Ensure that the version is compatible with the rest of the Firebase dependencies.

firebase-common-ktx = { group = "com.google.firebase", name = "firebase-common-ktx", version.ref = "firebaseCommonKtx" }
genai-image-description = { module = "com.google.mlkit:genai-image-description", version.ref = "mlkitGenAi" }
genai-proofreading = { module = "com.google.mlkit:genai-proofreading", version.ref = "mlkitGenAi" }
Expand Down
2 changes: 1 addition & 1 deletion ai-catalog/samples/gemini-chatbot/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ dependencies {
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.material.icons.extended)
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.vertexai)
implementation(libs.firebase.ai)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The dependency libs.firebase.ai is added, replacing libs.firebase.vertexai. This is the correct change for migrating to Firebase AI Logic. Ensure that all necessary configurations and initializations related to the new dependency are also handled correctly in the code.

implementation(libs.hilt.android)
implementation(libs.hilt.navigation.compose)
implementation(libs.androidx.runtime.livedata)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ package com.android.ai.samples.geminichatbot
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.google.firebase.Firebase
import com.google.firebase.vertexai.type.HarmBlockThreshold
import com.google.firebase.vertexai.type.HarmCategory
import com.google.firebase.vertexai.type.SafetySetting
import com.google.firebase.vertexai.type.content
import com.google.firebase.vertexai.type.generationConfig
import com.google.firebase.vertexai.vertexAI
import com.google.firebase.ai.ai
import com.google.firebase.ai.type.GenerativeBackend
import com.google.firebase.ai.type.HarmBlockThreshold
import com.google.firebase.ai.type.HarmCategory
import com.google.firebase.ai.type.SafetySetting
import com.google.firebase.ai.type.content
import com.google.firebase.ai.type.generationConfig
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
Expand All @@ -37,7 +38,7 @@ class GeminiChatbotViewModel @Inject constructor(): ViewModel() {
val messageList: StateFlow<List<ChatMessage>> = _messageList

private val generativeModel by lazy {
Firebase.vertexAI.generativeModel(
Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
"gemini-2.0-flash",
generationConfig = generationConfig {
temperature = 0.9f
Expand All @@ -52,7 +53,7 @@ class GeminiChatbotViewModel @Inject constructor(): ViewModel() {
SafetySetting(HarmCategory.DANGEROUS_CONTENT, HarmBlockThreshold.MEDIUM_AND_ABOVE)
),
systemInstruction = content {
"""You are a friendly assistant. Keep your response short."""
text("""You are a friendly assistant. Keep your response short.""")
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion ai-catalog/samples/gemini-multimodal/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ dependencies {
implementation(libs.androidx.material.icons.extended)
implementation(libs.androidx.material.icons.extended)
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.vertexai)
implementation(libs.firebase.ai)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The dependency libs.firebase.ai is added, replacing libs.firebase.vertexai. This is the correct change for migrating to Firebase AI Logic. Ensure that all necessary configurations and initializations related to the new dependency are also handled correctly in the code.

implementation(libs.hilt.android)
implementation(libs.hilt.navigation.compose)
implementation(libs.androidx.runtime.livedata)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.google.firebase.Firebase
import com.google.firebase.vertexai.type.HarmBlockThreshold
import com.google.firebase.vertexai.type.HarmCategory
import com.google.firebase.vertexai.type.SafetySetting
import com.google.firebase.vertexai.type.content
import com.google.firebase.vertexai.type.generationConfig
import com.google.firebase.vertexai.vertexAI
import com.google.firebase.ai.ai
import com.google.firebase.ai.type.GenerativeBackend
import com.google.firebase.ai.type.HarmBlockThreshold
import com.google.firebase.ai.type.HarmCategory
import com.google.firebase.ai.type.SafetySetting
import com.google.firebase.ai.type.content
import com.google.firebase.ai.type.generationConfig
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
Expand All @@ -41,7 +42,7 @@ class GeminiMultimodalViewModel @Inject constructor(): ViewModel() {
val isGenerating: LiveData<Boolean> = _isGenerating

private val generativeModel by lazy {
Firebase.vertexAI.generativeModel(
Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
"gemini-2.0-flash",
generationConfig = generationConfig {
temperature = 0.9f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ dependencies {
implementation(libs.androidx.ui.tooling.preview.android)
ksp(libs.hilt.compiler)
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.vertexai)
implementation(libs.firebase.ai)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The dependency libs.firebase.ai is added, replacing libs.firebase.vertexai. This is the correct change for migrating to Firebase AI Logic. Ensure that all necessary configurations and initializations related to the new dependency are also handled correctly in the code.


// Media3 ExoPlayer
implementation(libs.androidx.media3.exoplayer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import android.util.Log
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.google.firebase.Firebase
import com.google.firebase.vertexai.type.content
import com.google.firebase.vertexai.vertexAI
import com.google.firebase.ai.ai
import com.google.firebase.ai.type.GenerativeBackend
import com.google.firebase.ai.type.content
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
Expand All @@ -50,7 +51,7 @@ class VideoSummarizationViewModel @Inject constructor() : ViewModel() {
_outputText.value = OutputTextState.Loading

try {
val generativeModel = Firebase.vertexAI.generativeModel("gemini-2.0-flash")
val generativeModel = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel("gemini-2.0-flash")

val requestContent = content {
fileData(videoSource.toString(), "video/mp4")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,21 @@
package com.android.ai.samples.genai_image_description

import android.content.Context
import android.graphics.Bitmap
import android.net.Uri
import android.provider.MediaStore
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.android.ai.samples.geminimultimodal.R
import com.google.mlkit.genai.common.FeatureStatus
import kotlinx.coroutines.guava.await
import com.google.mlkit.genai.imagedescription.ImageDescriber
import com.google.mlkit.genai.imagedescription.ImageDescriberOptions
import com.google.mlkit.genai.imagedescription.ImageDescription
import com.google.mlkit.genai.imagedescription.ImageDescriptionRequest
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.guava.await
import kotlinx.coroutines.launch
import javax.inject.Inject
import com.android.ai.samples.geminimultimodal.R

class GenAIImageDescriptionViewModel @Inject constructor() : ViewModel() {
private val _resultGenerated = MutableStateFlow("")
Expand Down
2 changes: 1 addition & 1 deletion ai-catalog/samples/imagen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dependencies {
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.material.icons.extended)
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.vertexai)
implementation(libs.firebase.ai)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The dependency libs.firebase.ai is added, replacing libs.firebase.vertexai. This is the correct change for migrating to Firebase AI Logic. Ensure that all necessary configurations and initializations related to the new dependency are also handled correctly in the code.

implementation(libs.hilt.android)
implementation(libs.hilt.navigation.compose)
implementation(libs.androidx.runtime.livedata)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.google.firebase.Firebase
import com.google.firebase.vertexai.type.ImagenAspectRatio
import com.google.firebase.vertexai.type.ImagenGenerationConfig
import com.google.firebase.vertexai.type.ImagenImageFormat
import com.google.firebase.vertexai.type.PublicPreviewAPI
import com.google.firebase.vertexai.vertexAI
import com.google.firebase.ai.ai
import com.google.firebase.ai.type.GenerativeBackend
import com.google.firebase.ai.type.ImagenAspectRatio
import com.google.firebase.ai.type.ImagenGenerationConfig
import com.google.firebase.ai.type.ImagenImageFormat
import com.google.firebase.ai.type.PublicPreviewAPI
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import javax.inject.Inject
Expand All @@ -41,13 +42,12 @@ class ImagenViewModel @Inject constructor(): ViewModel() {
val isGenerating: LiveData<Boolean> = _isGenerating

@OptIn(PublicPreviewAPI::class)
private val imagenModel = Firebase.vertexAI.imagenModel(
modelName = "imagen-3.0-generate-002",
private val imagenModel = Firebase.ai(backend = GenerativeBackend.vertexAI()).imagenModel(
modelName = "imagen-4.0-generate-preview-05-20",
Comment on lines +45 to +46
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The model name is updated to imagen-4.0-generate-preview-05-20. This is the correct change for updating to Imagen 4. Ensure that this model name is valid and available in the Firebase AI Logic environment.

generationConfig = ImagenGenerationConfig(
numberOfImages = 1,
aspectRatio = ImagenAspectRatio.SQUARE_1x1,
imageFormat = ImagenImageFormat.jpeg(compressionQuality = 75),
addWatermark = true
),
)

Expand Down
2 changes: 1 addition & 1 deletion ai-catalog/samples/magic-selfie/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies {
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.material.icons.extended)
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.vertexai)
implementation(libs.firebase.ai)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The dependency libs.firebase.ai is added, replacing libs.firebase.vertexai. This is the correct change for migrating to Firebase AI Logic. Ensure that all necessary configurations and initializations related to the new dependency are also handled correctly in the code.

implementation(libs.hilt.android)
implementation(libs.hilt.navigation.compose)
implementation(libs.androidx.runtime.livedata)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.google.firebase.Firebase
import com.google.firebase.vertexai.type.ImagenAspectRatio
import com.google.firebase.vertexai.type.ImagenGenerationConfig
import com.google.firebase.vertexai.type.ImagenImageFormat
import com.google.firebase.vertexai.type.PublicPreviewAPI
import com.google.firebase.vertexai.vertexAI
import com.google.firebase.ai.ai
import com.google.firebase.ai.type.GenerativeBackend
import com.google.firebase.ai.type.ImagenAspectRatio
import com.google.firebase.ai.type.ImagenGenerationConfig
import com.google.firebase.ai.type.ImagenImageFormat
import com.google.firebase.ai.type.PublicPreviewAPI
import com.google.mlkit.vision.common.InputImage
import com.google.mlkit.vision.segmentation.subject.SubjectSegmentation
import com.google.mlkit.vision.segmentation.subject.SubjectSegmenterOptions
Expand All @@ -48,13 +49,12 @@ class MagicSelfieViewModel @Inject constructor(): ViewModel() {
private val _progress = MutableLiveData<String?>(null)
val progress: LiveData<String?> = _progress

private val imagenModel = Firebase.vertexAI.imagenModel(
modelName = "imagen-3.0-generate-002",
private val imagenModel = Firebase.ai(backend = GenerativeBackend.vertexAI()).imagenModel(
modelName = "imagen-4.0-generate-preview-05-20",
Comment on lines +52 to +53
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The model name is updated to imagen-4.0-generate-preview-05-20. This is the correct change for updating to Imagen 4. Ensure that this model name is valid and available in the Firebase AI Logic environment.

generationConfig = ImagenGenerationConfig(
numberOfImages = 1,
aspectRatio = ImagenAspectRatio.PORTRAIT_3x4,
imageFormat = ImagenImageFormat.jpeg(compressionQuality = 75),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The addWatermark parameter is removed from the ImagenGenerationConfig. This is likely due to changes in the Imagen 4 API. Verify that the removal of the watermark does not violate any usage policies or requirements.

addWatermark = true
),
)

Expand Down