File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,10 @@ public class GenerateContentResponse(
4646
4747 /* * Convenience field to list all the [InlineDataPart]s in the response, if they exist. */
4848 public val inlineDataParts: List <InlineDataPart > by lazy {
49- candidates.first().content.parts.filterIsInstance<InlineDataPart >()
49+ candidates.first().content.parts.let { parts ->
50+ parts.filterIsInstance<ImagePart >().map { it.toInlineDataPart() } +
51+ parts.filterIsInstance<InlineDataPart >()
52+ }
5053 }
5154
5255 @Serializable
Original file line number Diff line number Diff line change @@ -45,7 +45,14 @@ public class TextPart(public val text: String) : Part {
4545 *
4646 * @param image [Bitmap] to convert into a [Part]
4747 */
48- public class ImagePart (public val image : Bitmap ) : Part
48+ public class ImagePart (public val image : Bitmap ) : Part {
49+
50+ internal fun toInlineDataPart () =
51+ InlineDataPart (
52+ android.util.Base64 .decode(encodeBitmapToBase64Png(image), BASE_64_FLAGS ),
53+ " image/jpeg"
54+ )
55+ }
4956
5057/* *
5158 * Represents binary data with an associated MIME type sent to and received from requests.
You can’t perform that action at this time.
0 commit comments