Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gemini API multimodal support #81

Merged
merged 1 commit into from
Jun 27, 2024
Merged

Gemini API multimodal support #81

merged 1 commit into from
Jun 27, 2024

Conversation

lethargicpanda
Copy link
Contributor

Add image support in chat via Gemini API chatbot feature.

@@ -114,7 +118,17 @@ class ChatRepository @Inject internal constructor(

// Send a message prompt to the model to generate a response
var response = try {
chat.sendMessage(text).text?.trim() ?: "..."
if (mediaMimeType?.contains("image") == true) {
val inputStream: InputStream? = appContext.contentResolver.openInputStream(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using appContext.contentResolver.openInputStream?.use? This let you close input stream automatically.

Copy link
Contributor

@calren calren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to work for me! I took a picture of my dog and his toy and the Sheep made a comment about the toy.

sheep

also ran into this issue when testing #82, but it's unrelated to this PR

Add image support in chat
@lethargicpanda lethargicpanda merged commit 7a62784 into main Jun 27, 2024
2 checks passed
@lethargicpanda lethargicpanda deleted the gemini-multimodal branch June 27, 2024 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants