Firebase. AI. LiveSession
Manages asynchronous communication with Gemini model over a WebSocket connection.
Summary
Inheritance
Inherits from: IDisposable Protected functions | |
---|---|
Dispose(bool disposing) | virtual void |
Public functions | |
---|---|
CloseAsync(CancellationToken cancellationToken) | Task Close the LiveSession . |
Dispose() | void |
ReceiveAsync(CancellationToken cancellationToken) | async IAsyncEnumerable< LiveSessionResponse > Receives a stream of responses from the server. |
SendAsync(ModelContent? content, bool turnComplete, CancellationToken cancellationToken) | async Task Sends a single piece of content to the server. |
SendAudioAsync(float[] audioData, CancellationToken cancellationToken) | Task Convenience function for sending audio data in a float[] to the server. |
SendMediaChunksAsync(List< ModelContent.InlineDataPart > mediaChunks, CancellationToken cancellationToken) | async Task Send realtime input to the server. |
Protected functions
Dispose
virtual void Dispose( bool disposing )
Public functions
CloseAsync
Task CloseAsync( CancellationToken cancellationToken )
Close the LiveSession
.
Details | |||
---|---|---|---|
Parameters |
|
Dispose
void Dispose()
ReceiveAsync
async IAsyncEnumerable< LiveSessionResponse > ReceiveAsync( CancellationToken cancellationToken )
Receives a stream of responses from the server.
Having multiple of these ongoing will result in unexpected behavior. Closes upon receiving a TurnComplete from the server.
Details | |||
---|---|---|---|
Parameters |
| ||
Returns | A stream of LiveContentResponse s from the backend. |
SendAsync
async Task SendAsync( ModelContent? content, bool turnComplete, CancellationToken cancellationToken )
Sends a single piece of content to the server.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
SendAudioAsync
Task SendAudioAsync( float[] audioData, CancellationToken cancellationToken )
Convenience function for sending audio data in a float[] to the server.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
SendMediaChunksAsync
async Task SendMediaChunksAsync( List< ModelContent.InlineDataPart > mediaChunks, CancellationToken cancellationToken )
Send realtime input to the server.
Details | |||||
---|---|---|---|---|---|
Parameters |
|