Skip to content

Commit ee7d7f9

Browse files
Fix: Resolve type mismatch in PhotoReasoningViewModel.reason() for imageUris.
Corrected a build error caused by a type mismatch when creating a PhotoReasoningMessage within the `reason` method. The `imageUrisForChat` parameter (List<String>?) was being assigned to the `imageUris` field, which expected a non-nullable List<String>. The fix uses the Elvis operator to provide `emptyList()` if `imageUrisForChat` is null: `imageUris = imageUrisForChat ?: emptyList()` This ensures a non-nullable list is always passed, resolving the compilation error and maintaining the intended logic for displaying images in chat messages.
1 parent 4c643eb commit ee7d7f9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class PhotoReasoningViewModel(
137137
val userMessage = PhotoReasoningMessage(
138138
text = aiPromptText, // Use the combined text
139139
participant = PhotoParticipant.USER,
140-
imageUris = imageUrisForChat, // Use the new parameter here
140+
imageUris = imageUrisForChat ?: emptyList(), // Use the new parameter here
141141
isPending = false
142142
)
143143
_chatState.addMessage(userMessage)

0 commit comments

Comments
 (0)