Skip to content

[VertexAI] Remove option from LiveSession Receive #1240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2025
Merged
Changes from all 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
7 changes: 3 additions & 4 deletions vertexai/src/LiveSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,11 @@ public Task SendAudioAsync(float[] audioData, CancellationToken cancellationToke

/// <summary>
/// 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.
/// </summary>
/// <param name="closeOnTurnComplete">Should the stream stop when the server returns TurnComplete.</param>
/// <param name="cancellationToken">A token to cancel the operation.</param>
/// <returns>A stream of `LiveContentResponse`s from the backend.</returns>
public async IAsyncEnumerable<LiveSessionResponse> ReceiveAsync(
bool closeOnTurnComplete = true,
[EnumeratorCancellation] CancellationToken cancellationToken = default) {
if (_clientWebSocket.State != WebSocketState.Open) {
throw new InvalidOperationException("WebSocket is not open. Cannot start receiving.");
Expand Down Expand Up @@ -206,8 +205,8 @@ public async IAsyncEnumerable<LiveSessionResponse> ReceiveAsync(
if (response != null) {
yield return response.Value;

if (closeOnTurnComplete &&
response?.Message is LiveSessionContent serverContent &&
// On receiving TurnComplete we close the ongoing connection.
if (response?.Message is LiveSessionContent serverContent &&
serverContent.TurnComplete) {
break;
}
Expand Down