Skip to content
Next Next commit
Add a new response api
  • Loading branch information
cynthiajoan committed Apr 3, 2025
commit 34ea7b6090fa40196b865a867f85a09f2a35863d
43 changes: 43 additions & 0 deletions packages/firebase_vertexai/firebase_vertexai/lib/src/live_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,49 @@ class LiveServerToolCallCancellation implements LiveServerMessage {
final List<String>? functionIds;
}

/// The status of a live generation response.
enum LiveResponseStatus {
/// The live generation is proceeding normally, and more content might be streamed.
normal,

/// A client message has interrupted current model generation. If the client
/// is playing out the content in realtime, this is a good signal to stop and
/// empty the current queue.
interrupted,

/// The model is done generating. Generation will only start in response to
/// additional client messages.
turnComplete,
}

/// A single response chunk received during a live content generation.
///
/// It can contain generated content, function calls to be executed, or
/// instructions to cancel previous function calls, along with the status of the
/// ongoing generation.
class LiveContentResponse {
// ignore: public_member_api_docs
LiveContentResponse(
{this.modelTurn,
this.responseStatus = LiveResponseStatus.normal,
this.functionCalls,
this.functionIdsToCancel});

/// The content generated by the live model.
final Content? modelTurn;

/// The status of the live generation at the point this response was received.
/// Indicates whether the generation is ongoing, interrupted, or complete for
/// the current turn. Defaults to [LiveResponseStatus.normal].
final LiveResponseStatus responseStatus;

/// The list of function calls to be executed.
final List<FunctionCall>? functionCalls;

/// The list of [FunctionCall.id] to cancel.
final List<String>? functionIdsToCancel;
}

/// Represents realtime input from the client in a live stream.
class LiveClientRealtimeInput {
/// Creates a [LiveClientRealtimeInput] instance.
Expand Down