Skip to content

Commit d762b6e

Browse files
google-genai-botcopybara-github
authored andcommitted
feat: Replace the more ambiguous rate field with sample_rate.
PiperOrigin-RevId: 905114354
1 parent e337ba9 commit d762b6e

2 files changed

Lines changed: 80 additions & 27 deletions

File tree

src/main/java/com/google/genai/interactions/models/interactions/AudioContent.kt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private constructor(
4141
private val channels: JsonField<Int>,
4242
private val data: JsonField<String>,
4343
private val mimeType: JsonField<MimeType>,
44-
private val rate: JsonField<Int>,
44+
private val sampleRate: JsonField<Int>,
4545
private val uri: JsonField<String>,
4646
private val additionalProperties: MutableMap<String, JsonValue>,
4747
) {
@@ -52,9 +52,9 @@ private constructor(
5252
@JsonProperty("channels") @ExcludeMissing channels: JsonField<Int> = JsonMissing.of(),
5353
@JsonProperty("data") @ExcludeMissing data: JsonField<String> = JsonMissing.of(),
5454
@JsonProperty("mime_type") @ExcludeMissing mimeType: JsonField<MimeType> = JsonMissing.of(),
55-
@JsonProperty("rate") @ExcludeMissing rate: JsonField<Int> = JsonMissing.of(),
55+
@JsonProperty("sample_rate") @ExcludeMissing sampleRate: JsonField<Int> = JsonMissing.of(),
5656
@JsonProperty("uri") @ExcludeMissing uri: JsonField<String> = JsonMissing.of(),
57-
) : this(type, channels, data, mimeType, rate, uri, mutableMapOf())
57+
) : this(type, channels, data, mimeType, sampleRate, uri, mutableMapOf())
5858

5959
/**
6060
* Expected to always return the following:
@@ -97,7 +97,7 @@ private constructor(
9797
* @throws GeminiNextGenApiInvalidDataException if the JSON field has an unexpected type (e.g.
9898
* if the server responded with an unexpected value).
9999
*/
100-
fun rate(): Optional<Int> = rate.getOptional("rate")
100+
fun sampleRate(): Optional<Int> = sampleRate.getOptional("sample_rate")
101101

102102
/**
103103
* The URI of the audio.
@@ -129,11 +129,11 @@ private constructor(
129129
@JsonProperty("mime_type") @ExcludeMissing fun _mimeType(): JsonField<MimeType> = mimeType
130130

131131
/**
132-
* Returns the raw JSON value of [rate].
132+
* Returns the raw JSON value of [sampleRate].
133133
*
134-
* Unlike [rate], this method doesn't throw if the JSON field has an unexpected type.
134+
* Unlike [sampleRate], this method doesn't throw if the JSON field has an unexpected type.
135135
*/
136-
@JsonProperty("rate") @ExcludeMissing fun _rate(): JsonField<Int> = rate
136+
@JsonProperty("sample_rate") @ExcludeMissing fun _sampleRate(): JsonField<Int> = sampleRate
137137

138138
/**
139139
* Returns the raw JSON value of [uri].
@@ -167,7 +167,7 @@ private constructor(
167167
private var channels: JsonField<Int> = JsonMissing.of()
168168
private var data: JsonField<String> = JsonMissing.of()
169169
private var mimeType: JsonField<MimeType> = JsonMissing.of()
170-
private var rate: JsonField<Int> = JsonMissing.of()
170+
private var sampleRate: JsonField<Int> = JsonMissing.of()
171171
private var uri: JsonField<String> = JsonMissing.of()
172172
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
173173

@@ -177,7 +177,7 @@ private constructor(
177177
channels = audioContent.channels
178178
data = audioContent.data
179179
mimeType = audioContent.mimeType
180-
rate = audioContent.rate
180+
sampleRate = audioContent.sampleRate
181181
uri = audioContent.uri
182182
additionalProperties = audioContent.additionalProperties.toMutableMap()
183183
}
@@ -231,15 +231,15 @@ private constructor(
231231
fun mimeType(mimeType: JsonField<MimeType>) = apply { this.mimeType = mimeType }
232232

233233
/** The sample rate of the audio. */
234-
fun rate(rate: Int) = rate(JsonField.of(rate))
234+
fun sampleRate(sampleRate: Int) = sampleRate(JsonField.of(sampleRate))
235235

236236
/**
237-
* Sets [Builder.rate] to an arbitrary JSON value.
237+
* Sets [Builder.sampleRate] to an arbitrary JSON value.
238238
*
239-
* You should usually call [Builder.rate] with a well-typed [Int] value instead. This method
240-
* is primarily for setting the field to an undocumented or not yet supported value.
239+
* You should usually call [Builder.sampleRate] with a well-typed [Int] value instead. This
240+
* method is primarily for setting the field to an undocumented or not yet supported value.
241241
*/
242-
fun rate(rate: JsonField<Int>) = apply { this.rate = rate }
242+
fun sampleRate(sampleRate: JsonField<Int>) = apply { this.sampleRate = sampleRate }
243243

