Skip to content

Commit 82ba5a4

Browse files
committed
update parts
1 parent 0f74341 commit 82ba5a4

File tree

1 file changed

+17
-5
lines changed
  • firebase-ai/src/main/kotlin/com/google/firebase/ai/type

1 file changed

+17
-5
lines changed

firebase-ai/src/main/kotlin/com/google/firebase/ai/type/Part.kt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,21 @@ internal constructor(
5353
) : InternalPart
5454
}
5555

56+
/**
57+
* Represents the code execution result from the model.
58+
* @property outcome The result of the execution.
59+
* @property output The stdout from the code execution, or an error message if it failed.
60+
* @property isThought Indicates whether the response is a thought.
61+
*/
5662
public class CodeExecutionResultPart
5763
internal constructor(
58-
public val outcome: String,
64+
public val outcome: Outcome,
5965
public val output: String,
6066
public override val isThought: Boolean,
6167
internal val thoughtSignature: String?
6268
) : Part {
6369

64-
public constructor(outcome: String, output: String) : this(outcome, output, false, null)
70+
public constructor(outcome: Outcome, output: String) : this(outcome, output, false, null)
6571

6672
@Serializable
6773
internal data class Internal(
@@ -72,12 +78,18 @@ internal constructor(
7278

7379
@Serializable
7480
internal data class CodeExecutionResult(
75-
@SerialName("outcome") val outcome: String,
81+
@SerialName("outcome") val outcome: Outcome.Internal,
7682
val output: String
7783
)
7884
}
7985
}
8086

87+
/**
88+
* Represents the code that is executed by the model.
89+
* @property language The programming language of the code.
90+
* @property code The source code to be executed.
91+
* @property isThought Indicates whether the response is a thought.
92+
*/
8193
public class ExecutableCodePart
8294
internal constructor(
8395
public val language: String,
@@ -354,7 +366,7 @@ internal fun Part.toInternal(): InternalPart {
354366
)
355367
is CodeExecutionResultPart ->
356368
CodeExecutionResultPart.Internal(
357-
CodeExecutionResultPart.Internal.CodeExecutionResult(outcome, output),
369+
CodeExecutionResultPart.Internal.CodeExecutionResult(outcome.toInternal(), output),
358370
isThought,
359371
thoughtSignature
360372
)
@@ -410,7 +422,7 @@ internal fun InternalPart.toPublic(): Part {
410422
)
411423
is CodeExecutionResultPart.Internal ->
412424
CodeExecutionResultPart(
413-
codeExecutionResult.outcome,
425+
codeExecutionResult.outcome.toPublic(),
414426
codeExecutionResult.output,
415427
thought ?: false,
416428
thoughtSignature

0 commit comments

Comments
 (0)