Skip to content

Commit 7859a7f

Browse files
author
David Motsonashvili
committed
add documentation to ImagenGenerationConfig.Builder
1 parent 2dcce15 commit 7859a7f

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,32 @@ public class ImagenGenerationConfig(
3333
public val imageFormat: ImagenImageFormat? = null,
3434
public val addWatermark: Boolean? = null,
3535
) {
36+
/**
37+
* Builder for creating a [ImagenGenerationConfig].
38+
*
39+
* Mainly intended for Java interop. Kotlin consumers should use [imagenGenerationConfig] for a
40+
* more idiomatic experience.
41+
*
42+
* @property negativePrompt See [ImagenGenerationConfig.negativePrompt].
43+
* @property numberOfImages See [ImagenGenerationConfig.numberOfImages].
44+
* @property aspectRatio See [ImagenGenerationConfig.aspectRatio].
45+
* @property imageFormat See [ImagenGenerationConfig.imageFormat]
46+
* @property addWatermark See [ImagenGenerationConfig.addWatermark]
47+
* @see [imagenGenerationConfig]
48+
*/
3649
public class Builder {
3750
@JvmField public var negativePrompt: String? = null
3851
@JvmField public var numberOfImages: Int? = 1
3952
@JvmField public var aspectRatio: ImagenAspectRatio? = null
4053
@JvmField public var imageFormat: ImagenImageFormat? = null
4154
@JvmField public var addWatermark: Boolean? = null
4255

56+
/**
57+
* Alternative casing for [ImagenGenerationConfig.Builder]:
58+
* ```
59+
* val config = GenerationConfig.builder()
60+
* ```
61+
*/
4362
public fun build(): ImagenGenerationConfig =
4463
ImagenGenerationConfig(
4564
negativePrompt = negativePrompt,
@@ -55,6 +74,20 @@ public class ImagenGenerationConfig(
5574
}
5675
}
5776

77+
/**
78+
* Helper method to construct a [ImagenGenerationConfig] in a DSL-like manner.
79+
*
80+
* Example Usage:
81+
* ```
82+
* imagenGenerationConfig {
83+
* negativePrompt = "People, black and white, painting"
84+
* numberOfImages = 1
85+
* aspectRatio = ImagenAspecRatio.SQUARE_1x1
86+
* imageFormat = ImagenImageFormat.png()
87+
* addWatermark = false
88+
* }
89+
* ```
90+
*/
5891
public fun imagenGenerationConfig(
5992
init: ImagenGenerationConfig.Builder.() -> Unit
6093
): ImagenGenerationConfig {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ package com.google.firebase.vertexai.type
1919
/**
2020
* Represents the format an image should be returned in.
2121
* @param mimeType A string (like `"image/jpeg"`) specifying the encoding MIME type of the image.
22-
* @param compressionQuality an int (1-100) representing the quality of the image; a lower
23-
* number means the image is permitted to be lower quality to reduce size. This parameter is not
24-
* relevant for every MIME type.
22+
* @param compressionQuality an int (1-100) representing the quality of the image; a lower number
23+
* means the image is permitted to be lower quality to reduce size. This parameter is not relevant
24+
* for every MIME type.
2525
*/
2626
public class ImagenImageFormat
2727
private constructor(public val mimeType: String, public val compressionQuality: Int?) {

0 commit comments

Comments
 (0)