244244
/** The URI of the audio. */
245245
fun uri(uri: String) = uri(JsonField.of(uri))
@@ -282,7 +282,7 @@ private constructor(
282282
channels,
283283
data,
284284
mimeType,
285-
rate,
285+
sampleRate,
286286
uri,
287287
additionalProperties.toMutableMap(),
288288
)
@@ -303,7 +303,7 @@ private constructor(
303303
channels()
304304
data()
305305
mimeType().ifPresent { it.validate() }
306-
rate()
306+
sampleRate()
307307
uri()
308308
validated = true
309309
}
@@ -327,7 +327,7 @@ private constructor(
327327
(if (channels.asKnown().isPresent) 1 else 0) +
328328
(if (data.asKnown().isPresent) 1 else 0) +
329329
(mimeType.asKnown().getOrNull()?.validity() ?: 0) +
330-
(if (rate.asKnown().isPresent) 1 else 0) +
330+
(if (sampleRate.asKnown().isPresent) 1 else 0) +
331331
(if (uri.asKnown().isPresent) 1 else 0)
332332

333333
/** The mime type of the audio. */
@@ -528,17 +528,17 @@ private constructor(
528528
channels == other.channels &&
529529
data == other.data &&
530530
mimeType == other.mimeType &&
531-
rate == other.rate &&
531+
sampleRate == other.sampleRate &&
532532
uri == other.uri &&
533533
additionalProperties == other.additionalProperties
534534
}
535535

536536
private val hashCode: Int by lazy {
537-
Objects.hash(type, channels, data, mimeType, rate, uri, additionalProperties)
537+
Objects.hash(type, channels, data, mimeType, sampleRate, uri, additionalProperties)
538538
}
539539

540540
override fun hashCode(): Int = hashCode
541541

542542
override fun toString() =
543-
"AudioContent{type=$type, channels=$channels, data=$data, mimeType=$mimeType, rate=$rate, uri=$uri, additionalProperties=$additionalProperties}"
543+
"AudioContent{type=$type, channels=$channels, data=$data, mimeType=$mimeType, sampleRate=$sampleRate, uri=$uri, additionalProperties=$additionalProperties}"
544544
}

src/main/java/com/google/genai/interactions/models/interactions/ContentDelta.kt

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,6 +2011,7 @@ private constructor(
20112011
private val data: JsonField<String>,
20122012
private val mimeType: JsonField<MimeType>,
20132013
private val rate: JsonField<Int>,
2014+
private val sampleRate: JsonField<Int>,
20142015
private val uri: JsonField<String>,
20152016
private val additionalProperties: MutableMap<String, JsonValue>,
20162017
) {
@@ -2026,8 +2027,11 @@ private constructor(
20262027
@ExcludeMissing
20272028
mimeType: JsonField<MimeType> = JsonMissing.of(),
20282029
@JsonProperty("rate") @ExcludeMissing rate: JsonField<Int> = JsonMissing.of(),
2030+
@JsonProperty("sample_rate")
2031+
@ExcludeMissing
2032+
sampleRate: JsonField<Int> = JsonMissing.of(),
20292033
@JsonProperty("uri") @ExcludeMissing uri: JsonField<String> = JsonMissing.of(),
2030-
) : this(type, channels, data, mimeType, rate, uri, mutableMapOf())
2034+
) : this(type, channels, data, mimeType, rate, sampleRate, uri, mutableMapOf())
20312035

20322036
/**
20332037
* Expected to always return the following:
@@ -2060,13 +2064,21 @@ private constructor(
20602064
*/
20612065
fun mimeType(): Optional<MimeType> = mimeType.getOptional("mime_type")
20622066

2067+
/**
2068+
* Deprecated. Use sample_rate instead. The value is ignored.
2069+
*
2070+
* @throws GeminiNextGenApiInvalidDataException if the JSON field has an unexpected type
2071+
* (e.g. if the server responded with an unexpected value).
2072+
*/
2073+
@Deprecated("deprecated") fun rate(): Optional<Int> = rate.getOptional("rate")
2074+
20632075
/**
20642076
* The sample rate of the audio.
20652077
*
20662078
* @throws GeminiNextGenApiInvalidDataException if the JSON field has an unexpected type
20672079
* (e.g. if the server responded with an unexpected value).
20682080
*/
2069-
fun rate(): Optional<Int> = rate.getOptional("rate")
2081+
fun sampleRate(): Optional<Int> = sampleRate.getOptional("sample_rate")
20702082

20712083
/**
20722084
* @throws GeminiNextGenApiInvalidDataException if the JSON field has an unexpected type
@@ -2104,7 +2116,20 @@ private constructor(
21042116
*
21052117
* Unlike [rate], this method doesn't throw if the JSON field has an unexpected type.
21062118
*/
2107-
@JsonProperty("rate") @ExcludeMissing fun _rate(): JsonField<Int> = rate
2119+
@Deprecated("deprecated")
2120+
@JsonProperty("rate")
2121+
@ExcludeMissing
2122+
fun _rate(): JsonField<Int> = rate
2123+
2124+
/**
2125+
* Returns the raw JSON value of [sampleRate].
2126+
*
2127+
* Unlike [sampleRate], this method doesn't throw if the JSON field has an unexpected
2128+
* type.
2129+
*/
2130+
@JsonProperty("sample_rate")
2131+
@ExcludeMissing
2132+
fun _sampleRate(): JsonField<Int> = sampleRate
21082133

