Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions firebase-ai/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
* [fixed] Fixed an issue with `LiveContentResponse` audio data not being present when the model was
interrupted or the turn completed. (#6870)
* [fixed] Fixed an issue with `LiveSession` not converting exceptions to `FirebaseVertexAIException`. (#6870)
* [feature] Add support for specifying response modalities in `GenerationConfig`. (#6921)
1 change: 1 addition & 0 deletions firebase-ai/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ package com.google.firebase.ai.type {
field public Integer? maxOutputTokens;
field public Float? presencePenalty;
field public String? responseMimeType;
field public java.util.List<com.google.firebase.ai.type.ResponseModality>? responseModalities;
field public com.google.firebase.ai.type.Schema? responseSchema;
field public java.util.List<java.lang.String>? stopSequences;
field public Float? temperature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ import kotlinx.serialization.Serializable
* Refer to the
* [Control generated output](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/control-generated-output)
* guide for more details.
*
* @property responseModalities The format of data in which the model should respond with.
*/
public class GenerationConfig
private constructor(
Expand All @@ -88,6 +90,7 @@ private constructor(
internal val stopSequences: List<String>?,
internal val responseMimeType: String?,
internal val responseSchema: Schema?,
internal val responseModalities: List<ResponseModality>?,
) {

/**
Expand Down Expand Up @@ -115,6 +118,9 @@ private constructor(
* @property responseMimeType See [GenerationConfig.responseMimeType].
*
* @property responseSchema See [GenerationConfig.responseSchema].
*
* @property responseModalities See [GenerationConfig.responseModalities].
*
* @see [generationConfig]
*/
public class Builder {
Expand All @@ -128,6 +134,7 @@ private constructor(
@JvmField public var stopSequences: List<String>? = null
@JvmField public var responseMimeType: String? = null
@JvmField public var responseSchema: Schema? = null
@JvmField public var responseModalities: List<ResponseModality>? = null

/** Create a new [GenerationConfig] with the attached arguments. */
public fun build(): GenerationConfig =
Expand All @@ -142,6 +149,7 @@ private constructor(
frequencyPenalty = frequencyPenalty,
responseMimeType = responseMimeType,
responseSchema = responseSchema,
responseModalities = responseModalities
)
}

Expand All @@ -156,7 +164,8 @@ private constructor(
frequencyPenalty = frequencyPenalty,
presencePenalty = presencePenalty,
responseMimeType = responseMimeType,
responseSchema = responseSchema?.toInternal()
responseSchema = responseSchema?.toInternal(),
responseModalities = responseModalities?.map { it.toInternal() }
)

@Serializable
Expand All @@ -171,6 +180,7 @@ private constructor(
@SerialName("presence_penalty") val presencePenalty: Float? = null,
@SerialName("frequency_penalty") val frequencyPenalty: Float? = null,
@SerialName("response_schema") val responseSchema: Schema.Internal? = null,
@SerialName("response_modalities") val responseModalities: List<String>? = null
)

public companion object {
Expand Down