commonMain.com.xebia.functional.openai.generated.model.CreateTranscription200Response.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xef-openai-client Show documentation
Show all versions of xef-openai-client Show documentation
Building applications with LLMs through composability in Kotlin
/**
*
* Please note:
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* Do not edit this file manually.
*
*/
@file:Suppress(
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport"
)
package com.xebia.functional.openai.generated.model
import com.xebia.functional.openai.generated.model.CreateTranscriptionResponseJson
import com.xebia.functional.openai.generated.model.CreateTranscriptionResponseVerboseJson
import com.xebia.functional.openai.generated.model.TranscriptionSegment
import com.xebia.functional.openai.generated.model.TranscriptionWord
import com.xebia.functional.openai.attemptDeserialize
import kotlin.jvm.JvmInline
import kotlinx.serialization.*
import kotlinx.serialization.builtins.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*
@Serializable(with = CreateTranscription200ResponseSerializer::class)
sealed interface CreateTranscription200Response {
@JvmInline
@Serializable
value class CaseCreateTranscriptionResponseJson(val value: CreateTranscriptionResponseJson): CreateTranscription200Response
@JvmInline
@Serializable
value class CaseCreateTranscriptionResponseVerboseJson(val value: CreateTranscriptionResponseVerboseJson): CreateTranscription200Response
}
object CreateTranscription200ResponseSerializer : KSerializer {
@OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
override val descriptor: SerialDescriptor = buildSerialDescriptor("CreateTranscription200Response", PolymorphicKind.SEALED) {
element("1", CreateTranscriptionResponseJson.serializer().descriptor)
element("2", CreateTranscriptionResponseVerboseJson.serializer().descriptor)
}
override fun deserialize(decoder: Decoder): CreateTranscription200Response {
val jsonSerde = Json { ignoreUnknownKeys = true }
val json = decoder.decodeSerializableValue(JsonElement.serializer())
return attemptDeserialize(json,
Pair(CreateTranscription200Response.CaseCreateTranscriptionResponseJson::class) {
CreateTranscription200Response.CaseCreateTranscriptionResponseJson(jsonSerde.decodeFromJsonElement(CreateTranscriptionResponseJson.serializer(), json))
},
Pair(CreateTranscription200Response.CaseCreateTranscriptionResponseVerboseJson::class) {
CreateTranscription200Response.CaseCreateTranscriptionResponseVerboseJson(jsonSerde.decodeFromJsonElement(CreateTranscriptionResponseVerboseJson.serializer(), json))
})
}
override fun serialize(encoder: Encoder, value: CreateTranscription200Response) =
when(value) {
is CreateTranscription200Response.CaseCreateTranscriptionResponseJson ->
encoder.encodeSerializableValue(CreateTranscriptionResponseJson.serializer(), value.value)
is CreateTranscription200Response.CaseCreateTranscriptionResponseVerboseJson ->
encoder.encodeSerializableValue(CreateTranscriptionResponseVerboseJson.serializer(), value.value)
}
}