|
47 | 47 | import io.reactivex.rxjava3.core.Maybe; |
48 | 48 | import io.reactivex.rxjava3.core.Single; |
49 | 49 | import io.reactivex.rxjava3.disposables.Disposable; |
50 | | -import io.reactivex.rxjava3.functions.Function; |
51 | 50 | import java.util.ArrayList; |
52 | 51 | import java.util.Collections; |
53 | 52 | import java.util.HashMap; |
|
57 | 56 | import java.util.Optional; |
58 | 57 | import java.util.Set; |
59 | 58 | import java.util.UUID; |
| 59 | +import java.util.function.Function; |
60 | 60 | import org.slf4j.Logger; |
61 | 61 | import org.slf4j.LoggerFactory; |
62 | 62 |
|
@@ -202,10 +202,12 @@ public static Maybe<Event> handleFunctionCalls( |
202 | 202 | Flowable<Event> functionResponseEventsFlowable; |
203 | 203 | if (invocationContext.runConfig().toolExecutionMode() == ToolExecutionMode.SEQUENTIAL) { |
204 | 204 | functionResponseEventsFlowable = |
205 | | - Flowable.fromIterable(functionCalls).concatMapMaybe(functionCallMapper); |
| 205 | + Flowable.fromIterable(functionCalls) |
| 206 | + .concatMapMaybe(call -> functionCallMapper.apply(call)); |
206 | 207 | } else { |
207 | 208 | functionResponseEventsFlowable = |
208 | | - Flowable.fromIterable(functionCalls).flatMapMaybe(functionCallMapper); |
| 209 | + Flowable.fromIterable(functionCalls) |
| 210 | + .concatMapEager(call -> functionCallMapper.apply(call).toFlowable()); |
209 | 211 | } |
210 | 212 | return functionResponseEventsFlowable |
211 | 213 | .toList() |
@@ -314,11 +316,12 @@ public static Maybe<Event> handleFunctionCallsLive( |
314 | 316 |
|
315 | 317 | if (invocationContext.runConfig().toolExecutionMode() == ToolExecutionMode.SEQUENTIAL) { |
316 | 318 | responseEventsFlowable = |
317 | | - Flowable.fromIterable(functionCalls).concatMapMaybe(functionCallMapper); |
318 | | - |
| 319 | + Flowable.fromIterable(functionCalls) |
| 320 | + .concatMapMaybe(call -> functionCallMapper.apply(call)); |
319 | 321 | } else { |
320 | 322 | responseEventsFlowable = |
321 | | - Flowable.fromIterable(functionCalls).flatMapMaybe(functionCallMapper); |
| 323 | + Flowable.fromIterable(functionCalls) |
| 324 | + .concatMapEager(call -> functionCallMapper.apply(call).toFlowable()); |
322 | 325 | } |
323 | 326 |
|
324 | 327 | return responseEventsFlowable |
|
0 commit comments