All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.xebia.functional.openai.generated.model.RunStepObjectStepDetails.kt Maven / Gradle / Ivy

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)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy