commonMain.com.xebia.functional.openai.generated.model.MessageDeltaObjectDeltaContentInner.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.MessageDeltaContentImageFileObject
import com.xebia.functional.openai.generated.model.MessageDeltaContentImageFileObjectImageFile
import com.xebia.functional.openai.generated.model.MessageDeltaContentImageUrlObject
import com.xebia.functional.openai.generated.model.MessageDeltaContentImageUrlObjectImageUrl
import com.xebia.functional.openai.generated.model.MessageDeltaContentRefusalObject
import com.xebia.functional.openai.generated.model.MessageDeltaContentTextObject
import com.xebia.functional.openai.generated.model.MessageDeltaContentTextObjectText
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 = MessageDeltaObjectDeltaContentInnerSerializer::class)
sealed interface MessageDeltaObjectDeltaContentInner {
@JvmInline
@Serializable
value class CaseMessageDeltaContentImageFileObject(val value: MessageDeltaContentImageFileObject): MessageDeltaObjectDeltaContentInner
@JvmInline
@Serializable
value class CaseMessageDeltaContentImageUrlObject(val value: MessageDeltaContentImageUrlObject): MessageDeltaObjectDeltaContentInner
@JvmInline
@Serializable
value class CaseMessageDeltaContentRefusalObject(val value: MessageDeltaContentRefusalObject): MessageDeltaObjectDeltaContentInner
@JvmInline
@Serializable
value class CaseMessageDeltaContentTextObject(val value: MessageDeltaContentTextObject): MessageDeltaObjectDeltaContentInner
}
object MessageDeltaObjectDeltaContentInnerSerializer : KSerializer {
@OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
override val descriptor: SerialDescriptor = buildSerialDescriptor("MessageDeltaObjectDeltaContentInner", PolymorphicKind.SEALED) {
element("1", MessageDeltaContentImageFileObject.serializer().descriptor)
element("2", MessageDeltaContentImageUrlObject.serializer().descriptor)
element("3", MessageDeltaContentRefusalObject.serializer().descriptor)
element("4", MessageDeltaContentTextObject.serializer().descriptor)
}
override fun deserialize(decoder: Decoder): MessageDeltaObjectDeltaContentInner {
val jsonSerde = Json { ignoreUnknownKeys = true }
val json = decoder.decodeSerializableValue(JsonElement.serializer())
return attemptDeserialize(json,
Pair(MessageDeltaObjectDeltaContentInner.CaseMessageDeltaContentImageFileObject::class) {
MessageDeltaObjectDeltaContentInner.CaseMessageDeltaContentImageFileObject(jsonSerde.decodeFromJsonElement(MessageDeltaContentImageFileObject.serializer(), json))
},
Pair(MessageDeltaObjectDeltaContentInner.CaseMessageDeltaContentImageUrlObject::class) {
MessageDeltaObjectDeltaContentInner.CaseMessageDeltaContentImageUrlObject(jsonSerde.decodeFromJsonElement(MessageDeltaContentImageUrlObject.serializer(), json))
},
Pair(MessageDeltaObjectDeltaContentInner.CaseMessageDeltaContentRefusalObject::class) {
MessageDeltaObjectDeltaContentInner.CaseMessageDeltaContentRefusalObject(jsonSerde.decodeFromJsonElement(MessageDeltaContentRefusalObject.serializer(), json))
},
Pair(MessageDeltaObjectDeltaContentInner.CaseMessageDeltaContentTextObject::class) {
MessageDeltaObjectDeltaContentInner.CaseMessageDeltaContentTextObject(jsonSerde.decodeFromJsonElement(MessageDeltaContentTextObject.serializer(), json))
})
}
override fun serialize(encoder: Encoder, value: MessageDeltaObjectDeltaContentInner) =
when(value) {
is MessageDeltaObjectDeltaContentInner.CaseMessageDeltaContentImageFileObject ->
encoder.encodeSerializableValue(MessageDeltaContentImageFileObject.serializer(), value.value)
is MessageDeltaObjectDeltaContentInner.CaseMessageDeltaContentImageUrlObject ->
encoder.encodeSerializableValue(MessageDeltaContentImageUrlObject.serializer(), value.value)
is MessageDeltaObjectDeltaContentInner.CaseMessageDeltaContentRefusalObject ->
encoder.encodeSerializableValue(MessageDeltaContentRefusalObject.serializer(), value.value)
is MessageDeltaObjectDeltaContentInner.CaseMessageDeltaContentTextObject ->
encoder.encodeSerializableValue(MessageDeltaContentTextObject.serializer(), value.value)
}
}