Skip to content

Commit 2faf8ba

Browse files
author
Claude Code Cleanup
committed
Fix build: restore accidentally deleted content import and reasonInLiveMode
The previous cleanup commit incorrectly removed the SDK content{} builder import (still used by performReasoning) and accidentally deleted reasonInLiveMode along with the actually-dead code around it. Both are restored; the dead-code removal itself (reasonWithMistral, reasonWithPuter, reasonWithCerebras, reasonInRegularMode, routeProviderSpecificReasoning, Mistral auto-screenshot queue) is unaffected.
1 parent 46ef1a5 commit 2faf8ba

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

app/src/main/kotlin/com/google/ai/sample/feature/multimodal/PhotoReasoningViewModel.kt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import androidx.lifecycle.AndroidViewModel
1515
import androidx.lifecycle.viewModelScope
1616
import com.google.ai.client.generativeai.Chat
1717
import com.google.ai.client.generativeai.GenerativeModel
18+
import com.google.ai.client.generativeai.type.content
1819
import com.google.ai.client.generativeai.type.Content
1920
import com.google.ai.client.generativeai.type.ImagePart // For instance check
2021
import com.google.ai.client.generativeai.type.GenerationConfig
@@ -1055,6 +1056,42 @@ class PhotoReasoningViewModel(
10551056
}
10561057
}
10571058

1059+
private fun reasonInLiveMode(
1060+
userInput: String,
1061+
selectedImages: List<Bitmap>,
1062+
screenInfoForPrompt: String?,
1063+
imageUrisForChat: List<String>?,
1064+
currentModel: ModelOption
1065+
) {
1066+
viewModelScope.launch {
1067+
try {
1068+
if (liveApiManager?.connectionState?.value != LiveApiManager.ConnectionState.CONNECTED) {
1069+
liveApiManager?.connect()
1070+
delay(2000)
1071+
}
1072+
1073+
val combinedPromptText = PhotoReasoningTextPolicies.buildPromptWithScreenInfo(userInput, screenInfoForPrompt)
1074+
val userMessage = PhotoReasoningMessage(
1075+
text = combinedPromptText,
1076+
participant = PhotoParticipant.USER,
1077+
imageUris = if (currentModel.supportsScreenshot) (imageUrisForChat ?: emptyList()) else emptyList(),
1078+
isPending = false
1079+
)
1080+
appendUserAndPendingModelMessages(userMessage)
1081+
_uiState.value = PhotoReasoningUiState.Loading
1082+
1083+
val imageDataList = selectedImages.map { PhotoReasoningSerialization.bitmapToBase64(it) }
1084+
val prompt = "FOLLOW THE INSTRUCTIONS STRICTLY: $combinedPromptText"
1085+
liveApiManager?.sendMessage(prompt, imageDataList.ifEmpty { null })
1086+
} catch (e: Exception) {
1087+
Log.e(TAG, "Error in live mode reasoning", e)
1088+
_uiState.value = PhotoReasoningUiState.Error(e.message ?: "Unknown error")
1089+
appendErrorMessage("Error: ${e.message}")
1090+
saveChatHistoryForApplication()
1091+
}
1092+
}
1093+
}
1094+
10581095
private fun appendUserAndPendingModelMessages(userMessage: PhotoReasoningMessage) {
10591096
_chatMessagesFlow.value = PhotoReasoningMessageMutations.appendUserAndPendingModelMessages(
10601097
chatState = _chatState,

0 commit comments

Comments
 (0)