Skip to content
Merged
Changes from 1 commit
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 @@ -161,6 +161,8 @@ class TodoScreenViewModel @Inject constructor(private val todoRepository: TodoRe

val generativeModel = Firebase.ai(backend = GenerativeBackend.vertexAI()).liveModel(
Comment thread
JolandaVerhoef marked this conversation as resolved.
Outdated
"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
Comment thread
JolandaVerhoef marked this conversation as resolved.
Outdated
generationConfig = liveGenerationConfig,
systemInstruction = systemInstruction,
tools = listOf(
Expand Down Expand Up @@ -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
Expand All @@ -204,15 +206,15 @@ 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(
"success" to JsonPrimitive(false),
"message" to JsonPrimitive("Task $taskDescription wasn't properly added to the list"),
),
)
FunctionResponsePart(functionCall.name, response)
FunctionResponsePart(functionCall.name, response, functionCall.id)
}

}
Expand All @@ -226,15 +228,15 @@ 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(
"success" to JsonPrimitive(false),
"message" to JsonPrimitive("Something went wrong: ${e.message}"),
),
)
FunctionResponsePart(functionCall.name, response)
FunctionResponsePart(functionCall.name, response, functionCall.id)
}

}
Expand All @@ -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)
}
}
}
Expand Down
Loading