commonMain.com.xebia.functional.openai.generated.model.ChunkingStrategyRequestParam.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-jvm Show documentation
Show all versions of xef-openai-client-jvm 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.AutoChunkingStrategyRequestParam
import com.xebia.functional.openai.generated.model.StaticChunkingStrategy
import com.xebia.functional.openai.generated.model.StaticChunkingStrategyRequestParam
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 = ChunkingStrategyRequestParamSerializer::class)
sealed interface ChunkingStrategyRequestParam {
@JvmInline
@Serializable
value class CaseAutoChunkingStrategyRequestParam(val value: AutoChunkingStrategyRequestParam): ChunkingStrategyRequestParam
@JvmInline
@Serializable
value class CaseStaticChunkingStrategyRequestParam(val value: StaticChunkingStrategyRequestParam): ChunkingStrategyRequestParam
}
object ChunkingStrategyRequestParamSerializer : KSerializer {
@OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
override val descriptor: SerialDescriptor = buildSerialDescriptor("ChunkingStrategyRequestParam", PolymorphicKind.SEALED) {
element("1", AutoChunkingStrategyRequestParam.serializer().descriptor)
element("2", StaticChunkingStrategyRequestParam.serializer().descriptor)
}
override fun deserialize(decoder: Decoder): ChunkingStrategyRequestParam {
val jsonSerde = Json { ignoreUnknownKeys = true }
val json = decoder.decodeSerializableValue(JsonElement.serializer())
return attemptDeserialize(json,
Pair(ChunkingStrategyRequestParam.CaseAutoChunkingStrategyRequestParam::class) {
ChunkingStrategyRequestParam.CaseAutoChunkingStrategyRequestParam(jsonSerde.decodeFromJsonElement(AutoChunkingStrategyRequestParam.serializer(), json))
},
Pair(ChunkingStrategyRequestParam.CaseStaticChunkingStrategyRequestParam::class) {
ChunkingStrategyRequestParam.CaseStaticChunkingStrategyRequestParam(jsonSerde.decodeFromJsonElement(StaticChunkingStrategyRequestParam.serializer(), json))
})
}
override fun serialize(encoder: Encoder, value: ChunkingStrategyRequestParam) =
when(value) {
is ChunkingStrategyRequestParam.CaseAutoChunkingStrategyRequestParam ->
encoder.encodeSerializableValue(AutoChunkingStrategyRequestParam.serializer(), value.value)
is ChunkingStrategyRequestParam.CaseStaticChunkingStrategyRequestParam ->
encoder.encodeSerializableValue(StaticChunkingStrategyRequestParam.serializer(), value.value)
}
}