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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AudioSummarizationViewModel : ChatViewModel() {
val generativeModel = Firebase.ai(
backend = GenerativeBackend.googleAI()
).generativeModel(
modelName = "gemini-2.5-flash"
modelName = "gemini-3.1-flash-lite-preview"
)
chat = generativeModel.startChat(
listOf(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.google.firebase.quickstart.ai.feature.text

import com.google.firebase.Firebase
import com.google.firebase.ai.Chat
import com.google.firebase.ai.ai
import com.google.firebase.ai.type.Content
import com.google.firebase.ai.type.GenerativeBackend
import com.google.firebase.ai.type.content
import com.google.firebase.quickstart.ai.ui.UiChatMessage
import kotlinx.serialization.Serializable

@Serializable
object TranslationRoute

class TranslationViewModel : ChatViewModel() {
override val initialPrompt: String
get() = """
Translate the following text to Spanish:
Hey, are you down to grab some pizza later? I'm starving!
""".trimIndent()

private val chat: Chat

init {
val generativeModel = Firebase.ai(
backend = GenerativeBackend.googleAI()
).generativeModel(
modelName = "gemini-3.1-flash-lite-preview",
systemInstruction = content {
text("Only output the translated text")
}
)

chat = generativeModel.startChat()
}

override suspend fun performSendMessage(
prompt: Content,
currentMessages: List<UiChatMessage>
) {
val response = chat.sendMessage(prompt)
validateAndDisplayResponse(response, currentMessages)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import com.google.firebase.quickstart.ai.feature.text.SvgRoute
import com.google.firebase.quickstart.ai.feature.text.SvgViewModel
import com.google.firebase.quickstart.ai.feature.text.ThinkingChatRoute
import com.google.firebase.quickstart.ai.feature.text.ThinkingChatViewModel
import com.google.firebase.quickstart.ai.feature.text.TranslationRoute
import com.google.firebase.quickstart.ai.feature.text.TranslationViewModel
import com.google.firebase.quickstart.ai.feature.text.TravelTipsRoute
import com.google.firebase.quickstart.ai.feature.text.TravelTipsViewModel
import com.google.firebase.quickstart.ai.feature.text.VideoHashtagGeneratorRoute
Expand All @@ -46,6 +48,14 @@ import com.google.firebase.quickstart.ai.feature.text.WeatherChatRoute
import com.google.firebase.quickstart.ai.feature.text.WeatherChatViewModel

val FIREBASE_AI_SAMPLES = listOf(
Sample(
title = "Translate text",
description = "Use Gemini 3.1 Flash-Lite to translate text",
route = TranslationRoute,
screenType = ScreenType.CHAT,
viewModelClass = TranslationViewModel::class,
categories = listOf(Category.TEXT)
),
Sample(
title = "Travel tips",
description = "The user wants the model to help a new traveler" +
Expand All @@ -65,7 +75,7 @@ val FIREBASE_AI_SAMPLES = listOf(
),
Sample(
title = "Audio Summarization",
description = "Summarize an audio file",
description = "Use Gemini 3.1 Flash Lite to summarize an audio file",
route = AudioSummarizationRoute,
screenType = ScreenType.CHAT,
viewModelClass = AudioSummarizationViewModel::class,
Expand Down Expand Up @@ -194,7 +204,7 @@ val FIREBASE_AI_SAMPLES = listOf(
route = GoogleSearchGroundingRoute,
screenType = ScreenType.CHAT,
viewModelClass = GoogleSearchGroundingViewModel::class,
categories = listOf(Category.TEXT, Category.DOCUMENT)
categories = listOf(Category.TEXT)
),
Sample(
title = "Server Prompt Template - Imagen",
Expand Down
Loading