Skip to content

Commit

Permalink
Change InlineDataPart to match ImagePart (#6346)
Browse files Browse the repository at this point in the history
The order of the parameters should be consistent between them, and it
should be (url/byte, mime-type).
  • Loading branch information
rlazo authored Oct 4, 2024
1 parent f194676 commit 448adae
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ internal fun com.google.firebase.vertexai.common.shared.Part.toPublic(): Part {
if (inlineData.mimeType.contains("image")) {
ImagePart(decodeBitmapFromImage(data))
} else {
InlineDataPart(inlineData.mimeType, data)
InlineDataPart(data, inlineData.mimeType)
}
}
is com.google.firebase.vertexai.common.shared.FunctionCallPart ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ constructor(public val role: String? = "user", public val parts: List<Part>) {
*/
@JvmName("addInlineData")
public fun inlineData(mimeType: String, bytes: ByteArray): Content.Builder =
part(InlineDataPart(mimeType, bytes))
part(InlineDataPart(bytes, mimeType))

/** Wraps the provided [image] inside an [ImagePart] and adds it to the [parts] list. */
@JvmName("addImage") public fun image(image: Bitmap): Content.Builder = part(ImagePart(image))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ public class ImagePart(public val image: Bitmap) : Part
/**
* Represents binary data with an associated MIME type sent to and received from requests.
*
* @param inlineData the binary data as a [ByteArray]
* @param mimeType an IANA standard MIME type. For supported values, see the
* [Vertex AI documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/send-multimodal-prompts#media_requirements)
* .
* @param inlineData the binary data as a [ByteArray]
*/
public class InlineDataPart(public val mimeType: String, public val inlineData: ByteArray) : Part
public class InlineDataPart(public val inlineData: ByteArray, public val mimeType: String) : Part

/**
* Represents a function call request from the model
Expand Down

0 comments on commit 448adae

Please sign in to comment.