commonMain.com.xebia.functional.openai.generated.model.ArrayOfContentPartsInner.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
The newest version!
/**
*
* 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.MessageContentImageFileObject
import com.xebia.functional.openai.generated.model.MessageContentImageFileObjectImageFile
import com.xebia.functional.openai.generated.model.MessageContentImageUrlObject
import com.xebia.functional.openai.generated.model.MessageContentImageUrlObjectImageUrl
import com.xebia.functional.openai.generated.model.MessageRequestContentTextObject
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 = ArrayOfContentPartsInnerSerializer::class)
sealed interface ArrayOfContentPartsInner {
@JvmInline
@Serializable
value class CaseMessageContentImageFileObject(val value: MessageContentImageFileObject): ArrayOfContentPartsInner
@JvmInline
@Serializable
value class CaseMessageContentImageUrlObject(val value: MessageContentImageUrlObject): ArrayOfContentPartsInner
@JvmInline
@Serializable
value class CaseMessageRequestContentTextObject(val value: MessageRequestContentTextObject): ArrayOfContentPartsInner
}
object ArrayOfContentPartsInnerSerializer : KSerializer {
@OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
override val descriptor: SerialDescriptor = buildSerialDescriptor("ArrayOfContentPartsInner", PolymorphicKind.SEALED) {
element("1", MessageContentImageFileObject.serializer().descriptor)
element("2", MessageContentImageUrlObject.serializer().descriptor)
element("3", MessageRequestContentTextObject.serializer().descriptor)
}
override fun deserialize(decoder: Decoder): ArrayOfContentPartsInner {
val jsonSerde = Json { ignoreUnknownKeys = true }
val json = decoder.decodeSerializableValue(JsonElement.serializer())
return attemptDeserialize(json,
Pair(ArrayOfContentPartsInner.CaseMessageContentImageFileObject::class) {
ArrayOfContentPartsInner.CaseMessageContentImageFileObject(jsonSerde.decodeFromJsonElement(MessageContentImageFileObject.serializer(), json))
},
Pair(ArrayOfContentPartsInner.CaseMessageContentImageUrlObject::class) {
ArrayOfContentPartsInner.CaseMessageContentImageUrlObject(jsonSerde.decodeFromJsonElement(MessageContentImageUrlObject.serializer(), json))
},
Pair(ArrayOfContentPartsInner.CaseMessageRequestContentTextObject::class) {
ArrayOfContentPartsInner.CaseMessageRequestContentTextObject(jsonSerde.decodeFromJsonElement(MessageRequestContentTextObject.serializer(), json))
})
}
override fun serialize(encoder: Encoder, value: ArrayOfContentPartsInner) =
when(value) {
is ArrayOfContentPartsInner.CaseMessageContentImageFileObject ->
encoder.encodeSerializableValue(MessageContentImageFileObject.serializer(), value.value)
is ArrayOfContentPartsInner.CaseMessageContentImageUrlObject ->
encoder.encodeSerializableValue(MessageContentImageUrlObject.serializer(), value.value)
is ArrayOfContentPartsInner.CaseMessageRequestContentTextObject ->
encoder.encodeSerializableValue(MessageRequestContentTextObject.serializer(), value.value)
}
}