Skip to content

Commit 9a1d120

Browse files
davidmotsonDavid Motsonashvili
and
David Motsonashvili
authored
wire through response schema from common (#6114)
Co-authored-by: David Motsonashvili <[email protected]>
1 parent 1c03d4b commit 9a1d120

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

firebase-vertexai/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Unreleased
2-
2+
* [feature] added support for `responseSchema` in `GenerationConfig`.
33

44
# 16.0.0-beta03
55
* [changed] Breaking Change: changed `Schema.int` to return 32 bit integers instead of 64 bit (long).

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/internal/util/conversions.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ internal fun GenerationConfig.toInternal() =
114114
candidateCount = candidateCount,
115115
maxOutputTokens = maxOutputTokens,
116116
stopSequences = stopSequences,
117-
responseMimeType = responseMimeType
117+
responseMimeType = responseMimeType,
118+
responseSchema = responseSchema?.toInternal()
118119
)
119120

120121
internal fun com.google.firebase.vertexai.type.HarmCategory.toInternal() =

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ package com.google.firebase.vertexai.type
2525
* @property candidateCount The max *unique* responses to return
2626
* @property maxOutputTokens The max tokens to generate per response
2727
* @property stopSequences A list of strings to stop generation on occurrence of
28-
* * @property responseMimeType Response type for generated candidate text. See the
28+
* @property responseMimeType Response type for generated candidate text. See the
2929
* [vertex docs](https://cloud.google.com/vertex-ai/docs/reference/rest/v1beta1/GenerationConfig)
3030
* for a list of supported types.
31+
* @property responseSchema A schema that the response must adhere to, used with the
32+
* `application/json` mimeType.
3133
*/
3234
class GenerationConfig
3335
private constructor(
@@ -37,7 +39,8 @@ private constructor(
3739
val candidateCount: Int?,
3840
val maxOutputTokens: Int?,
3941
val stopSequences: List<String>?,
40-
val responseMimeType: String?
42+
val responseMimeType: String?,
43+
val responseSchema: Schema<*>? = null,
4144
) {
4245

4346
/**
@@ -63,6 +66,7 @@ private constructor(
6366
@JvmField var maxOutputTokens: Int? = null
6467
@JvmField var stopSequences: List<String>? = null
6568
@JvmField var responseMimeType: String? = null
69+
@JvmField var responseSchema: Schema<*>? = null
6670

6771
/** Create a new [GenerationConfig] with the attached arguments. */
6872
fun build() =
@@ -73,7 +77,8 @@ private constructor(
7377
candidateCount = candidateCount,
7478
maxOutputTokens = maxOutputTokens,
7579
stopSequences = stopSequences,
76-
responseMimeType = responseMimeType
80+
responseMimeType = responseMimeType,
81+
responseSchema = responseSchema
7782
)
7883
}
7984

0 commit comments

Comments
 (0)