diff --git a/firebase-ai/src/main/kotlin/com/google/firebase/ai/common/APIController.kt b/firebase-ai/src/main/kotlin/com/google/firebase/ai/common/APIController.kt index a0287c161c2..9e38045f432 100644 --- a/firebase-ai/src/main/kotlin/com/google/firebase/ai/common/APIController.kt +++ b/firebase-ai/src/main/kotlin/com/google/firebase/ai/common/APIController.kt @@ -165,6 +165,7 @@ internal constructor( suspend fun getWebSocketSession(location: String): ClientWebSocketSession = client.webSocketSession(getBidiEndpoint(location)) + fun generateContentStream( request: GenerateContentRequest ): Flow = diff --git a/firebase-ai/src/test/java/com/google/firebase/ai/DevAPIStreamingSnapshotTests.kt b/firebase-ai/src/test/java/com/google/firebase/ai/DevAPIStreamingSnapshotTests.kt index fde573fd634..967254a096c 100644 --- a/firebase-ai/src/test/java/com/google/firebase/ai/DevAPIStreamingSnapshotTests.kt +++ b/firebase-ai/src/test/java/com/google/firebase/ai/DevAPIStreamingSnapshotTests.kt @@ -42,9 +42,10 @@ internal class DevAPIStreamingSnapshotTests { withTimeout(testTimeout) { val responseList = responses.toList() responseList.isEmpty() shouldBe false - responseList.first().candidates.first().finishReason shouldBe FinishReason.STOP - responseList.first().candidates.first().content.parts.isEmpty() shouldBe false - responseList.first().candidates.first().safetyRatings.isEmpty() shouldBe false + responseList.last().candidates.first().apply { + finishReason shouldBe FinishReason.STOP + content.parts.isEmpty() shouldBe false + } } } @@ -56,10 +57,9 @@ internal class DevAPIStreamingSnapshotTests { withTimeout(testTimeout) { val responseList = responses.toList() responseList.isEmpty() shouldBe false - responseList.forEach { - it.candidates.first().finishReason shouldBe FinishReason.STOP - it.candidates.first().content.parts.isEmpty() shouldBe false - it.candidates.first().safetyRatings.isEmpty() shouldBe false + responseList.last().candidates.first().apply { + finishReason shouldBe FinishReason.STOP + content.parts.isEmpty() shouldBe false } } } diff --git a/firebase-ai/src/test/java/com/google/firebase/ai/VertexAIStreamingSnapshotTests.kt b/firebase-ai/src/test/java/com/google/firebase/ai/VertexAIStreamingSnapshotTests.kt index 8b6079cc6a5..e6331401fde 100644 --- a/firebase-ai/src/test/java/com/google/firebase/ai/VertexAIStreamingSnapshotTests.kt +++ b/firebase-ai/src/test/java/com/google/firebase/ai/VertexAIStreamingSnapshotTests.kt @@ -51,9 +51,11 @@ internal class VertexAIStreamingSnapshotTests { withTimeout(testTimeout) { val responseList = responses.toList() responseList.isEmpty() shouldBe false - responseList.first().candidates.first().finishReason shouldBe FinishReason.STOP - responseList.first().candidates.first().content.parts.isEmpty() shouldBe false - responseList.first().candidates.first().safetyRatings.isEmpty() shouldBe false + responseList.last().candidates.first().apply { + finishReason shouldBe FinishReason.STOP + content.parts.isEmpty() shouldBe false + safetyRatings.isEmpty() shouldBe false + } } } @@ -65,10 +67,9 @@ internal class VertexAIStreamingSnapshotTests { withTimeout(testTimeout) { val responseList = responses.toList() responseList.isEmpty() shouldBe false - responseList.forEach { - it.candidates.first().finishReason shouldBe FinishReason.STOP - it.candidates.first().content.parts.isEmpty() shouldBe false - it.candidates.first().safetyRatings.isEmpty() shouldBe false + responseList.last().candidates.first().apply { + finishReason shouldBe FinishReason.STOP + content.parts.isEmpty() shouldBe false } } } diff --git a/firebase-ai/src/test/java/com/google/firebase/ai/util/tests.kt b/firebase-ai/src/test/java/com/google/firebase/ai/util/tests.kt index dff254b7adf..393a2a16adc 100644 --- a/firebase-ai/src/test/java/com/google/firebase/ai/util/tests.kt +++ b/firebase-ai/src/test/java/com/google/firebase/ai/util/tests.kt @@ -39,7 +39,7 @@ import java.io.File import kotlinx.coroutines.launch import org.mockito.Mockito -private val TEST_CLIENT_ID = "firebase-vertexai-android/test" +private val TEST_CLIENT_ID = "firebase-ai-android/test" private val TEST_APP_ID = "1:android:12345" private val TEST_VERSION = 1 @@ -193,7 +193,7 @@ internal fun goldenDevAPIStreamingFile( name: String, httpStatusCode: HttpStatusCode = HttpStatusCode.OK, block: CommonTest, -) = goldenStreamingFile("vertexai/$name", httpStatusCode, GenerativeBackend.googleAI(), block) +) = goldenStreamingFile("googleai/$name", httpStatusCode, GenerativeBackend.googleAI(), block) /** * A variant of [commonTest] for performing snapshot tests. diff --git a/firebase-ai/update_responses.sh b/firebase-ai/update_responses.sh index a6dea7785d4..7d6ea18e0ee 100755 --- a/firebase-ai/update_responses.sh +++ b/firebase-ai/update_responses.sh @@ -17,7 +17,7 @@ # This script replaces mock response files for Vertex AI unit tests with a fresh # clone of the shared repository of Vertex AI test data. -RESPONSES_VERSION='v11.*' # The major version of mock responses to use +RESPONSES_VERSION='v13.*' # The major version of mock responses to use REPO_NAME="vertexai-sdk-test-data" REPO_LINK="https://github.com/FirebaseExtended/$REPO_NAME.git"