@@ -55,8 +55,7 @@ import okhttp3.MediaType.Companion.toMediaType
5555import okhttp3.OkHttpClient
5656import okhttp3.Request
5757import okhttp3.RequestBody.Companion.toRequestBody
58- import java.io.File
59- import java.io.FileOutputStream
58+ import java.io.File `nimport java.io.IOException `nimport java.io.FileOutputStream
6059import java.text.SimpleDateFormat
6160import java.util.Date
6261import java.util.Locale
@@ -770,25 +769,25 @@ private suspend fun callVercelApi(
770769 context : android.content.Context ,
771770 modelName : String ,
772771 apiKey : String ,
773- chatHistory : List <com.google.ai.sample.feature.multimodal. ContentDto >,
774- inputContent : com.google.ai.sample.feature.multimodal. ContentDto
772+ chatHistory : List <ContentDto >,
773+ inputContent : ContentDto
775774): String {
776775 val messages = mutableListOf<VercelMessage >()
777776
778777 // Add Chat History
779778 chatHistory.forEach { contentDto ->
780779 val role = if (contentDto.role == " user" ) " user" else " assistant"
781- val text = contentDto.parts.filterIsInstance< com.google.ai.sample.feature.multimodal.TextPartDto > ()
780+ val text = contentDto.parts.filterIsInstance< com.google.ai.sample.feature.multimodal.dtos. TextPartDto > ()
782781 .joinToString(" \n " ) { it.text }
783782 if (text.isNotBlank()) messages.add(VercelMessage (role = role, content = text))
784783 }
785784
786785 // Add current input
787- val inputText = inputContent.parts.filterIsInstance< com.google.ai.sample.feature.multimodal.TextPartDto > ()
786+ val inputText = inputContent.parts.filterIsInstance< com.google.ai.sample.feature.multimodal.dtos. TextPartDto > ()
788787 .joinToString(" \n " ) { it.text }
789788 if (inputText.isNotBlank()) messages.add(VercelMessage (role = " user" , content = inputText))
790789
791- val requestBodyJson = Json .encodeToString(VercelRequest (model = modelName, messages = messages, stream = true ))
790+ val requestBodyJson = Json .encodeToString(VercelRequest .serializer(), VercelRequest (model = modelName, messages = messages, stream = true ))
792791 val mediaType = " application/json" .toMediaType()
793792
794793 val httpRequest = Request .Builder ()
@@ -920,7 +919,7 @@ private suspend fun callMistralApi(modelName: String, apiKey: String, chatHistor
920919 is TextPart -> if (part.text.isNotBlank()) ServiceMistralTextContent (text = part.text) else null
921920 is ImagePart -> {
922921 if (supportsScreenshot) {
923- ServiceMistralImageContent (imageUrl = ServiceMistralImageUrl (url = part. image.toBase64() ))
922+ ServiceMistralImageContent (imageUrl = ServiceMistralImageUrl (url = " data: image/jpeg;base64, ${com.google.ai.sample.util. ImageUtils .bitmapToBase64(part.image)} " ))
924923 } else null
925924 }
926925 else -> null
0 commit comments