spring-ai icon indicating copy to clipboard operation
spring-ai copied to clipboard

Support async call by return `Mono<ChatResponse>`

Open XhstormR opened this issue 1 year ago • 4 comments
trafficstars

Please do a quick search on GitHub issues first, the feature you are about to request might have already been requested.

Expected Behavior

The call method of ChatClient supports returning Mono objects to achieve asynchronous calls.

For example:

public interface AsyncChatClient extends ModelClient<Prompt, ChatResponse> {
    @Override
    Mono<ChatResponse> call(Prompt prompt);
}

Current Behavior

Currently, the call method of AzureOpenAiChatClient does not support asynchronous calls. Only the stream method can return a Flux async object, but Flux represents multiple results. I need Mono object which it represent a single result.

Context

I used com.azure:azure-ai-openai SDK before. This SDK provides two type client: OpenAIClient and OpenAIAsyncClient. OpenAIAsyncClient provides complete Mono async support for a single result. But when I migrated to Spring AI, I found that Mono support was not provided.

image

XhstormR avatar Apr 02 '24 18:04 XhstormR

Thanks for your input.

markpollack avatar Jul 22 '24 19:07 markpollack

Any updates on this subject?

andresssantos avatar Jan 28 '25 12:01 andresssantos

bumping this, an async endpoint for non-stream responses would be quite useful!

alvarosevilla95 avatar Apr 07 '25 09:04 alvarosevilla95

Hi @alvarosevilla95 @andresssantos we are hoping to address this gap, as well as a non reactive stream based method, by RC1, but unsure if we will make it is time and it may have to wait until a 1.1 release.

markpollack avatar Apr 21 '25 16:04 markpollack

We will have to wait until a post GA release to fill this gap.

markpollack avatar May 06 '25 21:05 markpollack