-
Notifications
You must be signed in to change notification settings - Fork 932
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
Support asynchronous/reactive function calling #1778
Comments
Hey, as @tzolov mentioned, reactive/asynchronous signatures for functions are currently not supported, but it looks like a desired functionality having in mind streaming scenarios. I suggest closing the discussion #1757 and keeping this issue and related discussions here. As you noticed: ArrayList<Object> res = new ArrayList<>();
// ...
.subscribe(res::add);
return new Response(res); this construct immediately returns an object which is incomplete and another As a solution for the time being you don't need to introduce List<Map<String, Object>> data = CompletableFuture.supplyAsync(
() -> this.dataQueryRepository.query()
// ...
.collectList()
.block())
.join(); Instead, this.dataQueryRepository.query()
// ...
.collectList()
.block()) should get you the same result. For the Spring AI's internal implementation, it's worth keeping in mind that in case when an imperative user function is executed in an event loop, it's worth offloading the blocking call into a bounded-elastic return Mono.fromCallable(() -> userBlockingFunction())
.subscribeOn(Schedulers.boundedElastic()); regardless of whether the function is using reactive APIs or not, since just performing blocking calls in imperative code will degrade the performance and stall the event loop. |
Ok, thank you for your reply @chemicL . I hope you can remind me under this issues if there is any progress in asynchronous/reactive function calling. |
Please do a quick search on GitHub issues first, the feature you are about to request might have already been requested.
Expected Behavior
The current FunctionCallback only supports blocking programming. If the bottom layer of the provided function callback method uses the streaming programming of reactor, it can only be blocked by block or asynchronous thread pool.
Current Behavior
I hope to provide a FunctionCallback that can be called by reactor streaming programming. For example, bi function < request, tool context, Mono >
Context
This is more friendly for applications built entirely by webflux, and using blocking FunctionCallback in webflux will bring many difficult problems.
The text was updated successfully, but these errors were encountered: