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

commonMain.com.xebia.functional.openai.generated.model.RunStepDeltaObjectDeltaStepDetails.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.RunStepDeltaStepDetailsMessageCreationObject
import com.xebia.functional.openai.generated.model.RunStepDeltaStepDetailsMessageCreationObjectMessageCreation
import com.xebia.functional.openai.generated.model.RunStepDeltaStepDetailsToolCallsObject
import com.xebia.functional.openai.generated.model.RunStepDeltaStepDetailsToolCallsObjectToolCallsInner
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 = RunStepDeltaObjectDeltaStepDetailsSerializer::class)
sealed interface RunStepDeltaObjectDeltaStepDetails {

  @JvmInline
  @Serializable
  value class CaseRunStepDeltaStepDetailsMessageCreationObject(val value: RunStepDeltaStepDetailsMessageCreationObject): RunStepDeltaObjectDeltaStepDetails
  @JvmInline
  @Serializable
  value class CaseRunStepDeltaStepDetailsToolCallsObject(val value: RunStepDeltaStepDetailsToolCallsObject): RunStepDeltaObjectDeltaStepDetails

}

object RunStepDeltaObjectDeltaStepDetailsSerializer : KSerializer {
    @OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
    override val descriptor: SerialDescriptor = buildSerialDescriptor("RunStepDeltaObjectDeltaStepDetails", PolymorphicKind.SEALED) { 
      element("1", RunStepDeltaStepDetailsMessageCreationObject.serializer().descriptor)
      element("2", RunStepDeltaStepDetailsToolCallsObject.serializer().descriptor)
    }

    override fun deserialize(decoder: Decoder): RunStepDeltaObjectDeltaStepDetails {
      val jsonSerde = Json { ignoreUnknownKeys = true }
      val json = decoder.decodeSerializableValue(JsonElement.serializer())
      return attemptDeserialize(json, 
        Pair(RunStepDeltaObjectDeltaStepDetails.CaseRunStepDeltaStepDetailsMessageCreationObject::class) {
          RunStepDeltaObjectDeltaStepDetails.CaseRunStepDeltaStepDetailsMessageCreationObject(jsonSerde.decodeFromJsonElement(RunStepDeltaStepDetailsMessageCreationObject.serializer(), json))
      },
        Pair(RunStepDeltaObjectDeltaStepDetails.CaseRunStepDeltaStepDetailsToolCallsObject::class) {
          RunStepDeltaObjectDeltaStepDetails.CaseRunStepDeltaStepDetailsToolCallsObject(jsonSerde.decodeFromJsonElement(RunStepDeltaStepDetailsToolCallsObject.serializer(), json))
      })
    }

    override fun serialize(encoder: Encoder, value: RunStepDeltaObjectDeltaStepDetails) =
      when(value) { 
        is RunStepDeltaObjectDeltaStepDetails.CaseRunStepDeltaStepDetailsMessageCreationObject ->
        encoder.encodeSerializableValue(RunStepDeltaStepDetailsMessageCreationObject.serializer(), value.value)

        is RunStepDeltaObjectDeltaStepDetails.CaseRunStepDeltaStepDetailsToolCallsObject ->
        encoder.encodeSerializableValue(RunStepDeltaStepDetailsToolCallsObject.serializer(), value.value)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy