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