Skip to content

Commit

Permalink
Encode default value for content (#82)
Browse files Browse the repository at this point in the history
By default, kotlin serialization does not encode default values. In the case of content, we do want to serialize it.
  • Loading branch information
rlazo authored Mar 14, 2024
1 parent 2cecdba commit 87469b6
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package com.google.ai.client.generativeai.internal.api.shared

import com.google.ai.client.generativeai.internal.util.FirstOrdinalSerializer
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.EncodeDefault
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand All @@ -40,7 +42,9 @@ internal enum class HarmCategory {

typealias Base64 = String

@Serializable internal data class Content(val role: String? = "user", val parts: List<Part>)
@ExperimentalSerializationApi
@Serializable
internal data class Content(@EncodeDefault val role: String? = "user", val parts: List<Part>)

@Serializable(PartSerializer::class) internal sealed interface Part

Expand Down

0 comments on commit 87469b6

Please sign in to comment.