commonMain.com.xebia.functional.openai.generated.model.AssistantObjectToolsInner.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.AssistantToolsCode
import com.xebia.functional.openai.generated.model.AssistantToolsFileSearch
import com.xebia.functional.openai.generated.model.AssistantToolsFileSearchFileSearch
import com.xebia.functional.openai.generated.model.AssistantToolsFunction
import com.xebia.functional.openai.generated.model.FunctionObject
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 = AssistantObjectToolsInnerSerializer::class)
sealed interface AssistantObjectToolsInner {
@JvmInline
@Serializable
value class CaseAssistantToolsCode(val value: AssistantToolsCode): AssistantObjectToolsInner
@JvmInline
@Serializable
value class CaseAssistantToolsFileSearch(val value: AssistantToolsFileSearch): AssistantObjectToolsInner
@JvmInline
@Serializable
value class CaseAssistantToolsFunction(val value: AssistantToolsFunction): AssistantObjectToolsInner
}
object AssistantObjectToolsInnerSerializer : KSerializer {
@OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
override val descriptor: SerialDescriptor = buildSerialDescriptor("AssistantObjectToolsInner", PolymorphicKind.SEALED) {
element("1", AssistantToolsCode.serializer().descriptor)
element("2", AssistantToolsFileSearch.serializer().descriptor)
element("3", AssistantToolsFunction.serializer().descriptor)
}
override fun deserialize(decoder: Decoder): AssistantObjectToolsInner {
val jsonSerde = Json { ignoreUnknownKeys = true }
val json = decoder.decodeSerializableValue(JsonElement.serializer())
return attemptDeserialize(json,
Pair(AssistantObjectToolsInner.CaseAssistantToolsCode::class) {
AssistantObjectToolsInner.CaseAssistantToolsCode(jsonSerde.decodeFromJsonElement(AssistantToolsCode.serializer(), json))
},
Pair(AssistantObjectToolsInner.CaseAssistantToolsFileSearch::class) {
AssistantObjectToolsInner.CaseAssistantToolsFileSearch(jsonSerde.decodeFromJsonElement(AssistantToolsFileSearch.serializer(), json))
},
Pair(AssistantObjectToolsInner.CaseAssistantToolsFunction::class) {
AssistantObjectToolsInner.CaseAssistantToolsFunction(jsonSerde.decodeFromJsonElement(AssistantToolsFunction.serializer(), json))
})
}
override fun serialize(encoder: Encoder, value: AssistantObjectToolsInner) =
when(value) {
is AssistantObjectToolsInner.CaseAssistantToolsCode ->
encoder.encodeSerializableValue(AssistantToolsCode.serializer(), value.value)
is AssistantObjectToolsInner.CaseAssistantToolsFileSearch ->
encoder.encodeSerializableValue(AssistantToolsFileSearch.serializer(), value.value)
is AssistantObjectToolsInner.CaseAssistantToolsFunction ->
encoder.encodeSerializableValue(AssistantToolsFunction.serializer(), value.value)
}
}