Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ constructor(public val role: String? = "user", public val parts: List<Part>) {
@Serializable
internal data class Internal(
@EncodeDefault val role: String? = "user",
val parts: List<InternalPart>
val parts: List<InternalPart> = emptyList()
) {
internal fun toPublic(): Content {
val returnedParts =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,21 @@ internal class DevAPIStreamingSnapshotTests {
}
}

@Test
fun `streaming returned the last Content without parts`() =
goldenDevAPIStreamingFile("streaming-success-no-content-parts.txt") {
val responses = model.generateContentStream("prompt")

withTimeout(testTimeout) {
val responseList = responses.toList()
responseList.isEmpty() shouldBe false
responseList.last().candidates.first().apply {
finishReason shouldBe FinishReason.STOP
content.parts.isEmpty() shouldBe false
}
}
}

@Test
fun `stopped for recitation`() =
goldenDevAPIStreamingFile("streaming-failure-recitation-no-content.txt") {
Expand Down
Loading