File tree Expand file tree Collapse file tree
app/src/main/kotlin/com/google/ai/sample/feature/multimodal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2161,7 +2161,29 @@ class PhotoReasoningViewModel(
21612161 saveChatHistory(context)
21622162 }
21632163
2164- private fun createGenericScreenshotPrompt (): String = " "
2164+ private fun createGenericScreenshotPrompt (): String {
2165+ val lastUserMessage = _chatState .getAllMessages()
2166+ .asReversed()
2167+ .firstOrNull { it.participant == PhotoParticipant .USER && it.text.isNotBlank() }
2168+ ?.text
2169+ ?.trim()
2170+
2171+ if (! lastUserMessage.isNullOrBlank()) {
2172+ return lastUserMessage
2173+ }
2174+
2175+ val persistedInput = _userInput .value.trim()
2176+ if (persistedInput.isNotBlank()) {
2177+ return persistedInput
2178+ }
2179+
2180+ val lastKnownInput = currentUserInput.trim()
2181+ if (lastKnownInput.isNotBlank()) {
2182+ return lastKnownInput
2183+ }
2184+
2185+ return " "
2186+ }
21652187
21662188 /* *
21672189 * Update the system message
You can’t perform that action at this time.
0 commit comments