|
16 | 16 |
|
17 | 17 | package com.google.firebase.vertexai.type
|
18 | 18 |
|
19 |
| -/* Represents the response from the server. */ |
| 19 | +/** |
| 20 | + * Represents the response from the model for live content updates. |
| 21 | + * |
| 22 | + * This class encapsulates the content data, the status of the response, and any function calls |
| 23 | + * included in the response. |
| 24 | + */ |
20 | 25 | @PublicPreviewAPI
|
21 | 26 | public class LiveContentResponse
|
22 | 27 | internal constructor(
|
| 28 | + |
| 29 | + /** The main content data of the response. This can be `null` if there is no content. */ |
23 | 30 | public val data: Content?,
|
| 31 | + |
| 32 | + /** |
| 33 | + * The status of the live content response. Indicates whether the response is normal, was |
| 34 | + * interrupted, or signifies the completion of a turn. |
| 35 | + */ |
24 | 36 | public val status: Status,
|
| 37 | + |
| 38 | + /** |
| 39 | + * A list of [FunctionCallPart] included in the response, if any. |
| 40 | + * |
| 41 | + * This list can be null or empty if no function calls are present. |
| 42 | + */ |
25 | 43 | public val functionCalls: List<FunctionCallPart>?
|
26 | 44 | ) {
|
| 45 | + |
27 | 46 | /**
|
28 | 47 | * Convenience field representing all the text parts in the response as a single string, if they
|
29 | 48 | * exists.
|
30 | 49 | */
|
31 | 50 | public val text: String? =
|
32 | 51 | data?.parts?.filterIsInstance<TextPart>()?.joinToString(" ") { it.text }
|
33 | 52 |
|
| 53 | + /** Represents the status of a [LiveContentResponse], within a single interaction. */ |
34 | 54 | @JvmInline
|
35 | 55 | public value class Status private constructor(private val value: Int) {
|
36 | 56 | public companion object {
|
| 57 | + /** The server is actively sending data for the current interaction. */ |
37 | 58 | public val NORMAL: Status = Status(0)
|
| 59 | + /** |
| 60 | + * The server was interrupted while generating data. |
| 61 | + * |
| 62 | + * An interruption occurs when the client sends a message while the server is [actively] |
| 63 | + * [NORMAL] sending data. |
| 64 | + */ |
38 | 65 | public val INTERRUPTED: Status = Status(1)
|
| 66 | + /** |
| 67 | + * The model has finished sending data in the current interaction. |
| 68 | + * |
| 69 | + * Can be set alongside content, signifying that the content is the last in the turn. |
| 70 | + */ |
39 | 71 | public val TURN_COMPLETE: Status = Status(2)
|
40 | 72 | }
|
41 | 73 | }
|
|
0 commit comments