Skip to content
Draft
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 @@ -55,7 +55,9 @@ class GoogleAISnippets : ViewModel() {
// Specify the config as part of creating the `GenerativeModel` instance
val model =
Firebase.ai(backend = GenerativeBackend.googleAI())
.generativeModel(modelName = "gemini-2.5-flash", generationConfig = config)
.generativeModel(
modelName = "gemini-2.5-flash",
generationConfig = config)

// ...
// [END model_parameters_general]
Expand All @@ -79,7 +81,9 @@ class GoogleAISnippets : ViewModel() {
// Specify the config as part of creating the `GenerativeModel` instance
val model =
Firebase.ai(backend = GenerativeBackend.vertexAI())
.imagenModel(modelName = "imagen-4.0-generate-001", generationConfig = config)
.imagenModel(
modelName = "imagen-4.0-generate-001",
generationConfig = config)

// ...
// [END model_parameters_imagen]
Expand All @@ -104,7 +108,9 @@ class GoogleAISnippets : ViewModel() {
// Specify the config as part of creating the `LiveModel` instance
val model =
Firebase.ai(backend = GenerativeBackend.googleAI())
.liveModel(modelName = "gemini-2.5-flash", generationConfig = config)
.liveModel(
modelName = "gemini-2.5-flash",
generationConfig = config)

// ...
// [END model_parameters_live]
Expand Down Expand Up @@ -165,21 +171,23 @@ class GoogleAISnippets : ViewModel() {
fun systemInstructions_general() {
// [START system_instructions_general]
// Specify the system instructions as part of creating the `GenerativeModel` instance
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
modelName = "gemini-2.5-flash",
systemInstruction = content { text("You are a cat. Your name is Neko.") }
)
val model = Firebase.ai(backend = GenerativeBackend.googleAI())
.generativeModel(
modelName = "gemini-2.5-flash",
systemInstruction = content { text("You are a cat. Your name is Neko.") }
)
// [END system_instructions_general]
}

@OptIn(PublicPreviewAPI::class)
fun systemInstructions_live() {
// [START system_instructions_live]
// Specify the system instructions as part of creating the `LiveModel` instance
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).liveModel(
modelName = "gemini-2.5-flash",
systemInstruction = content { text("You are a cat. Your name is Neko.") }
)
val model = Firebase.ai(backend = GenerativeBackend.googleAI())
.liveModel(
modelName = "gemini-2.5-flash",
systemInstruction = content { text("You are a cat. Your name is Neko.") }
)
// [END system_instructions_live]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ class VertexAISnippets : ViewModel() {
// Specify the config as part of creating the `GenerativeModel` instance
val model =
Firebase.ai(backend = GenerativeBackend.vertexAI())
.generativeModel(modelName = "gemini-2.5-flash", generationConfig = config)
.generativeModel(
modelName = "gemini-2.5-flash",
generationConfig = config)

// ...
// [END model_parameters_general]
Expand All @@ -80,7 +82,9 @@ class VertexAISnippets : ViewModel() {
// Specify the config as part of creating the `GenerativeModel` instance
val model =
Firebase.ai(backend = GenerativeBackend.vertexAI())
.imagenModel(modelName = "imagen-4.0-generate-001", generationConfig = config)
.imagenModel(
modelName = "imagen-4.0-generate-001",
generationConfig = config)

// ...
// [END model_parameters_imagen]
Expand All @@ -105,7 +109,9 @@ class VertexAISnippets : ViewModel() {
// Specify the config as part of creating the `LiveModel` instance
val model =
Firebase.ai(backend = GenerativeBackend.vertexAI())
.liveModel(modelName = "gemini-2.5-flash", generationConfig = config)
.liveModel(
modelName = "gemini-2.5-flash",
generationConfig = config)

// ...
// [END model_parameters_live]
Expand Down Expand Up @@ -166,21 +172,23 @@ class VertexAISnippets : ViewModel() {
fun systemInstructions_general() {
// [START system_instructions_general]
// Specify the system instructions as part of creating the `GenerativeModel` instance
val model = Firebase.ai(backend = GenerativeBackend.vertexAI()).generativeModel(
modelName = "gemini-2.5-flash",
systemInstruction = content { text("You are a cat. Your name is Neko.") }
)
val model = Firebase.ai(backend = GenerativeBackend.vertexAI())
.generativeModel(
modelName = "gemini-2.5-flash",
systemInstruction = content { text("You are a cat. Your name is Neko.") }
)
// [END system_instructions_general]
}

@OptIn(PublicPreviewAPI::class)
fun systemInstructions_live() {
// [START system_instructions_live]
// Specify the system instructions as part of creating the `LiveModel` instance
val model = Firebase.ai(backend = GenerativeBackend.vertexAI()).liveModel(
modelName = "gemini-2.5-flash",
systemInstruction = content { text("You are a cat. Your name is Neko.") }
)
val model = Firebase.ai(backend = GenerativeBackend.vertexAI())
.liveModel(
modelName = "gemini-2.5-flash",
systemInstruction = content { text("You are a cat. Your name is Neko.") }
)
// [END system_instructions_live]
}
}