Skip to content

Commit c4ea253

Browse files
committed
Merge branch 'main' into rl.txt.to.json.ai
2 parents bf5dd10 + 7cbb80b commit c4ea253

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import com.google.firebase.ai.util.goldenDevAPIUnaryFile
2424
import io.kotest.assertions.throwables.shouldThrow
2525
import io.kotest.matchers.should
2626
import io.kotest.matchers.shouldBe
27+
import io.kotest.matchers.shouldNotBe
2728
import io.ktor.http.HttpStatusCode
2829
import kotlin.time.Duration.Companion.seconds
2930
import kotlinx.coroutines.withTimeout
@@ -82,6 +83,17 @@ internal class DevAPIUnarySnapshotTests {
8283
}
8384
}
8485

86+
@Test
87+
fun `response blocked for safety`() =
88+
goldenDevAPIUnaryFile("unary-failure-finish-reason-safety.txt") {
89+
withTimeout(testTimeout) {
90+
shouldThrow<ResponseStoppedException> { model.generateContent("prompt") } should
91+
{
92+
it.response.candidates[0].finishReason shouldBe FinishReason.SAFETY
93+
}
94+
}
95+
}
96+
8597
@Test
8698
fun `invalid api key`() =
8799
goldenDevAPIUnaryFile("unary-failure-api-key.json", HttpStatusCode.BadRequest) {

firebase-ai/update_responses.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# This script replaces mock response files for Vertex AI unit tests with a fresh
1818
# clone of the shared repository of Vertex AI test data.
1919

20-
RESPONSES_VERSION='v10.*' # The major version of mock responses to use
20+
RESPONSES_VERSION='v11.*' # The major version of mock responses to use
2121
REPO_NAME="vertexai-sdk-test-data"
2222
REPO_LINK="https://github.com/FirebaseExtended/$REPO_NAME.git"
2323

plugins/src/main/java/com/google/firebase/gradle/plugins/PostReleasePlugin.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ class PostReleasePlugin : Plugin<Project> {
6363
* @see VersionBumpTask
6464
*/
6565
fun registerVersionBumpTask(project: Project) =
66-
project.tasks.register<VersionBumpTask>("versionBump")
66+
project.tasks.register<VersionBumpTask>("versionBump") {
67+
// TODO(b/285892320): Remove condition when bug fixed
68+
bumpVersion.set(project.firebaseLibrary.artifactId.map {
69+
it !== "protolite-well-known-types"
70+
})
71+
}
6772

6873
/**
6974
* Registers the `moveUnreleasedChanges` task for the provided [Project].

plugins/src/main/java/com/google/firebase/gradle/plugins/VersionBumpTask.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ import org.gradle.kotlin.dsl.provideDelegate
3939
* @property releasedVersion A [ModuleVersion] of what to bump from. Defaults to the project
4040
* version.
4141
* @property newVersion A [ModuleVersion] of what to set the version to. Defaults to one patch
42-
* higher than [releasedVersion]
42+
* higher than [releasedVersion].
43+
* @property bumpVersion If set, then the default provided by [newVersion] will be bumped by one patch. Defaults to `true`.
4344
* @see PostReleasePlugin
4445
*/
4546
abstract class VersionBumpTask : DefaultTask() {
@@ -52,16 +53,22 @@ abstract class VersionBumpTask : DefaultTask() {
5253
@get:[Optional Input]
5354
abstract val newVersion: Property<ModuleVersion>
5455

56+
@get:[Optional Input]
57+
abstract val bumpVersion: Property<Boolean>
58+
5559
init {
5660
configure()
5761
}
5862

5963
@TaskAction
6064
fun build() {
65+
val latestVersion = releasedVersion.get()
66+
val version = newVersion.orNull ?: if(bumpVersion.get()) latestVersion.bump() else latestVersion
67+
6168
versionFile.get().asFile.rewriteLines {
6269
when {
63-
it.startsWith("version=") -> "version=${newVersion.get()}"
64-
it.startsWith("latestReleasedVersion") -> "latestReleasedVersion=${releasedVersion.get()}"
70+
it.startsWith("version=") -> "version=${version}"
71+
it.startsWith("latestReleasedVersion") -> "latestReleasedVersion=${latestVersion}"
6572
else -> it
6673
}
6774
}
@@ -70,7 +77,7 @@ abstract class VersionBumpTask : DefaultTask() {
7077
fun configure() {
7178
versionFile.convention(project.layout.projectDirectory.file("gradle.properties"))
7279
releasedVersion.convention(computeReleasedVersion())
73-
newVersion.convention(releasedVersion.map { it.bump() })
80+
bumpVersion.convention(true)
7481
}
7582

7683
fun computeReleasedVersion(): ModuleVersion? {

0 commit comments

Comments
 (0)