commonMain.com.xebia.functional.openai.generated.model.RunStepObjectStepDetails.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.RunStepDetailsMessageCreationObject
import com.xebia.functional.openai.generated.model.RunStepDetailsMessageCreationObjectMessageCreation
import com.xebia.functional.openai.generated.model.RunStepDetailsToolCallsObject
import com.xebia.functional.openai.generated.model.RunStepDetailsToolCallsObjectToolCallsInner
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 = RunStepObjectStepDetailsSerializer::class)
sealed interface RunStepObjectStepDetails {
@JvmInline
@Serializable
value class CaseRunStepDetailsMessageCreationObject(val value: RunStepDetailsMessageCreationObject): RunStepObjectStepDetails
@JvmInline
@Serializable
value class CaseRunStepDetailsToolCallsObject(val value: RunStepDetailsToolCallsObject): RunStepObjectStepDetails
}
object RunStepObjectStepDetailsSerializer : KSerializer {
@OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
override val descriptor: SerialDescriptor = buildSerialDescriptor("RunStepObjectStepDetails", PolymorphicKind.SEALED) {
element("1", RunStepDetailsMessageCreationObject.serializer().descriptor)
element("2", RunStepDetailsToolCallsObject.serializer().descriptor)
}
override fun deserialize(decoder: Decoder): RunStepObjectStepDetails {
val jsonSerde = Json { ignoreUnknownKeys = true }
val json = decoder.decodeSerializableValue(JsonElement.serializer())
return attemptDeserialize(json,
Pair(RunStepObjectStepDetails.CaseRunStepDetailsMessageCreationObject::class) {
RunStepObjectStepDetails.CaseRunStepDetailsMessageCreationObject(jsonSerde.decodeFromJsonElement(RunStepDetailsMessageCreationObject.serializer(), json))
},
Pair(RunStepObjectStepDetails.CaseRunStepDetailsToolCallsObject::class) {
RunStepObjectStepDetails.CaseRunStepDetailsToolCallsObject(jsonSerde.decodeFromJsonElement(RunStepDetailsToolCallsObject.serializer(), json))
})
}
override fun serialize(encoder: Encoder, value: RunStepObjectStepDetails) =
when(value) {
is RunStepObjectStepDetails.CaseRunStepDetailsMessageCreationObject ->
encoder.encodeSerializableValue(RunStepDetailsMessageCreationObject.serializer(), value.value)
is RunStepObjectStepDetails.CaseRunStepDetailsToolCallsObject ->
encoder.encodeSerializableValue(RunStepDetailsToolCallsObject.serializer(), value.value)
}
}