Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public abstract class LiveModelFutures internal constructor() {
* @throws [ServiceConnectionHandshakeFailedException] If the client was not able to establish a
* connection with the server.
*/
public abstract fun connect(): ListenableFuture<LiveSession>
public abstract fun connect(): ListenableFuture<LiveSessionFutures>

private class FuturesImpl(private val model: LiveGenerativeModel) : LiveModelFutures() {
override fun connect(): ListenableFuture<LiveSession> {
return SuspendToFutureAdapter.launchFuture { model.connect() }
override fun connect(): ListenableFuture<LiveSessionFutures> {
return SuspendToFutureAdapter.launchFuture { LiveSessionFutures.from(model.connect()) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ public abstract class LiveSessionFutures internal constructor() {
functionCallHandler: ((FunctionCallPart) -> FunctionResponsePart)?
): ListenableFuture<Unit>

/**
* Starts an audio conversation with the Gemini server, which can only be stopped using
* [stopAudioConversation].
*
* @param functionCallHandler A callback function to map function calls from the server to their
* response parts.
*/
public abstract fun startAudioConversation(): ListenableFuture<Unit>

/**
* Stops the audio conversation with the Gemini Server.
*
Expand Down Expand Up @@ -124,6 +133,9 @@ public abstract class LiveSessionFutures internal constructor() {
functionCallHandler: ((FunctionCallPart) -> FunctionResponsePart)?
) = SuspendToFutureAdapter.launchFuture { session.startAudioConversation(functionCallHandler) }

override fun startAudioConversation() =
SuspendToFutureAdapter.launchFuture { session.startAudioConversation() }

override fun stopAudioConversation() =
SuspendToFutureAdapter.launchFuture { session.stopAudioConversation() }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ private constructor(
public fun setFrequencyPenalty(frequencyPenalty: Float?): Builder = apply {
this.frequencyPenalty = frequencyPenalty
}
public fun setResponseModalities(responseModalities: ResponseModality?): Builder = apply {
this.responseModality = responseModalities
public fun setResponseModality(responseModality: ResponseModality?): Builder = apply {
this.responseModality = responseModality
}
public fun setSpeechConfig(speechConfig: SpeechConfig?): Builder = apply {
this.speechConfig = speechConfig
Expand Down
Loading