Skip to content

Instantly share code, notes, and snippets.

@skydoves
Last active February 5, 2024 05:20
Show Gist options
  • Save skydoves/fac89f38d17f24d4e39d2cc0be180a13 to your computer and use it in GitHub Desktop.
Save skydoves/fac89f38d17f24d4e39d2cc0be180a13 to your computer and use it in GitHub Desktop.
photo_reasoning_gemini
private suspend fun photoReasoning(message: Message, bitmaps: List<Bitmap>): String? {
val text = message.text
val prompt = "Look at the image(s), and then answer the following question: $text"
val content = content {
for (bitmap in bitmaps) {
image(bitmap)
}
text(prompt)
}
val response = generativeModel.generateContent(content)
val responseText = response.text
if (responseText != null) {
channelClient.sendMessage(
message = Message(
id = UUID.randomUUID().toString(),
cid = channelClient.cid,
text = responseText,
extraData = mutableMapOf(STREAM_CHANNEL_GEMINI_FLAG to true)
)
).await()
}
return responseText
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment