Skip to content

Commit 9e5ad27

Browse files
authored
Merge ef4dbf2 into 335379a
2 parents 335379a + ef4dbf2 commit 9e5ad27

17 files changed

+52
-1
lines changed

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/FirebaseVertexAI.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import com.google.firebase.vertexai.type.GenerationConfig
2727
import com.google.firebase.vertexai.type.ImagenGenerationConfig
2828
import com.google.firebase.vertexai.type.ImagenSafetySettings
2929
import com.google.firebase.vertexai.type.InvalidLocationException
30+
import com.google.firebase.vertexai.type.PublicPreviewAPI
3031
import com.google.firebase.vertexai.type.RequestOptions
3132
import com.google.firebase.vertexai.type.SafetySetting
3233
import com.google.firebase.vertexai.type.Tool
@@ -91,6 +92,7 @@ internal constructor(
9192
* @return The initialized [ImagenModel] instance.
9293
*/
9394
@JvmOverloads
95+
@PublicPreviewAPI
9496
public fun imagenModel(
9597
modelName: String,
9698
generationConfig: ImagenGenerationConfig? = null,

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/ImagenModel.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ import com.google.firebase.vertexai.type.ImagenGenerationConfig
2828
import com.google.firebase.vertexai.type.ImagenGenerationResponse
2929
import com.google.firebase.vertexai.type.ImagenInlineImage
3030
import com.google.firebase.vertexai.type.ImagenSafetySettings
31+
import com.google.firebase.vertexai.type.PublicPreviewAPI
3132
import com.google.firebase.vertexai.type.RequestOptions
3233

3334
/**
3435
* Represents a generative model (like Imagen), capable of generating images based on various input
3536
* types.
3637
*/
38+
@PublicPreviewAPI
3739
public class ImagenModel
3840
internal constructor(
3941
private val modelName: String,
@@ -126,6 +128,7 @@ internal constructor(
126128
}
127129
}
128130

131+
@OptIn(PublicPreviewAPI::class)
129132
private fun ImagenGenerationResponse.Internal.validate(): ImagenGenerationResponse.Internal {
130133
if (predictions.none { it.mimeType != null }) {
131134
throw ContentBlockedException(

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/common/APIController.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import com.google.firebase.vertexai.type.FinishReason
2626
import com.google.firebase.vertexai.type.GRpcErrorResponse
2727
import com.google.firebase.vertexai.type.GenerateContentResponse
2828
import com.google.firebase.vertexai.type.ImagenGenerationResponse
29+
import com.google.firebase.vertexai.type.PublicPreviewAPI
2930
import com.google.firebase.vertexai.type.RequestOptions
3031
import com.google.firebase.vertexai.type.Response
3132
import io.ktor.client.HttpClient
@@ -82,6 +83,7 @@ internal val JSON = Json {
8283
* @property apiClient The value to pass in the `x-goog-api-client` header.
8384
* @property headerProvider A provider that generates extra headers to include in all HTTP requests.
8485
*/
86+
@OptIn(PublicPreviewAPI::class)
8587
internal class APIController
8688
internal constructor(
8789
private val key: String,

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/common/Request.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import com.google.firebase.vertexai.common.util.fullModelName
2020
import com.google.firebase.vertexai.type.Content
2121
import com.google.firebase.vertexai.type.GenerationConfig
2222
import com.google.firebase.vertexai.type.ImagenImageFormat
23+
import com.google.firebase.vertexai.type.PublicPreviewAPI
2324
import com.google.firebase.vertexai.type.SafetySetting
2425
import com.google.firebase.vertexai.type.Tool
2526
import com.google.firebase.vertexai.type.ToolConfig
@@ -74,6 +75,7 @@ internal data class GenerateImageRequest(
7475
) : Request {
7576
@Serializable internal data class ImagenPrompt(val prompt: String)
7677

78+
@OptIn(PublicPreviewAPI::class)
7779
@Serializable
7880
internal data class ImagenParameters(
7981
val sampleCount: Int = 1,

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/ImagenModelFutures.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ import com.google.firebase.vertexai.ImagenModel
2222
import com.google.firebase.vertexai.type.ImagenGCSImage
2323
import com.google.firebase.vertexai.type.ImagenGenerationResponse
2424
import com.google.firebase.vertexai.type.ImagenInlineImage
25+
import com.google.firebase.vertexai.type.PublicPreviewAPI
2526

2627
/**
2728
* Wrapper class providing Java compatible methods for [ImagenModel].
2829
*
2930
* @see [ImagenModel]
3031
*/
32+
@PublicPreviewAPI
3133
public abstract class ImagenModelFutures internal constructor() {
3234
/**
3335
* Generates an image, returning the result directly to the caller.

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ImagenAspectRatio.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.firebase.vertexai.type
1818

1919
/** Represents the aspect ratio that the generated image should conform to. */
20+
@PublicPreviewAPI
2021
public class ImagenAspectRatio private constructor(internal val internalVal: String) {
2122
public companion object {
2223
/** A square image, useful for icons, profile pictures, etc. */

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ImagenGCSImage.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ package com.google.firebase.vertexai.type
2222
* @param gcsUri Contains the `gs://` URI for the image.
2323
* @param mimeType Contains the MIME type of the image (for example, `"image/png"`).
2424
*/
25+
@PublicPreviewAPI
2526
public class ImagenGCSImage
2627
internal constructor(public val gcsUri: String, public val mimeType: String) {}

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ImagenGenerationConfig.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ package com.google.firebase.vertexai.type
2626
* @param imageFormat The file format/compression of the generated images.
2727
* @param addWatermark Adds an invisible watermark to mark the image as AI generated.
2828
*/
29+
@PublicPreviewAPI
2930
public class ImagenGenerationConfig(
3031
public val negativePrompt: String? = null,
3132
public val numberOfImages: Int? = 1,
@@ -88,6 +89,7 @@ public class ImagenGenerationConfig(
8889
* }
8990
* ```
9091
*/
92+
@PublicPreviewAPI
9193
public fun imagenGenerationConfig(
9294
init: ImagenGenerationConfig.Builder.() -> Unit
9395
): ImagenGenerationConfig {

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ImagenGenerationResponse.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import kotlinx.serialization.Serializable
2525
* @param filteredReason if fewer images were generated than were requested, this field will contain
2626
* the reason they were filtered out.
2727
*/
28+
@PublicPreviewAPI
2829
public class ImagenGenerationResponse<T>
2930
internal constructor(public val images: List<T>, public val filteredReason: String?) {
3031

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ImagenImageFormat.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import kotlinx.serialization.Serializable
2626
* means the image is permitted to be lower quality to reduce size. This parameter is not relevant
2727
* for every MIME type.
2828
*/
29+
@PublicPreviewAPI
2930
public class ImagenImageFormat
3031
private constructor(public val mimeType: String, public val compressionQuality: Int?) {
3132

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ImagenInlineImage.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import android.util.Base64
2626
* @param data Contains the raw bytes of the image
2727
* @param mimeType Contains the MIME type of the image (for example, `"image/png"`)
2828
*/
29+
@PublicPreviewAPI
2930
public class ImagenInlineImage
3031
internal constructor(public val data: ByteArray, public val mimeType: String) {
3132

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ImagenPersonFilterLevel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.firebase.vertexai.type
1818

1919
/** A filter used to prevent images from containing depictions of children or people. */
20+
@PublicPreviewAPI
2021
public class ImagenPersonFilterLevel private constructor(internal val internalVal: String) {
2122
public companion object {
2223
/** No filters applied. */

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ImagenSafetyFilterLevel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.firebase.vertexai.type
1818

1919
/** Used for safety filtering. */
20+
@PublicPreviewAPI
2021
public class ImagenSafetyFilterLevel private constructor(internal val internalVal: String) {
2122
public companion object {
2223
/** Strongest filtering level, most strict blocking. */

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ImagenSafetySettings.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package com.google.firebase.vertexai.type
2222
* @param safetyFilterLevel Used to filter unsafe content.
2323
* @param personFilterLevel Used to filter images containing people.
2424
*/
25+
@PublicPreviewAPI
2526
public class ImagenSafetySettings(
2627
internal val safetyFilterLevel: ImagenSafetyFilterLevel,
2728
internal val personFilterLevel: ImagenPersonFilterLevel,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.firebase.vertexai.type
18+
19+
@Retention(AnnotationRetention.BINARY)
20+
@RequiresOptIn(
21+
level = RequiresOptIn.Level.ERROR,
22+
message =
23+
"This API is part of an experimental public preview and may change in " +
24+
"backwards-incompatible ways without notice.",
25+
)
26+
public annotation class PublicPreviewAPI()

firebase-vertexai/src/test/java/com/google/firebase/vertexai/UnarySnapshotTests.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import com.google.firebase.vertexai.type.HarmProbability
2525
import com.google.firebase.vertexai.type.HarmSeverity
2626
import com.google.firebase.vertexai.type.InvalidAPIKeyException
2727
import com.google.firebase.vertexai.type.PromptBlockedException
28+
import com.google.firebase.vertexai.type.PublicPreviewAPI
2829
import com.google.firebase.vertexai.type.ResponseStoppedException
2930
import com.google.firebase.vertexai.type.SerializationException
3031
import com.google.firebase.vertexai.type.ServerException
@@ -35,7 +36,6 @@ import com.google.firebase.vertexai.util.goldenUnaryFile
3536
import com.google.firebase.vertexai.util.shouldNotBeNullOrEmpty
3637
import io.kotest.assertions.throwables.shouldThrow
3738
import io.kotest.inspectors.forAtLeastOne
38-
import io.kotest.matchers.collections.shouldContain
3939
import io.kotest.matchers.collections.shouldNotBeEmpty
4040
import io.kotest.matchers.nulls.shouldNotBeNull
4141
import io.kotest.matchers.should
@@ -54,6 +54,7 @@ import kotlinx.serialization.json.jsonPrimitive
5454
import org.json.JSONArray
5555
import org.junit.Test
5656

57+
@OptIn(PublicPreviewAPI::class)
5758
internal class UnarySnapshotTests {
5859
private val testTimeout = 5.seconds
5960

firebase-vertexai/src/test/java/com/google/firebase/vertexai/util/tests.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17+
@file:OptIn(PublicPreviewAPI::class)
18+
1719
package com.google.firebase.vertexai.util
1820

1921
import com.google.firebase.vertexai.GenerativeModel
2022
import com.google.firebase.vertexai.ImagenModel
2123
import com.google.firebase.vertexai.common.APIController
24+
import com.google.firebase.vertexai.type.PublicPreviewAPI
2225
import com.google.firebase.vertexai.type.RequestOptions
2326
import io.kotest.matchers.collections.shouldNotBeEmpty
2427
import io.kotest.matchers.nulls.shouldNotBeNull

0 commit comments

Comments
 (0)