Skip to content

Commit cf122c1

Browse files
committed
Add include thoughts configuration.
This updates `thinking_budget` to not be included in the generated JSON unless its value is not-null, which is the standard behaviour.
1 parent 5e778b9 commit cf122c1

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

firebase-ai/src/main/kotlin/com/google/firebase/ai/type/ThinkingConfig.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,18 @@ import kotlinx.serialization.Serializable
2323
public class ThinkingConfig
2424
private constructor(
2525
internal val thinkingBudget: Int? = null,
26+
internal val includeThoughts: Boolean? = null
2627
) {
2728

2829
public class Builder() {
2930
@JvmField
3031
@set:JvmSynthetic // hide void setter from Java
3132
public var thinkingBudget: Int? = null
3233

34+
@JvmField
35+
@set:JvmSynthetic // hide void setter from Java
36+
public var includeThoughts: Boolean? = null
37+
3338
/**
3439
* Indicates the thinking budget in tokens. `0` is disabled. `-1` is dynamic. The default values
3540
* and allowed ranges are model dependent.
@@ -38,13 +43,20 @@ private constructor(
3843
this.thinkingBudget = thinkingBudget
3944
}
4045

46+
public fun setIncludeThoughts(includeThoughts: Boolean): Builder = apply {
47+
this.includeThoughts = includeThoughts
48+
}
49+
4150
public fun build(): ThinkingConfig = ThinkingConfig(thinkingBudget = thinkingBudget)
4251
}
4352

44-
internal fun toInternal() = Internal(thinkingBudget)
53+
internal fun toInternal() = Internal(thinkingBudget, includeThoughts)
4554

4655
@Serializable
47-
internal data class Internal(@SerialName("thinking_budget") val thinkingBudget: Int?)
56+
internal data class Internal(
57+
@SerialName("thinking_budget") val thinkingBudget: Int? = null,
58+
val includeThoughts: Boolean? = null
59+
)
4860
}
4961

5062
/**

0 commit comments

Comments
 (0)