Skip to content

wire through response schema from common #6114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion firebase-vertexai/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Unreleased

* [feature] added support for `responseSchema` in `GenerationConfig`.

# 16.0.0-beta03
* [changed] Breaking Change: changed `Schema.int` to return 32 bit integers instead of 64 bit (long).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ internal fun GenerationConfig.toInternal() =
candidateCount = candidateCount,
maxOutputTokens = maxOutputTokens,
stopSequences = stopSequences,
responseMimeType = responseMimeType
responseMimeType = responseMimeType,
responseSchema = responseSchema?.toInternal()
)

internal fun com.google.firebase.vertexai.type.HarmCategory.toInternal() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ package com.google.firebase.vertexai.type
* @property candidateCount The max *unique* responses to return
* @property maxOutputTokens The max tokens to generate per response
* @property stopSequences A list of strings to stop generation on occurrence of
* * @property responseMimeType Response type for generated candidate text. See the
* @property responseMimeType Response type for generated candidate text. See the
* [vertex docs](https://cloud.google.com/vertex-ai/docs/reference/rest/v1beta1/GenerationConfig)
* for a list of supported types.
* @property responseSchema A schema that the response must adhere to, used with the
* `application/json` mimeType.
*/
class GenerationConfig
private constructor(
Expand All @@ -37,7 +39,8 @@ private constructor(
val candidateCount: Int?,
val maxOutputTokens: Int?,
val stopSequences: List<String>?,
val responseMimeType: String?
val responseMimeType: String?,
val responseSchema: Schema<*>? = null,
) {

/**
Expand All @@ -63,6 +66,7 @@ private constructor(
@JvmField var maxOutputTokens: Int? = null
@JvmField var stopSequences: List<String>? = null
@JvmField var responseMimeType: String? = null
@JvmField var responseSchema: Schema<*>? = null

/** Create a new [GenerationConfig] with the attached arguments. */
fun build() =
Expand All @@ -73,7 +77,8 @@ private constructor(
candidateCount = candidateCount,
maxOutputTokens = maxOutputTokens,
stopSequences = stopSequences,
responseMimeType = responseMimeType
responseMimeType = responseMimeType,
responseSchema = responseSchema
)
}

Expand Down
Loading