|
48 | 48 | @RunWith(JUnit4.class) |
49 | 49 | public final class StreamingToolTest { |
50 | 50 |
|
| 51 | + private static final RunConfig BIDI_STREAMING_RUN_CONFIG = |
| 52 | + RunConfig.builder().setStreamingMode(StreamingMode.BIDI).build(); |
| 53 | + |
51 | 54 | public static final class StreamingTools { |
52 | 55 | public static Flowable<ImmutableMap<String, Object>> monitorStockPrice( |
53 | 56 | @Schema(name = "stockSymbol") String stockSymbol) { |
@@ -130,10 +133,7 @@ public void runLive_asyncFunctionCall_succeeds() throws Exception { |
130 | 133 |
|
131 | 134 | Session session = runner.sessionService().createSession("test-app", "test-user").blockingGet(); |
132 | 135 | List<Event> resEvents = |
133 | | - runner |
134 | | - .runLive(session, liveRequestQueue, RunConfig.builder().build()) |
135 | | - .toList() |
136 | | - .blockingGet(); |
| 136 | + runner.runLive(session, liveRequestQueue, BIDI_STREAMING_RUN_CONFIG).toList().blockingGet(); |
137 | 137 |
|
138 | 138 | assertThat(resEvents).isNotNull(); |
139 | 139 | assertThat(resEvents).isNotEmpty(); |
@@ -215,10 +215,7 @@ public void runLive_functionCall_returnsErrors() throws Exception { |
215 | 215 |
|
216 | 216 | Session session = runner.sessionService().createSession("test-app", "test-user").blockingGet(); |
217 | 217 | List<Event> resEvents = |
218 | | - runner |
219 | | - .runLive(session, liveRequestQueue, RunConfig.builder().build()) |
220 | | - .toList() |
221 | | - .blockingGet(); |
| 218 | + runner.runLive(session, liveRequestQueue, BIDI_STREAMING_RUN_CONFIG).toList().blockingGet(); |
222 | 219 |
|
223 | 220 | assertThat(resEvents).isNotNull(); |
224 | 221 | assertThat(resEvents).isNotEmpty(); |
@@ -301,13 +298,7 @@ public void runLive_videoStreamingTool_receivesVideoFramesAndSendsResultsToLlm() |
301 | 298 |
|
302 | 299 | // Run the agent and collect events. |
303 | 300 | List<Event> resEvents = |
304 | | - runner |
305 | | - .runLive( |
306 | | - session, |
307 | | - liveRequestQueue, |
308 | | - RunConfig.builder().setStreamingMode(StreamingMode.BIDI).build()) |
309 | | - .toList() |
310 | | - .blockingGet(); |
| 301 | + runner.runLive(session, liveRequestQueue, BIDI_STREAMING_RUN_CONFIG).toList().blockingGet(); |
311 | 302 |
|
312 | 303 | // Wait for the tool to send its 3 results back to the LLM |
313 | 304 | assertThat(testLlm.waitForStreamingToolResults("monitorVideoStream", 3, Duration.ofSeconds(20))) |
@@ -409,10 +400,7 @@ public void runLive_stopStreamingTool() throws Exception { |
409 | 400 |
|
410 | 401 | Session session = runner.sessionService().createSession("test-app", "test-user").blockingGet(); |
411 | 402 | List<Event> resEvents = |
412 | | - runner |
413 | | - .runLive(session, liveRequestQueue, RunConfig.builder().build()) |
414 | | - .toList() |
415 | | - .blockingGet(); |
| 403 | + runner.runLive(session, liveRequestQueue, BIDI_STREAMING_RUN_CONFIG).toList().blockingGet(); |
416 | 404 |
|
417 | 405 | assertThat(resEvents).isNotNull(); |
418 | 406 | assertThat(resEvents.size()).isAtLeast(1); |
@@ -502,13 +490,7 @@ public void runLive_streamingTool_responsesAreSentAsUserContentToLlm() throws Ex |
502 | 490 | Session session = runner.sessionService().createSession("test-app", "test-user").blockingGet(); |
503 | 491 |
|
504 | 492 | List<Event> resEvents = |
505 | | - runner |
506 | | - .runLive( |
507 | | - session, |
508 | | - liveRequestQueue, |
509 | | - RunConfig.builder().setStreamingMode(StreamingMode.BIDI).build()) |
510 | | - .toList() |
511 | | - .blockingGet(); |
| 493 | + runner.runLive(session, liveRequestQueue, BIDI_STREAMING_RUN_CONFIG).toList().blockingGet(); |
512 | 494 |
|
513 | 495 | assertThat(resEvents).isNotNull(); |
514 | 496 | assertThat(resEvents).isNotEmpty(); |
|
0 commit comments