@@ -39,6 +39,35 @@ public class TextPart(public val text: String) : Part {
3939 @Serializable internal data class Internal (val text : String ) : InternalPart
4040}
4141
42+ public class CodeExecutionResultPart (public val outcome : String , public val output : String ) : Part {
43+
44+ @Serializable
45+ internal data class Internal (
46+ @SerialName(" codeExecutionResult" ) val codeExecutionResult : CodeExecutionResult
47+ ) : InternalPart {
48+
49+ @Serializable
50+ internal data class CodeExecutionResult (
51+ @SerialName(" outcome" ) val outcome : String ,
52+ val output : String
53+ )
54+ }
55+ }
56+
57+ public class ExecutableCodePart (public val language : String , public val code : String ) : Part {
58+
59+ @Serializable
60+ internal data class Internal (@SerialName(" executableCode" ) val executableCode : ExecutableCode ) :
61+ InternalPart {
62+
63+ @Serializable
64+ internal data class ExecutableCode (
65+ @SerialName(" language" ) val language : String ,
66+ val code : String
67+ )
68+ }
69+ }
70+
4271/* *
4372 * Represents image data sent to and received from requests. The image is converted client-side to
4473 * JPEG encoding at 80% quality before being sent to the server.
@@ -176,6 +205,8 @@ internal object PartSerializer :
176205 val jsonObject = element.jsonObject
177206 return when {
178207 " text" in jsonObject -> TextPart .Internal .serializer()
208+ " executableCode" in jsonObject -> ExecutableCodePart .Internal .serializer()
209+ " codeExecutionResult" in jsonObject -> CodeExecutionResultPart .Internal .serializer()
179210 " functionCall" in jsonObject -> FunctionCallPart .Internal .serializer()
180211 " functionResponse" in jsonObject -> FunctionResponsePart .Internal .serializer()
181212 " inlineData" in jsonObject -> InlineDataPart .Internal .serializer()
@@ -207,6 +238,12 @@ internal fun Part.toInternal(): InternalPart {
207238 )
208239 is FileDataPart ->
209240 FileDataPart .Internal (FileDataPart .Internal .FileData (mimeType = mimeType, fileUri = uri))
241+ is ExecutableCodePart ->
242+ ExecutableCodePart .Internal (ExecutableCodePart .Internal .ExecutableCode (language, code))
243+ is CodeExecutionResultPart ->
244+ CodeExecutionResultPart .Internal (
245+ CodeExecutionResultPart .Internal .CodeExecutionResult (outcome, output)
246+ )
210247 else ->
211248 throw com.google.firebase.ai.type.SerializationException (
212249 " The given subclass of Part (${javaClass.simpleName} ) is not supported in the serialization yet."
@@ -241,6 +278,10 @@ internal fun InternalPart.toPublic(): Part {
241278 is FunctionResponsePart .Internal ->
242279 FunctionResponsePart (functionResponse.name, functionResponse.response, functionResponse.id)
243280 is FileDataPart .Internal -> FileDataPart (fileData.mimeType, fileData.fileUri)
281+ is ExecutableCodePart .Internal ->
282+ ExecutableCodePart (executableCode.language, executableCode.code)
283+ is CodeExecutionResultPart .Internal ->
284+ CodeExecutionResultPart (codeExecutionResult.outcome, codeExecutionResult.output)
244285 else ->
245286 throw com.google.firebase.ai.type.SerializationException (
246287 " Unsupported part type \" ${javaClass.simpleName} \" provided. This model may not be supported by this SDK."
0 commit comments