From 5aca910d369fa7cbb16097c570d9c40d3ed7c410 Mon Sep 17 00:00:00 2001 From: Jolanda Verhoef Date: Fri, 14 Nov 2025 15:22:31 +0100 Subject: [PATCH 1/3] Add function ids to Live Todo sample. Omitting them can cause problematic behavior in some of the backend models. Change-Id: I9c54234bdba922b918ce5eee3fba52d953fc7bcb --- .../geminilivetodo/ui/TodoScreenViewModel.kt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/samples/gemini-live-todo/src/main/java/com/android/ai/samples/geminilivetodo/ui/TodoScreenViewModel.kt b/samples/gemini-live-todo/src/main/java/com/android/ai/samples/geminilivetodo/ui/TodoScreenViewModel.kt index f7f3d9d2..b524ee2f 100644 --- a/samples/gemini-live-todo/src/main/java/com/android/ai/samples/geminilivetodo/ui/TodoScreenViewModel.kt +++ b/samples/gemini-live-todo/src/main/java/com/android/ai/samples/geminilivetodo/ui/TodoScreenViewModel.kt @@ -161,6 +161,8 @@ class TodoScreenViewModel @Inject constructor(private val todoRepository: TodoRe val generativeModel = Firebase.ai(backend = GenerativeBackend.vertexAI()).liveModel( "gemini-2.0-flash-live-preview-04-09", +// "gemini-live-2.5-flash-preview", // Or try with a newer model +// "gemini-2.5-flash-native-audio-preview-09-2025", // Or try with native audio generationConfig = liveGenerationConfig, systemInstruction = systemInstruction, tools = listOf( @@ -191,7 +193,7 @@ class TodoScreenViewModel @Inject constructor(private val todoRepository: TodoRe "message" to JsonPrimitive("List of tasks in the todo list: $todoList"), ), ) - FunctionResponsePart(functionCall.name, response) + FunctionResponsePart(functionCall.name, response, functionCall.id) } "addTodo" -> { val taskDescription = functionCall.args["taskDescription"]!!.jsonPrimitive.content @@ -204,7 +206,7 @@ class TodoScreenViewModel @Inject constructor(private val todoRepository: TodoRe "message" to JsonPrimitive("Task $taskDescription added to the todo list (id: $id)"), ), ) - FunctionResponsePart(functionCall.name, response) + FunctionResponsePart(functionCall.name, response, functionCall.id) } else { val response = JsonObject( mapOf( @@ -212,7 +214,7 @@ class TodoScreenViewModel @Inject constructor(private val todoRepository: TodoRe "message" to JsonPrimitive("Task $taskDescription wasn't properly added to the list"), ), ) - FunctionResponsePart(functionCall.name, response) + FunctionResponsePart(functionCall.name, response, functionCall.id) } } @@ -226,7 +228,7 @@ class TodoScreenViewModel @Inject constructor(private val todoRepository: TodoRe "message" to JsonPrimitive("Task was removed from the todo list"), ), ) - FunctionResponsePart(functionCall.name, response) + FunctionResponsePart(functionCall.name, response, functionCall.id) } catch (e: Exception) { val response = JsonObject( mapOf( @@ -234,7 +236,7 @@ class TodoScreenViewModel @Inject constructor(private val todoRepository: TodoRe "message" to JsonPrimitive("Something went wrong: ${e.message}"), ), ) - FunctionResponsePart(functionCall.name, response) + FunctionResponsePart(functionCall.name, response, functionCall.id) } } @@ -247,13 +249,13 @@ class TodoScreenViewModel @Inject constructor(private val todoRepository: TodoRe "message" to JsonPrimitive("Task was toggled in the todo list"), ), ) - FunctionResponsePart(functionCall.name, response) + FunctionResponsePart(functionCall.name, response, functionCall.id) } else -> { val response = JsonObject( mapOf("error" to JsonPrimitive("Unknown function: ${functionCall.name}")), ) - FunctionResponsePart(functionCall.name, response) + FunctionResponsePart(functionCall.name, response, functionCall.id) } } } From 0ee12c8e852c841ba3e24e858fc5e914553d2755 Mon Sep 17 00:00:00 2001 From: Jolanda Verhoef Date: Mon, 17 Nov 2025 13:41:17 +0100 Subject: [PATCH 2/3] List all possible models including deprecation notice Change-Id: I9c13ae5eb448a540a5bee970ed7d74add2531459 --- .../samples/geminilivetodo/ui/TodoScreenViewModel.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/samples/gemini-live-todo/src/main/java/com/android/ai/samples/geminilivetodo/ui/TodoScreenViewModel.kt b/samples/gemini-live-todo/src/main/java/com/android/ai/samples/geminilivetodo/ui/TodoScreenViewModel.kt index b524ee2f..d8e42be9 100644 --- a/samples/gemini-live-todo/src/main/java/com/android/ai/samples/geminilivetodo/ui/TodoScreenViewModel.kt +++ b/samples/gemini-live-todo/src/main/java/com/android/ai/samples/geminilivetodo/ui/TodoScreenViewModel.kt @@ -159,10 +159,12 @@ class TodoScreenViewModel @Inject constructor(private val todoRepository: TodoRe emptyMap(), ) - val generativeModel = Firebase.ai(backend = GenerativeBackend.vertexAI()).liveModel( - "gemini-2.0-flash-live-preview-04-09", -// "gemini-live-2.5-flash-preview", // Or try with a newer model -// "gemini-2.5-flash-native-audio-preview-09-2025", // Or try with native audio + val generativeModel = Firebase.ai(backend = GenerativeBackend.googleAI()).liveModel( + "gemini-2.5-flash-native-audio-preview-09-2025", // available through googleAI() +// "gemini-live-2.5-flash-preview", // available through googleAI(), to be deprecated on Dec 9th 2025. +// "gemini-2.0-flash-live-001", // available through googleAI(), to be deprecated on Dec 9th 2025. +// "gemini-2.0-flash-live-preview-04-09", // available through vertexAI() +// "gemini-live-2.5-flash-preview-native-audio-09-2025", // available through vertexAI() generationConfig = liveGenerationConfig, systemInstruction = systemInstruction, tools = listOf( From de31b26e55b54501c2d686f61f7baf89810a35ed Mon Sep 17 00:00:00 2001 From: Jolanda Verhoef Date: Mon, 17 Nov 2025 18:17:28 +0100 Subject: [PATCH 3/3] Remove full list, link to Firebase docs instead. Change-Id: I854be3c2bd9f19ca913ffb246e88529d01098a47 --- .../ai/samples/geminilivetodo/ui/TodoScreenViewModel.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/samples/gemini-live-todo/src/main/java/com/android/ai/samples/geminilivetodo/ui/TodoScreenViewModel.kt b/samples/gemini-live-todo/src/main/java/com/android/ai/samples/geminilivetodo/ui/TodoScreenViewModel.kt index d8e42be9..7106da2a 100644 --- a/samples/gemini-live-todo/src/main/java/com/android/ai/samples/geminilivetodo/ui/TodoScreenViewModel.kt +++ b/samples/gemini-live-todo/src/main/java/com/android/ai/samples/geminilivetodo/ui/TodoScreenViewModel.kt @@ -159,12 +159,9 @@ class TodoScreenViewModel @Inject constructor(private val todoRepository: TodoRe emptyMap(), ) + // See https://firebase.google.com/docs/ai-logic/live-api for an overview of available models val generativeModel = Firebase.ai(backend = GenerativeBackend.googleAI()).liveModel( - "gemini-2.5-flash-native-audio-preview-09-2025", // available through googleAI() -// "gemini-live-2.5-flash-preview", // available through googleAI(), to be deprecated on Dec 9th 2025. -// "gemini-2.0-flash-live-001", // available through googleAI(), to be deprecated on Dec 9th 2025. -// "gemini-2.0-flash-live-preview-04-09", // available through vertexAI() -// "gemini-live-2.5-flash-preview-native-audio-09-2025", // available through vertexAI() + "gemini-2.5-flash-native-audio-preview-09-2025", generationConfig = liveGenerationConfig, systemInstruction = systemInstruction, tools = listOf(