21092134
/**
21102135
* Returns the raw JSON value of [uri].
@@ -2139,6 +2164,7 @@ private constructor(
21392164
private var data: JsonField<String> = JsonMissing.of()
21402165
private var mimeType: JsonField<MimeType> = JsonMissing.of()
21412166
private var rate: JsonField<Int> = JsonMissing.of()
2167+
private var sampleRate: JsonField<Int> = JsonMissing.of()
21422168
private var uri: JsonField<String> = JsonMissing.of()
21432169
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
21442170

@@ -2149,6 +2175,7 @@ private constructor(
21492175
data = audio.data
21502176
mimeType = audio.mimeType
21512177
rate = audio.rate
2178+
sampleRate = audio.sampleRate
21522179
uri = audio.uri
21532180
additionalProperties = audio.additionalProperties.toMutableMap()
21542181
}
@@ -2201,8 +2228,8 @@ private constructor(
22012228
*/
22022229
fun mimeType(mimeType: JsonField<MimeType>) = apply { this.mimeType = mimeType }
22032230

2204-
/** The sample rate of the audio. */
2205-
fun rate(rate: Int) = rate(JsonField.of(rate))
2231+
/** Deprecated. Use sample_rate instead. The value is ignored. */
2232+
@Deprecated("deprecated") fun rate(rate: Int) = rate(JsonField.of(rate))
22062233

22072234
/**
22082235
* Sets [Builder.rate] to an arbitrary JSON value.
@@ -2211,8 +2238,21 @@ private constructor(
22112238
* This method is primarily for setting the field to an undocumented or not yet
22122239
* supported value.
22132240
*/
2241+
@Deprecated("deprecated")
22142242
fun rate(rate: JsonField<Int>) = apply { this.rate = rate }
22152243

2244+
/** The sample rate of the audio. */
2245+
fun sampleRate(sampleRate: Int) = sampleRate(JsonField.of(sampleRate))
2246+
2247+
/**
2248+
* Sets [Builder.sampleRate] to an arbitrary JSON value.
2249+
*
2250+
* You should usually call [Builder.sampleRate] with a well-typed [Int] value
2251+
* instead. This method is primarily for setting the field to an undocumented or not
2252+
* yet supported value.
2253+
*/
2254+
fun sampleRate(sampleRate: JsonField<Int>) = apply { this.sampleRate = sampleRate }
2255+
22162256
fun uri(uri: String) = uri(JsonField.of(uri))
22172257

22182258
/**
@@ -2258,6 +2298,7 @@ private constructor(
22582298
data,
22592299
mimeType,
22602300
rate,
2301+
sampleRate,
22612302
uri,
22622303
additionalProperties.toMutableMap(),
22632304
)
@@ -2281,6 +2322,7 @@ private constructor(
22812322
data()
22822323
mimeType().ifPresent { it.validate() }
22832324
rate()
2325+
sampleRate()
22842326
uri()
22852327
validated = true
22862328
}
@@ -2306,6 +2348,7 @@ private constructor(
23062348
(if (data.asKnown().isPresent) 1 else 0) +
23072349
(mimeType.asKnown().getOrNull()?.validity() ?: 0) +
23082350
(if (rate.asKnown().isPresent) 1 else 0) +
2351+
(if (sampleRate.asKnown().isPresent) 1 else 0) +
23092352
(if (uri.asKnown().isPresent) 1 else 0)
23102353

23112354
class MimeType @JsonCreator private constructor(private val value: JsonField<String>) :
@@ -2511,18 +2554,28 @@ private constructor(
25112554
data == other.data &&
25122555
mimeType == other.mimeType &&
25132556
rate == other.rate &&
2557+
sampleRate == other.sampleRate &&
25142558
uri == other.uri &&
25152559
additionalProperties == other.additionalProperties
25162560
}
25172561

25182562
private val hashCode: Int by lazy {
2519-
Objects.hash(type, channels, data, mimeType, rate, uri, additionalProperties)
2563+
Objects.hash(
2564+
type,
2565+
channels,
2566+
data,
2567+
mimeType,
2568+
rate,
2569+
sampleRate,
2570+
uri,
2571+
additionalProperties,
2572+
)
25202573
}
25212574

25222575
override fun hashCode(): Int = hashCode
25232576

25242577
override fun toString() =
2525-
"Audio{type=$type, channels=$channels, data=$data, mimeType=$mimeType, rate=$rate, uri=$uri, additionalProperties=$additionalProperties}"
2578+
"Audio{type=$type, channels=$channels, data=$data, mimeType=$mimeType, rate=$rate, sampleRate=$sampleRate, uri=$uri, additionalProperties=$additionalProperties}"
25262579
}
25272580

25282581
class Document

0 commit comments

Comments
 (0)