desc: It's easy to get an assitantMessage from the result in a non-streaming response, but there doesn't seem to be a straightforward way to get an assitantMessage in a streaming response, so I need to manually implement a complex logic to accomplish this. I'm wondering if there's a relatively simple and straightforward way to accomplish this?
Minimal:
chatClient.prompt().stream().chatClientResponse(); ...-> AssistentMessage
env: java 17 1.1.0-snapshot
Comment From: fanxt0218
In my realization, I achieved it roughly like this
Flux<AssistantMessage> assistantMessageFlux = chatClient.prompt().stream().chatClientResponse().map(chatClientResponse -> chatClientResponse.chatResponse().getResult().getOutput());
Mono<List<AssistantMessage>> listMono = assistantMessageFlux.collectList();
listMono.flatMap(messages -> { ...
retuen Mono.just(new AssistantMessage( ... )); }
But it's inconvenient, and I'd like to see an easier way. Or what implementation I didn't notice, please let me know, thanks!