commonMain.com.xebia.functional.openai.generated.model.CreateMessageRequestContent.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.ArrayOfContentPartsInner
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 = CreateMessageRequestContentSerializer::class)
sealed interface CreateMessageRequestContent {
@JvmInline
@Serializable
value class CaseString(val value: kotlin.String): CreateMessageRequestContent
@JvmInline
@Serializable
value class CaseArrayOfContentPartsInners(val value: kotlin.collections.List): CreateMessageRequestContent
}
object CreateMessageRequestContentSerializer : KSerializer {
@OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
override val descriptor: SerialDescriptor = buildSerialDescriptor("CreateMessageRequestContent", PolymorphicKind.SEALED) {
element("1", kotlin.String.serializer().descriptor)
element("2", ListSerializer(ArrayOfContentPartsInner.serializer()).descriptor)
}
override fun deserialize(decoder: Decoder): CreateMessageRequestContent {
val jsonSerde = Json { ignoreUnknownKeys = true }
val json = decoder.decodeSerializableValue(JsonElement.serializer())
return attemptDeserialize(json,
Pair(CreateMessageRequestContent.CaseString::class) {
CreateMessageRequestContent.CaseString(jsonSerde.decodeFromJsonElement(kotlin.String.serializer(), json))
},
Pair(CreateMessageRequestContent.CaseArrayOfContentPartsInners::class) {
CreateMessageRequestContent.CaseArrayOfContentPartsInners(jsonSerde.decodeFromJsonElement(ListSerializer(ArrayOfContentPartsInner.serializer()), json))
})
}
override fun serialize(encoder: Encoder, value: CreateMessageRequestContent) =
when(value) {
is CreateMessageRequestContent.CaseString ->
encoder.encodeSerializableValue(kotlin.String.serializer(), value.value)
is CreateMessageRequestContent.CaseArrayOfContentPartsInners ->
encoder.encodeSerializableValue(ListSerializer(ArrayOfContentPartsInner.serializer()), value.value)
}
}