Skip to content

Commit 33e989f

Browse files
VinayGuthalrlazodaymxn
authored
update javadocs (#6848)
Co-authored-by: Rodrigo Lazo <rlazo@users.noreply.github.com> Co-authored-by: Daymon <17409137+daymxn@users.noreply.github.com>
1 parent edcea54 commit 33e989f

File tree

5 files changed

+66
-10
lines changed

5 files changed

+66
-10
lines changed

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/LiveContentResponse.kt

+33-1
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,58 @@
1616

1717
package com.google.firebase.vertexai.type
1818

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+
*/
2025
@PublicPreviewAPI
2126
public class LiveContentResponse
2227
internal constructor(
28+
29+
/** The main content data of the response. This can be `null` if there is no content. */
2330
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+
*/
2436
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+
*/
2543
public val functionCalls: List<FunctionCallPart>?
2644
) {
45+
2746
/**
2847
* Convenience field representing all the text parts in the response as a single string, if they
2948
* exists.
3049
*/
3150
public val text: String? =
3251
data?.parts?.filterIsInstance<TextPart>()?.joinToString(" ") { it.text }
3352

53+
/** Represents the status of a [LiveContentResponse], within a single interaction. */
3454
@JvmInline
3555
public value class Status private constructor(private val value: Int) {
3656
public companion object {
57+
/** The server is actively sending data for the current interaction. */
3758
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+
*/
3865
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+
*/
3971
public val TURN_COMPLETE: Status = Status(2)
4072
}
4173
}

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/LiveSession.kt

+15-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import android.media.AudioFormat
2020
import android.media.AudioTrack
2121
import android.util.Log
2222
import com.google.firebase.annotations.concurrent.Background
23+
import com.google.firebase.vertexai.LiveGenerativeModel
2324
import io.ktor.client.plugins.websocket.ClientWebSocketSession
2425
import io.ktor.websocket.Frame
2526
import io.ktor.websocket.close
@@ -232,8 +233,14 @@ internal constructor(
232233
}
233234

234235
/**
235-
* Stops receiving from the server. If this function is called during an ongoing audio
236-
* conversation, the server's response will not be received, and no audio will be played.
236+
* Stops receiving from the model.
237+
*
238+
* If this function is called during an ongoing audio conversation, the model's response will not
239+
* be received, and no audio will be played; the live session object will no longer receive data
240+
* from the server.
241+
*
242+
* To resume receiving data, you must either handle it directly using [receive], or indirectly by
243+
* using [startAudioConversation].
237244
*/
238245
public fun stopReceiving() {
239246
if (!startedReceiving) {
@@ -355,7 +362,12 @@ internal constructor(
355362
send(Content.Builder().text(text).build())
356363
}
357364

358-
/** Closes the client session. */
365+
/**
366+
* Closes the client session.
367+
*
368+
* After this is called, the session object becomes unusable. To interact with the server again,
369+
* you must create a new session using [LiveGenerativeModel].
370+
*/
359371
public suspend fun close() {
360372
session?.close()
361373
}

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ResponseModality.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import kotlinx.serialization.KSerializer
2121
import kotlinx.serialization.SerialName
2222
import kotlinx.serialization.Serializable
2323

24-
/** Modality for bidirectional streaming. */
24+
/** Represents the type of content present in a response (e.g., text, image, audio). */
2525
@PublicPreviewAPI
2626
public class ResponseModality private constructor(public val ordinal: Int) {
2727

@@ -54,13 +54,13 @@ public class ResponseModality private constructor(public val ordinal: Int) {
5454
/** Unspecified modality. */
5555
@JvmField public val UNSPECIFIED: ResponseModality = ResponseModality(0)
5656

57-
/** Plain text. */
57+
/** Represents a plain text response modality. */
5858
@JvmField public val TEXT: ResponseModality = ResponseModality(1)
5959

60-
/** Image. */
60+
/** Represents an image response modality. */
6161
@JvmField public val IMAGE: ResponseModality = ResponseModality(2)
6262

63-
/** Audio. */
63+
/** Represents an audio response modality. */
6464
@JvmField public val AUDIO: ResponseModality = ResponseModality(4)
6565
}
6666
}

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/SpeechConfig.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ import kotlinx.serialization.Serializable
2121

2222
/** Speech configuration class for setting up the voice of the server's response. */
2323
@PublicPreviewAPI
24-
public class SpeechConfig(public val voice: Voices) {
24+
public class SpeechConfig(
25+
/** The voice to be used for the server's speech response. */
26+
public val voice: Voices
27+
) {
2528

2629
@Serializable
2730
internal data class Internal(@SerialName("voice_config") val voiceConfig: VoiceConfigInternal) {

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/Voices.kt

+10-1
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,26 @@ public class Voices private constructor(public val ordinal: Int) {
5353
}
5454

5555
public companion object {
56-
/** Unspecified modality. */
56+
/**
57+
* Unspecified voice.
58+
*
59+
* Will use the default voice of the model.
60+
*/
5761
@JvmField public val UNSPECIFIED: Voices = Voices(0)
5862

63+
/** Represents the Charon voice. */
5964
@JvmField public val CHARON: Voices = Voices(1)
6065

66+
/** Represents the Aoede voice. */
6167
@JvmField public val AOEDE: Voices = Voices(2)
6268

69+
/** Represents the Fenrir voice. */
6370
@JvmField public val FENRIR: Voices = Voices(3)
6471

72+
/** Represents the Kore voice. */
6573
@JvmField public val KORE: Voices = Voices(4)
6674

75+
/** Represents the Puck voice. */
6776
@JvmField public val PUCK: Voices = Voices(5)
6877
}
6978
}

0 commit comments

Comments
 (0)