Skip to content
Draft
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
12 changes: 12 additions & 0 deletions packages/firebase_ai/firebase_ai/lib/src/live_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,15 @@ class LiveServerToolCallCancellation implements LiveServerMessage {
final List<String>? functionIds;
}

/// A message indicating that the live server is going away.
class LiveServerGoAway implements LiveServerMessage {
/// Creates a [LiveServerGoAway] instance.
const LiveServerGoAway({this.timeLeft});

/// The time left in seconds for the live session to be terminated.
final String? timeLeft;
}

/// A single response chunk received during a live content generation.
///
/// It can contain generated content, function calls to be executed, or
Expand Down Expand Up @@ -435,6 +444,9 @@ LiveServerMessage _parseServerMessage(Object jsonObject) {
return LiveServerToolCallCancellation(functionIds: toolCancelJson['ids']);
} else if (json.containsKey('setupComplete')) {
return LiveServerSetupComplete();
} else if (json.containsKey('goAway')) {
final goAwayJson = json['goAway'] as Map;
return LiveServerGoAway(timeLeft: goAwayJson['timeLeft'] as String?);
} else {
throw unhandledFormat('LiveServerMessage', json);
}
Expand Down
Loading