@@ -7,21 +7,15 @@ import com.fasterxml.jackson.annotation.JsonAnySetter
7
7
import com.fasterxml.jackson.annotation.JsonCreator
8
8
import com.fasterxml.jackson.annotation.JsonProperty
9
9
import com.fasterxml.jackson.core.JsonGenerator
10
- import com.fasterxml.jackson.core.ObjectCodec
11
- import com.fasterxml.jackson.databind.JsonNode
12
10
import com.fasterxml.jackson.databind.SerializerProvider
13
- import com.fasterxml.jackson.databind.annotation.JsonDeserialize
14
11
import com.fasterxml.jackson.databind.annotation.JsonSerialize
15
- import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
16
- import com.openai.core.BaseDeserializer
17
12
import com.openai.core.BaseSerializer
18
13
import com.openai.core.Enum
19
14
import com.openai.core.ExcludeMissing
20
15
import com.openai.core.JsonField
21
16
import com.openai.core.JsonValue
22
17
import com.openai.core.MultipartField
23
18
import com.openai.core.Params
24
- import com.openai.core.allMaxBy
25
19
import com.openai.core.checkKnown
26
20
import com.openai.core.checkRequired
27
21
import com.openai.core.getOrThrow
@@ -1220,7 +1214,6 @@ private constructor(
1220
1214
* object can be provided to tweak VAD detection parameters manually. If unset, the audio is
1221
1215
* transcribed as a single block.
1222
1216
*/
1223
- @JsonDeserialize(using = ChunkingStrategy .Deserializer ::class )
1224
1217
@JsonSerialize(using = ChunkingStrategy .Serializer ::class )
1225
1218
class ChunkingStrategy
1226
1219
private constructor (
@@ -1285,25 +1278,6 @@ private constructor(
1285
1278
false
1286
1279
}
1287
1280
1288
- /* *
1289
- * Returns a score indicating how many valid values are contained in this object
1290
- * recursively.
1291
- *
1292
- * Used for best match union deserialization.
1293
- */
1294
- @JvmSynthetic
1295
- internal fun validity (): Int =
1296
- accept(
1297
- object : Visitor <Int > {
1298
- override fun visitAuto (auto : JsonValue ) =
1299
- auto.let { if (it == JsonValue .from(" auto" )) 1 else 0 }
1300
-
1301
- override fun visitVadConfig (vadConfig : VadConfig ) = 1
1302
-
1303
- override fun unknown (json : JsonValue ? ) = 0
1304
- }
1305
- )
1306
-
1307
1281
override fun equals (other : Any? ): Boolean {
1308
1282
if (this == = other) {
1309
1283
return true
@@ -1361,36 +1335,6 @@ private constructor(
1361
1335
}
1362
1336
}
1363
1337
1364
- internal class Deserializer : BaseDeserializer <ChunkingStrategy >(ChunkingStrategy : :class) {
1365
-
1366
- override fun ObjectCodec.deserialize (node : JsonNode ): ChunkingStrategy {
1367
- val json = JsonValue .fromJsonNode(node)
1368
-
1369
- val bestMatches =
1370
- sequenceOf(
1371
- tryDeserialize(node, jacksonTypeRef<JsonValue >())
1372
- ?.let { ChunkingStrategy (auto = it, _json = json) }
1373
- ?.takeIf { it.isValid() },
1374
- tryDeserialize(node, jacksonTypeRef<VadConfig >())?.let {
1375
- ChunkingStrategy (vadConfig = it, _json = json)
1376
- },
1377
- )
1378
- .filterNotNull()
1379
- .allMaxBy { it.validity() }
1380
- .toList()
1381
- return when (bestMatches.size) {
1382
- // This can happen if what we're deserializing is completely incompatible with
1383
- // all the possible variants (e.g. deserializing from array).
1384
- 0 -> ChunkingStrategy (_json = json)
1385
- 1 -> bestMatches.single()
1386
- // If there's more than one match with the highest validity, then use the first
1387
- // completely valid match, or simply the first match if none are completely
1388
- // valid.
1389
- else -> bestMatches.firstOrNull { it.isValid() } ? : bestMatches.first()
1390
- }
1391
- }
1392
- }
1393
-
1394
1338
internal class Serializer : BaseSerializer <ChunkingStrategy >(ChunkingStrategy : :class) {
1395
1339
1396
1340
override fun serialize (
0 commit comments