File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed
firebase-ai/src/main/kotlin/com/google/firebase/ai/type Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -32,18 +32,36 @@ public class GenerateContentResponse(
3232 public val usageMetadata : UsageMetadata ? ,
3333) {
3434 /* *
35- * Convenience field representing all the text parts in the response as a single string, if they
36- * exists.
35+ * Convenience field representing all the non-thought text parts in the response as a single
36+ * string, if they exists.
3737 */
3838 public val text: String? by lazy {
39- candidates.first().content.parts.filterIsInstance<TextPart >().joinToString(" " ) { it.text }
39+ candidates
40+ .first()
41+ .content
42+ .parts
43+ .filter { ! it.isThought && it is TextPart }
44+ .joinToString(" " ) { (it as TextPart ).text }
4045 }
4146
4247 /* * Convenience field to list all the [FunctionCallPart]s in the response, if they exist. */
4348 public val functionCalls: List <FunctionCallPart > by lazy {
4449 candidates.first().content.parts.filterIsInstance<FunctionCallPart >()
4550 }
4651
52+ /* *
53+ * Convenience field representing all the text parts in the response that are marked as thoughts
54+ * as a single string, if they exists.
55+ */
56+ public val thoughtSummary: String? by lazy {
57+ candidates
58+ .first()
59+ .content
60+ .parts
61+ .filter { it.isThought && it is TextPart }
62+ .joinToString(" " ) { (it as TextPart ).text }
63+ }
64+
4765 /* *
4866 * Convenience field representing all the [InlineDataPart]s in the first candidate, if they exist.
4967 *
You can’t perform that action at this time.
0 commit comments