Skip to content

Align LiveSeverMessage related protos #6910

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 8 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from 5 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
6 changes: 6 additions & 0 deletions firebase-ai/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,11 @@
* [fixed] Fixed an issue with `LiveContentResponse` audio data not being present when the model was
interrupted or the turn completed. (#6870)
* [fixed] Fixed an issue with `LiveSession` not converting exceptions to `FirebaseVertexAIException`. (#6870)
* * [changed] **Breaking Change**: Removed the `LiveContentResponse.Status` class, and instead have nested the status
fields as properties of `LiveContentResponse`. (#6906)
* [changed] **Breaking Change**: Removed the `LiveContentResponse` class, and instead have provided subclasses
of `LiveServerMessage` that match the responses from the model. (#6910)
* [feature] Added support for the `id` field on `FunctionResponsePart` and `FunctionCallPart`. (#6910)
* [feature] Add support for specifying response modalities in `GenerationConfig`. (#6921)
* [feature] Added a helper field for getting all the `InlineDataPart` from a `GenerateContentResponse`. (#6922)

65 changes: 39 additions & 26 deletions firebase-ai/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ package com.google.firebase.ai.java {
@com.google.firebase.ai.type.PublicPreviewAPI public abstract class LiveSessionFutures {
method public abstract com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> close();
method public static final com.google.firebase.ai.java.LiveSessionFutures from(com.google.firebase.ai.type.LiveSession session);
method public abstract org.reactivestreams.Publisher<com.google.firebase.ai.type.LiveContentResponse> receive();
method public abstract org.reactivestreams.Publisher<com.google.firebase.ai.type.LiveServerMessage> receive();
method public abstract com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> send(com.google.firebase.ai.type.Content content);
method public abstract com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> send(String text);
method public abstract com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> sendFunctionResponse(java.util.List<com.google.firebase.ai.type.FunctionResponsePart> functionList);
Expand Down Expand Up @@ -293,9 +293,12 @@ package com.google.firebase.ai.type {

public final class FunctionCallPart implements com.google.firebase.ai.type.Part {
ctor public FunctionCallPart(String name, java.util.Map<java.lang.String,? extends kotlinx.serialization.json.JsonElement> args);
ctor public FunctionCallPart(String name, java.util.Map<java.lang.String,? extends kotlinx.serialization.json.JsonElement> args, String? id = null);
method public java.util.Map<java.lang.String,kotlinx.serialization.json.JsonElement> getArgs();
method public String? getId();
method public String getName();
property public final java.util.Map<java.lang.String,kotlinx.serialization.json.JsonElement> args;
property public final String? id;
property public final String name;
}

Expand All @@ -320,8 +323,11 @@ package com.google.firebase.ai.type {

public final class FunctionResponsePart implements com.google.firebase.ai.type.Part {
ctor public FunctionResponsePart(String name, kotlinx.serialization.json.JsonObject response);
ctor public FunctionResponsePart(String name, kotlinx.serialization.json.JsonObject response, String? id = null);
method public String? getId();
method public String getName();
method public kotlinx.serialization.json.JsonObject getResponse();
property public final String? id;
property public final String name;
property public final kotlinx.serialization.json.JsonObject response;
}
Expand Down Expand Up @@ -579,30 +585,6 @@ package com.google.firebase.ai.type {
public final class InvalidStateException extends com.google.firebase.ai.type.FirebaseAIException {
}

@com.google.firebase.ai.type.PublicPreviewAPI public final class LiveContentResponse {
method public com.google.firebase.ai.type.Content? getData();
method public java.util.List<com.google.firebase.ai.type.FunctionCallPart>? getFunctionCalls();
method public int getStatus();
method public String? getText();
property public final com.google.firebase.ai.type.Content? data;
property public final java.util.List<com.google.firebase.ai.type.FunctionCallPart>? functionCalls;
property public final int status;
property public final String? text;
}

@kotlin.jvm.JvmInline public static final value class LiveContentResponse.Status {
field public static final com.google.firebase.ai.type.LiveContentResponse.Status.Companion Companion;
}

public static final class LiveContentResponse.Status.Companion {
method public int getINTERRUPTED();
method public int getNORMAL();
method public int getTURN_COMPLETE();
property public final int INTERRUPTED;
property public final int NORMAL;
property public final int TURN_COMPLETE;
}

@com.google.firebase.ai.type.PublicPreviewAPI public final class LiveGenerationConfig {
field public static final com.google.firebase.ai.type.LiveGenerationConfig.Companion Companion;
}
Expand Down Expand Up @@ -638,9 +620,40 @@ package com.google.firebase.ai.type {
method public static com.google.firebase.ai.type.LiveGenerationConfig liveGenerationConfig(kotlin.jvm.functions.Function1<? super com.google.firebase.ai.type.LiveGenerationConfig.Builder,kotlin.Unit> init);
}

@com.google.firebase.ai.type.PublicPreviewAPI public final class LiveServerContent implements com.google.firebase.ai.type.LiveServerMessage {
ctor public LiveServerContent(com.google.firebase.ai.type.Content? content, boolean interrupted, boolean turnComplete, boolean generationComplete);
method public com.google.firebase.ai.type.Content? getContent();
method public boolean getGenerationComplete();
method public boolean getInterrupted();
method public boolean getTurnComplete();
property public final com.google.firebase.ai.type.Content? content;
property public final boolean generationComplete;
property public final boolean interrupted;
property public final boolean turnComplete;
}

@com.google.firebase.ai.type.PublicPreviewAPI public interface LiveServerMessage {
}

@com.google.firebase.ai.type.PublicPreviewAPI public final class LiveServerSetupComplete implements com.google.firebase.ai.type.LiveServerMessage {
ctor public LiveServerSetupComplete();
}

@com.google.firebase.ai.type.PublicPreviewAPI public final class LiveServerToolCall implements com.google.firebase.ai.type.LiveServerMessage {
ctor public LiveServerToolCall(java.util.List<com.google.firebase.ai.type.FunctionCallPart> functionCalls);
method public java.util.List<com.google.firebase.ai.type.FunctionCallPart> getFunctionCalls();
property public final java.util.List<com.google.firebase.ai.type.FunctionCallPart> functionCalls;
}

@com.google.firebase.ai.type.PublicPreviewAPI public final class LiveServerToolCallCancellation implements com.google.firebase.ai.type.LiveServerMessage {
ctor public LiveServerToolCallCancellation(java.util.List<java.lang.String> functionIds);
method public java.util.List<java.lang.String> getFunctionIds();
property public final java.util.List<java.lang.String> functionIds;
}

@com.google.firebase.ai.type.PublicPreviewAPI public final class LiveSession {
method public suspend Object? close(kotlin.coroutines.Continuation<? super kotlin.Unit>);
method public kotlinx.coroutines.flow.Flow<com.google.firebase.ai.type.LiveContentResponse> receive();
method public kotlinx.coroutines.flow.Flow<com.google.firebase.ai.type.LiveServerMessage> receive();
method public suspend Object? send(com.google.firebase.ai.type.Content content, kotlin.coroutines.Continuation<? super kotlin.Unit>);
method public suspend Object? send(String text, kotlin.coroutines.Continuation<? super kotlin.Unit>);
method public suspend Object? sendFunctionResponse(java.util.List<com.google.firebase.ai.type.FunctionResponsePart> functionList, kotlin.coroutines.Continuation<? super kotlin.Unit>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import com.google.common.util.concurrent.ListenableFuture
import com.google.firebase.ai.type.Content
import com.google.firebase.ai.type.FunctionCallPart
import com.google.firebase.ai.type.FunctionResponsePart
import com.google.firebase.ai.type.LiveContentResponse
import com.google.firebase.ai.type.LiveServerMessage
import com.google.firebase.ai.type.LiveSession
import com.google.firebase.ai.type.MediaData
import com.google.firebase.ai.type.PublicPreviewAPI
Expand Down Expand Up @@ -135,16 +135,16 @@ public abstract class LiveSessionFutures internal constructor() {
*
* Call [close] to stop receiving responses from the model.
*
* @return A [Publisher] which will emit [LiveContentResponse] from the model.
* @return A [Publisher] which will emit [LiveServerMessage] from the model.
*
* @throws [SessionAlreadyReceivingException] when the session is already receiving.
* @see stopReceiving
*/
public abstract fun receive(): Publisher<LiveContentResponse>
public abstract fun receive(): Publisher<LiveServerMessage>

private class FuturesImpl(private val session: LiveSession) : LiveSessionFutures() {

override fun receive(): Publisher<LiveContentResponse> = session.receive().asPublisher()
override fun receive(): Publisher<LiveServerMessage> = session.receive().asPublisher()

override fun close(): ListenableFuture<Unit> =
SuspendToFutureAdapter.launchFuture { session.close() }
Expand Down

This file was deleted.

Loading