Skip to content

Commit 8c73fb4

Browse files
authored
Merge 75e5e14 into af24598
2 parents af24598 + 75e5e14 commit 8c73fb4

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

firebase-ai/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Unreleased
22

3+
* [fixed] Fixed a serialization error that was thrown for the last message when using
4+
`generateContentStream()` with `googleAI()`.
35
* [fixed] Fixed `FirebaseAI.getInstance` StackOverflowException (#6971)
46
* [fixed] Fixed an issue that was causing the SDK to send empty `FunctionDeclaration` descriptions to the API.
57
* [changed] Introduced the `Voice` class, which accepts a voice name, and deprecated the `Voices` class.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ constructor(public val role: String? = "user", public val parts: List<Part>) {
9090
@Serializable
9191
internal data class Internal(
9292
@EncodeDefault val role: String? = "user",
93-
val parts: List<InternalPart>
93+
val parts: List<InternalPart> = emptyList()
9494
) {
9595
internal fun toPublic(): Content {
9696
val returnedParts =

firebase-ai/src/test/java/com/google/firebase/ai/DevAPIStreamingSnapshotTests.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,21 @@ internal class DevAPIStreamingSnapshotTests {
8888
}
8989
}
9090

91+
@Test
92+
fun `streaming returned the last Content without parts`() =
93+
goldenDevAPIStreamingFile("streaming-success-no-content-parts.txt") {
94+
val responses = model.generateContentStream("prompt")
95+
96+
withTimeout(testTimeout) {
97+
val responseList = responses.toList()
98+
responseList.isEmpty() shouldBe false
99+
responseList.last().candidates.first().apply {
100+
finishReason shouldBe FinishReason.STOP
101+
content.parts.isEmpty() shouldBe false
102+
}
103+
}
104+
}
105+
91106
@Test
92107
fun `stopped for recitation`() =
93108
goldenDevAPIStreamingFile("streaming-failure-recitation-no-content.txt") {

0 commit comments

Comments
 (0)