commonMain.com.xebia.functional.openai.generated.model.FinetuneChatRequestInputMessagesInner.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.ChatCompletionMessageToolCall
import com.xebia.functional.openai.generated.model.ChatCompletionRequestAssistantMessageFunctionCall
import com.xebia.functional.openai.generated.model.ChatCompletionRequestFunctionMessage
import com.xebia.functional.openai.generated.model.ChatCompletionRequestSystemMessage
import com.xebia.functional.openai.generated.model.ChatCompletionRequestToolMessage
import com.xebia.functional.openai.generated.model.ChatCompletionRequestUserMessage
import com.xebia.functional.openai.generated.model.FineTuneChatCompletionRequestAssistantMessage
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 = FinetuneChatRequestInputMessagesInnerSerializer::class)
sealed interface FinetuneChatRequestInputMessagesInner {
@JvmInline
@Serializable
value class CaseChatCompletionRequestFunctionMessage(val value: ChatCompletionRequestFunctionMessage): FinetuneChatRequestInputMessagesInner
@JvmInline
@Serializable
value class CaseChatCompletionRequestSystemMessage(val value: ChatCompletionRequestSystemMessage): FinetuneChatRequestInputMessagesInner
@JvmInline
@Serializable
value class CaseChatCompletionRequestToolMessage(val value: ChatCompletionRequestToolMessage): FinetuneChatRequestInputMessagesInner
@JvmInline
@Serializable
value class CaseChatCompletionRequestUserMessage(val value: ChatCompletionRequestUserMessage): FinetuneChatRequestInputMessagesInner
@JvmInline
@Serializable
value class CaseFineTuneChatCompletionRequestAssistantMessage(val value: FineTuneChatCompletionRequestAssistantMessage): FinetuneChatRequestInputMessagesInner
}
object FinetuneChatRequestInputMessagesInnerSerializer : KSerializer {
@OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
override val descriptor: SerialDescriptor = buildSerialDescriptor("FinetuneChatRequestInputMessagesInner", PolymorphicKind.SEALED) {
element("1", ChatCompletionRequestFunctionMessage.serializer().descriptor)
element("2", ChatCompletionRequestSystemMessage.serializer().descriptor)
element("3", ChatCompletionRequestToolMessage.serializer().descriptor)
element("4", ChatCompletionRequestUserMessage.serializer().descriptor)
element("5", FineTuneChatCompletionRequestAssistantMessage.serializer().descriptor)
}
override fun deserialize(decoder: Decoder): FinetuneChatRequestInputMessagesInner {
val jsonSerde = Json { ignoreUnknownKeys = true }
val json = decoder.decodeSerializableValue(JsonElement.serializer())
return attemptDeserialize(json,
Pair(FinetuneChatRequestInputMessagesInner.CaseChatCompletionRequestFunctionMessage::class) {
FinetuneChatRequestInputMessagesInner.CaseChatCompletionRequestFunctionMessage(jsonSerde.decodeFromJsonElement(ChatCompletionRequestFunctionMessage.serializer(), json))
},
Pair(FinetuneChatRequestInputMessagesInner.CaseChatCompletionRequestSystemMessage::class) {
FinetuneChatRequestInputMessagesInner.CaseChatCompletionRequestSystemMessage(jsonSerde.decodeFromJsonElement(ChatCompletionRequestSystemMessage.serializer(), json))
},
Pair(FinetuneChatRequestInputMessagesInner.CaseChatCompletionRequestToolMessage::class) {
FinetuneChatRequestInputMessagesInner.CaseChatCompletionRequestToolMessage(jsonSerde.decodeFromJsonElement(ChatCompletionRequestToolMessage.serializer(), json))
},
Pair(FinetuneChatRequestInputMessagesInner.CaseChatCompletionRequestUserMessage::class) {
FinetuneChatRequestInputMessagesInner.CaseChatCompletionRequestUserMessage(jsonSerde.decodeFromJsonElement(ChatCompletionRequestUserMessage.serializer(), json))
},
Pair(FinetuneChatRequestInputMessagesInner.CaseFineTuneChatCompletionRequestAssistantMessage::class) {
FinetuneChatRequestInputMessagesInner.CaseFineTuneChatCompletionRequestAssistantMessage(jsonSerde.decodeFromJsonElement(FineTuneChatCompletionRequestAssistantMessage.serializer(), json))
})
}
override fun serialize(encoder: Encoder, value: FinetuneChatRequestInputMessagesInner) =
when(value) {
is FinetuneChatRequestInputMessagesInner.CaseChatCompletionRequestFunctionMessage ->
encoder.encodeSerializableValue(ChatCompletionRequestFunctionMessage.serializer(), value.value)
is FinetuneChatRequestInputMessagesInner.CaseChatCompletionRequestSystemMessage ->
encoder.encodeSerializableValue(ChatCompletionRequestSystemMessage.serializer(), value.value)
is FinetuneChatRequestInputMessagesInner.CaseChatCompletionRequestToolMessage ->
encoder.encodeSerializableValue(ChatCompletionRequestToolMessage.serializer(), value.value)
is FinetuneChatRequestInputMessagesInner.CaseChatCompletionRequestUserMessage ->
encoder.encodeSerializableValue(ChatCompletionRequestUserMessage.serializer(), value.value)
is FinetuneChatRequestInputMessagesInner.CaseFineTuneChatCompletionRequestAssistantMessage ->
encoder.encodeSerializableValue(FineTuneChatCompletionRequestAssistantMessage.serializer(), value.value)
}
}