diff --git a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/ImageModel.kt b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/ImageModel.kt index 3febc04a2ce..c24623fc1ff 100644 --- a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/ImageModel.kt +++ b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/ImageModel.kt @@ -28,11 +28,11 @@ import com.google.firebase.vertexai.internal.util.toInternal import com.google.firebase.vertexai.internal.util.toPublicGCS import com.google.firebase.vertexai.internal.util.toPublicInline import com.google.firebase.vertexai.type.FirebaseVertexAIException -import com.google.firebase.vertexai.type.ImagenSafetySettings import com.google.firebase.vertexai.type.ImagenGCSImage import com.google.firebase.vertexai.type.ImagenGenerationConfig import com.google.firebase.vertexai.type.ImagenGenerationResponse import com.google.firebase.vertexai.type.ImagenInlineImage +import com.google.firebase.vertexai.type.ImagenSafetySettings import com.google.firebase.vertexai.type.PromptBlockedException import com.google.firebase.vertexai.type.RequestOptions import kotlin.time.Duration @@ -115,7 +115,10 @@ internal constructor( prompt: String, ): ImagenGenerationResponse = try { - controller.generateImage(constructRequest(prompt, null, generationConfig)).toPublicInline().validate() + controller + .generateImage(constructRequest(prompt, null, generationConfig)) + .toPublicInline() + .validate() } catch (e: Throwable) { throw FirebaseVertexAIException.from(e) } @@ -131,7 +134,10 @@ internal constructor( gcsUri: String, ): ImagenGenerationResponse = try { - controller.generateImage(constructRequest(prompt, gcsUri, generationConfig)).toPublicGCS().validate() + controller + .generateImage(constructRequest(prompt, gcsUri, generationConfig)) + .toPublicGCS() + .validate() } catch (e: Throwable) { throw FirebaseVertexAIException.from(e) } @@ -164,8 +170,7 @@ internal constructor( } } -private fun ImagenGenerationResponse.validate(): - ImagenGenerationResponse { +private fun ImagenGenerationResponse.validate(): ImagenGenerationResponse { if (images.isEmpty()) { throw PromptBlockedException(message = filteredReason ?: ImageModel.DEFAULT_FILTERED_ERROR) } diff --git a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ImagenGenerationConfig.kt b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ImagenGenerationConfig.kt index c07827ed1e7..acae920ab14 100644 --- a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ImagenGenerationConfig.kt +++ b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ImagenGenerationConfig.kt @@ -26,9 +26,9 @@ package com.google.firebase.vertexai.type * @param addWatermark Adds an invisible watermark to mark the image as AI generated. */ public class ImagenGenerationConfig( - public val negativePrompt: String? = null, - public val numberOfImages: Int? = 1, - public val aspectRatio: ImagenAspectRatio? = null, - public val imageFormat: ImagenImageFormat? = null, - public val addWatermark: Boolean? = null + public val negativePrompt: String? = null, + public val numberOfImages: Int? = 1, + public val aspectRatio: ImagenAspectRatio? = null, + public val imageFormat: ImagenImageFormat? = null, + public val addWatermark: Boolean? = null ) {}