Skip to content

Commit f1f5ae0

Browse files
committed
Update GenerateContentResponse.kt
1 parent 7924813 commit f1f5ae0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

firebase-ai/src/main/kotlin/com/google/firebase/ai/type/GenerateContentResponse.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ public class GenerateContentResponse(
4444
candidates.first().content.parts.filterIsInstance<FunctionCallPart>()
4545
}
4646

47+
/**
48+
* Convenience field representing all the [InlineDataPart]s in the first candidate, if they exist.
49+
*
50+
* This also includes any [ImagePart], but they will be represented as [InlineDataPart] instead.
51+
*/
52+
public val inlineDataParts: List<InlineDataPart> by lazy {
53+
candidates.first().content.parts.let { parts ->
54+
parts.filterIsInstance<ImagePart>().map { it.toInlineDataPart() } +
55+
parts.filterIsInstance<InlineDataPart>()
56+
}
57+
}
58+
4759
@Serializable
4860
internal data class Internal(
4961
val candidates: List<Candidate.Internal>? = null,

0 commit comments

Comments
 (0)