Skip to content

Commit 5518099

Browse files
committed
Update JavaCompileTests.java
1 parent 7151fd0 commit 5518099

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

firebase-vertexai/src/testUtil/java/com/google/firebase/vertexai/JavaCompileTests.java

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@
4444
import com.google.firebase.vertexai.type.HarmSeverity;
4545
import com.google.firebase.vertexai.type.ImagePart;
4646
import com.google.firebase.vertexai.type.InlineDataPart;
47-
import com.google.firebase.vertexai.type.LiveContentResponse;
4847
import com.google.firebase.vertexai.type.LiveGenerationConfig;
48+
import com.google.firebase.vertexai.type.LiveServerContent;
49+
import com.google.firebase.vertexai.type.LiveServerMessage;
50+
import com.google.firebase.vertexai.type.LiveServerSetupComplete;
51+
import com.google.firebase.vertexai.type.LiveServerToolCall;
52+
import com.google.firebase.vertexai.type.LiveServerToolCallCancellation;
4953
import com.google.firebase.vertexai.type.MediaData;
5054
import com.google.firebase.vertexai.type.ModalityTokenCount;
5155
import com.google.firebase.vertexai.type.Part;
@@ -276,14 +280,14 @@ private void testLiveFutures(LiveModelFutures futures) throws Exception {
276280
session
277281
.receive()
278282
.subscribe(
279-
new Subscriber<LiveContentResponse>() {
283+
new Subscriber<LiveServerMessage>() {
280284
@Override
281285
public void onSubscribe(Subscription s) {
282286
s.request(Long.MAX_VALUE);
283287
}
284288

285289
@Override
286-
public void onNext(LiveContentResponse response) {
290+
public void onNext(LiveServerMessage response) {
287291
validateLiveContentResponse(response);
288292
}
289293

@@ -315,17 +319,22 @@ public void onComplete() {
315319
session.close();
316320
}
317321

318-
private void validateLiveContentResponse(LiveContentResponse response) {
319-
// int status = response.getStatus();
320-
// Assert.assertEquals(status, LiveContentResponse.Status.Companion.getNORMAL());
321-
// Assert.assertNotEquals(status, LiveContentResponse.Status.Companion.getINTERRUPTED());
322-
// Assert.assertNotEquals(status, LiveContentResponse.Status.Companion.getTURN_COMPLETE());
323-
// TODO b/412743328 LiveContentResponse.Status inaccessible for Java users
324-
Content data = response.getData();
325-
if (data != null) {
326-
validateContent(data);
322+
private void validateLiveContentResponse(LiveServerMessage message) {
323+
if (message instanceof LiveServerContent) {
324+
LiveServerContent content = (LiveServerContent) message;
325+
validateContent(content.getContent());
326+
boolean complete = content.getGenerationComplete();
327+
boolean interrupted = content.getInterrupted();
328+
boolean turnComplete = content.getTurnComplete();
329+
} else if (message instanceof LiveServerSetupComplete) {
330+
LiveServerSetupComplete setup = (LiveServerSetupComplete) message;
331+
// No methods
332+
} else if (message instanceof LiveServerToolCall) {
333+
LiveServerToolCall call = (LiveServerToolCall) message;
334+
validateFunctionCalls(call.getFunctionCalls());
335+
} else if (message instanceof LiveServerToolCallCancellation) {
336+
LiveServerToolCallCancellation cancel = (LiveServerToolCallCancellation) message;
337+
List<String> functions = cancel.getFunctionIds();
327338
}
328-
String text = response.getText();
329-
validateFunctionCalls(response.getFunctionCalls());
330339
}
331340
}

0 commit comments

Comments
 (0)