Skip to content

Commit 2b23887

Browse files
authored
Align LiveSeverMessage related protos (#6910)
Per [b/410856389](https://b.corp.google.com/issues/410856389), This removes the `LiveContentResponse` and provides a `LiveServerMessage` in its place that aligns with the proto, and the other SDKs. Documentation is included for everything added. Additionally, this PR fixes the following: - [b/410040441](https://b.corp.google.com/issues/410040441) -> Add support for id field on functions - [b/413437559](https://b.corp.google.com/issues/413437559) -> Add support for generationComplete - [b/414602833](https://b.corp.google.com/issues/414602833) -> Fix firebase ai changelog
1 parent 7b7e11e commit 2b23887

File tree

7 files changed

+322
-242
lines changed

7 files changed

+322
-242
lines changed

firebase-ai/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,11 @@
1313
* [fixed] Fixed an issue with `LiveContentResponse` audio data not being present when the model was
1414
interrupted or the turn completed. (#6870)
1515
* [fixed] Fixed an issue with `LiveSession` not converting exceptions to `FirebaseVertexAIException`. (#6870)
16+
* * [changed] **Breaking Change**: Removed the `LiveContentResponse.Status` class, and instead have nested the status
17+
fields as properties of `LiveContentResponse`. (#6906)
18+
* [changed] **Breaking Change**: Removed the `LiveContentResponse` class, and instead have provided subclasses
19+
of `LiveServerMessage` that match the responses from the model. (#6910)
20+
* [feature] Added support for the `id` field on `FunctionResponsePart` and `FunctionCallPart`. (#6910)
1621
* [feature] Add support for specifying response modalities in `GenerationConfig`. (#6921)
1722
* [feature] Added a helper field for getting all the `InlineDataPart` from a `GenerateContentResponse`. (#6922)
23+

firebase-ai/api.txt

+39-26
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ package com.google.firebase.ai.java {
127127
@com.google.firebase.ai.type.PublicPreviewAPI public abstract class LiveSessionFutures {
128128
method public abstract com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> close();
129129
method public static final com.google.firebase.ai.java.LiveSessionFutures from(com.google.firebase.ai.type.LiveSession session);
130-
method public abstract org.reactivestreams.Publisher<com.google.firebase.ai.type.LiveContentResponse> receive();
130+
method public abstract org.reactivestreams.Publisher<com.google.firebase.ai.type.LiveServerMessage> receive();
131131
method public abstract com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> send(com.google.firebase.ai.type.Content content);
132132
method public abstract com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> send(String text);
133133
method public abstract com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> sendFunctionResponse(java.util.List<com.google.firebase.ai.type.FunctionResponsePart> functionList);
@@ -293,9 +293,12 @@ package com.google.firebase.ai.type {
293293

294294
public final class FunctionCallPart implements com.google.firebase.ai.type.Part {
295295
ctor public FunctionCallPart(String name, java.util.Map<java.lang.String,? extends kotlinx.serialization.json.JsonElement> args);
296+
ctor public FunctionCallPart(String name, java.util.Map<java.lang.String,? extends kotlinx.serialization.json.JsonElement> args, String? id = null);
296297
method public java.util.Map<java.lang.String,kotlinx.serialization.json.JsonElement> getArgs();
298+
method public String? getId();
297299
method public String getName();
298300
property public final java.util.Map<java.lang.String,kotlinx.serialization.json.JsonElement> args;
301+
property public final String? id;
299302
property public final String name;
300303
}
301304

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

321324
public final class FunctionResponsePart implements com.google.firebase.ai.type.Part {
322325
ctor public FunctionResponsePart(String name, kotlinx.serialization.json.JsonObject response);
326+
ctor public FunctionResponsePart(String name, kotlinx.serialization.json.JsonObject response, String? id = null);
327+
method public String? getId();
323328
method public String getName();
324329
method public kotlinx.serialization.json.JsonObject getResponse();
330+
property public final String? id;
325331
property public final String name;
326332
property public final kotlinx.serialization.json.JsonObject response;
327333
}
@@ -579,30 +585,6 @@ package com.google.firebase.ai.type {
579585
public final class InvalidStateException extends com.google.firebase.ai.type.FirebaseAIException {
580586
}
581587

582-
@com.google.firebase.ai.type.PublicPreviewAPI public final class LiveContentResponse {
583-
method public com.google.firebase.ai.type.Content? getData();
584-
method public java.util.List<com.google.firebase.ai.type.FunctionCallPart>? getFunctionCalls();
585-
method public int getStatus();
586-
method public String? getText();
587-
property public final com.google.firebase.ai.type.Content? data;
588-
property public final java.util.List<com.google.firebase.ai.type.FunctionCallPart>? functionCalls;
589-
property public final int status;
590-
property public final String? text;
591-
}
592-
593-
@kotlin.jvm.JvmInline public static final value class LiveContentResponse.Status {
594-
field public static final com.google.firebase.ai.type.LiveContentResponse.Status.Companion Companion;
595-
}
596-
597-
public static final class LiveContentResponse.Status.Companion {
598-
method public int getINTERRUPTED();
599-
method public int getNORMAL();
600-
method public int getTURN_COMPLETE();
601-
property public final int INTERRUPTED;
602-
property public final int NORMAL;
603-
property public final int TURN_COMPLETE;
604-
}
605-
606588
@com.google.firebase.ai.type.PublicPreviewAPI public final class LiveGenerationConfig {
607589
field public static final com.google.firebase.ai.type.LiveGenerationConfig.Companion Companion;
608590
}
@@ -638,9 +620,40 @@ package com.google.firebase.ai.type {
638620
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);
639621
}
640622

623+
@com.google.firebase.ai.type.PublicPreviewAPI public final class LiveServerContent implements com.google.firebase.ai.type.LiveServerMessage {
624+
ctor public LiveServerContent(com.google.firebase.ai.type.Content? content, boolean interrupted, boolean turnComplete, boolean generationComplete);
625+
method public com.google.firebase.ai.type.Content? getContent();
626+
method public boolean getGenerationComplete();
627+
method public boolean getInterrupted();
628+
method public boolean getTurnComplete();
629+
property public final com.google.firebase.ai.type.Content? content;
630+
property public final boolean generationComplete;
631+
property public final boolean interrupted;
632+
property public final boolean turnComplete;
633+
}
634+
635+
@com.google.firebase.ai.type.PublicPreviewAPI public interface LiveServerMessage {
636+
}
637+
638+
@com.google.firebase.ai.type.PublicPreviewAPI public final class LiveServerSetupComplete implements com.google.firebase.ai.type.LiveServerMessage {
639+
ctor public LiveServerSetupComplete();
640+
}
641+
642+
@com.google.firebase.ai.type.PublicPreviewAPI public final class LiveServerToolCall implements com.google.firebase.ai.type.LiveServerMessage {
643+
ctor public LiveServerToolCall(java.util.List<com.google.firebase.ai.type.FunctionCallPart> functionCalls);
644+
method public java.util.List<com.google.firebase.ai.type.FunctionCallPart> getFunctionCalls();
645+
property public final java.util.List<com.google.firebase.ai.type.FunctionCallPart> functionCalls;
646+
}
647+
648+
@com.google.firebase.ai.type.PublicPreviewAPI public final class LiveServerToolCallCancellation implements com.google.firebase.ai.type.LiveServerMessage {
649+
ctor public LiveServerToolCallCancellation(java.util.List<java.lang.String> functionIds);
650+
method public java.util.List<java.lang.String> getFunctionIds();
651+
property public final java.util.List<java.lang.String> functionIds;
652+
}
653+
641654
@com.google.firebase.ai.type.PublicPreviewAPI public final class LiveSession {
642655
method public suspend Object? close(kotlin.coroutines.Continuation<? super kotlin.Unit>);
643-
method public kotlinx.coroutines.flow.Flow<com.google.firebase.ai.type.LiveContentResponse> receive();
656+
method public kotlinx.coroutines.flow.Flow<com.google.firebase.ai.type.LiveServerMessage> receive();
644657
method public suspend Object? send(com.google.firebase.ai.type.Content content, kotlin.coroutines.Continuation<? super kotlin.Unit>);
645658
method public suspend Object? send(String text, kotlin.coroutines.Continuation<? super kotlin.Unit>);
646659
method public suspend Object? sendFunctionResponse(java.util.List<com.google.firebase.ai.type.FunctionResponsePart> functionList, kotlin.coroutines.Continuation<? super kotlin.Unit>);

firebase-ai/src/main/kotlin/com/google/firebase/ai/java/LiveSessionFutures.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import com.google.common.util.concurrent.ListenableFuture
2323
import com.google.firebase.ai.type.Content
2424
import com.google.firebase.ai.type.FunctionCallPart
2525
import com.google.firebase.ai.type.FunctionResponsePart
26-
import com.google.firebase.ai.type.LiveContentResponse
26+
import com.google.firebase.ai.type.LiveServerMessage
2727
import com.google.firebase.ai.type.LiveSession
2828
import com.google.firebase.ai.type.MediaData
2929
import com.google.firebase.ai.type.PublicPreviewAPI
@@ -135,16 +135,16 @@ public abstract class LiveSessionFutures internal constructor() {
135135
*
136136
* Call [close] to stop receiving responses from the model.
137137
*
138-
* @return A [Publisher] which will emit [LiveContentResponse] from the model.
138+
* @return A [Publisher] which will emit [LiveServerMessage] from the model.
139139
*
140140
* @throws [SessionAlreadyReceivingException] when the session is already receiving.
141141
* @see stopReceiving
142142
*/
143-
public abstract fun receive(): Publisher<LiveContentResponse>
143+
public abstract fun receive(): Publisher<LiveServerMessage>
144144

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

147-
override fun receive(): Publisher<LiveContentResponse> = session.receive().asPublisher()
147+
override fun receive(): Publisher<LiveServerMessage> = session.receive().asPublisher()
148148

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

firebase-ai/src/main/kotlin/com/google/firebase/ai/type/LiveContentResponse.kt

-74
This file was deleted.

0 commit comments

Comments
 (0)