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