Skip to content

Commit

Permalink
Encode default value for content
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 committed Mar 14, 2024
1 parent 2cecdba commit b1bc0a4
Showing 1 changed file with 4 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,8 @@ 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 b1bc0a4

Please sign in to comment.