@@ -21,10 +21,12 @@ import com.google.common.util.concurrent.ListenableFuture
2121import  com.google.firebase.vertexai.GenerativeModel 
2222import  com.google.firebase.vertexai.type.Content 
2323import  com.google.firebase.vertexai.type.ContentModality 
24+ import  com.google.firebase.vertexai.type.FunctionCallPart 
2425import  com.google.firebase.vertexai.type.FunctionResponsePart 
2526import  com.google.firebase.vertexai.type.LiveContentResponse 
2627import  com.google.firebase.vertexai.type.LiveSession 
2728import  com.google.firebase.vertexai.type.MediaData 
29+ import  com.google.firebase.vertexai.type.SessionAlreadyReceivingException 
2830import  kotlinx.coroutines.reactive.asPublisher 
2931import  org.reactivestreams.Publisher 
3032
@@ -34,35 +36,84 @@ import org.reactivestreams.Publisher
3436 * @see [GenerativeModel] 
3537 */  
3638public  abstract  class  LiveSessionFutures  internal constructor() {
39+ 
40+   /* *
41+    * Starts an audio conversation with the Gemini server, which can only be stopped using 
42+    * stopAudioConversation. 
43+    */  
3744  public  abstract  fun  startAudioConversation (): ListenableFuture <Unit >
3845
46+   /* * Stops the audio conversation with the Gemini Server. */ 
3947  public  abstract  fun  stopAudioConversation (): ListenableFuture <Unit >
4048
49+   /* * Stop receiving from the server. */ 
4150  public  abstract  fun  stopReceiving ()
4251
52+   /* *
53+    * Sends the function response from the client to the server. 
54+    * 
55+    * @param functionList The list of [FunctionResponsePart] instances indicating the function 
56+    * response from the client. 
57+    */  
4358  public  abstract  fun  sendFunctionResponse (
4459    functionList :  List <FunctionResponsePart >
4560  ): ListenableFuture <Unit >
4661
62+   /* *
63+    * Streams client data to the server. 
64+    * 
65+    * @param mediaChunks The list of [MediaData] instances representing the media data to be sent. 
66+    */  
4767  public  abstract  fun  sendMediaStream (mediaChunks :  List <MediaData >): ListenableFuture <Unit >
4868
69+   /* *
70+    * Sends data to the server 
71+    * 
72+    * @param content Client [Content] to be sent to the server. 
73+    */  
4974  public  abstract  fun  send (content :  Content ): ListenableFuture <Unit >
5075
76+   /* *
77+    * Sends text to the server 
78+    * 
79+    * @param text Text to be sent to the server. 
80+    */  
5181  public  abstract  fun  send (text :  String ): ListenableFuture <Unit >
5282
83+   /* * Closes the client session. */ 
5384  public  abstract  fun  close (): ListenableFuture <Unit >
5485
86+   /* *
87+    * Receives responses from the server for both streaming and standard requests. 
88+    * 
89+    * @param outputModalities The list of output formats to receive from the server. 
90+    * 
91+    * @return A [Publisher] which will emit [LiveContentResponse] as and when it receives it 
92+    * 
93+    * @throws [SessionAlreadyReceivingException] when the session is already receiving. 
94+    */  
5595  public  abstract  fun  receive (
5696    outputModalities :  List <ContentModality >
5797  ): ListenableFuture <Publisher <LiveContentResponse >>
5898
99+   /* *
100+    * Receives all function call responses from the server for the audio conversation feature.. 
101+    * 
102+    * @return A [Publisher] which will emit list of [FunctionCallPart] as they are returned by the 
103+    * model. 
104+    */  
105+   public  abstract  fun  receiveAudioConversationFunctionCalls (): Publisher <List <FunctionCallPart >>
106+ 
59107  private  class  FuturesImpl (private  val  session :  LiveSession ) : LiveSessionFutures() {
60108
61109    override  fun  receive (
62110      outputModalities :  List <ContentModality >
63111    ): ListenableFuture <Publisher <LiveContentResponse >> = 
64112      SuspendToFutureAdapter .launchFuture { session.receive(outputModalities).asPublisher() }
65113
114+     override  fun  receiveAudioConversationFunctionCalls (): Publisher <List <FunctionCallPart >> = 
115+       session.receiveAudioConversationFunctionCalls().asPublisher()
116+ 
66117    override  fun  close (): ListenableFuture <Unit > = 
67118      SuspendToFutureAdapter .launchFuture { session.close() }
68119
0 commit comments