File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
spring-ai-adapter/src/main/java/com/javaaidev/chatagent/springai Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change 1616import org .springframework .ai .chat .model .ChatResponse ;
1717import org .springframework .ai .chat .model .Generation ;
1818import org .springframework .http .codec .ServerSentEvent ;
19+ import org .springframework .util .StringUtils ;
1920import reactor .core .publisher .Flux ;
2021
2122/**
@@ -78,8 +79,9 @@ public static Flux<ServerSentEvent<ChatAgentResponse>> toStreamingResponse(
7879 Flux <ChatResponse > chatResponse ) {
7980 return chatResponse .concatMap (
8081 response -> Flux .fromIterable (response .getResults ()))
81- .filter (generation -> Objects .nonNull (generation .getOutput (). getText () ))
82+ .filter (generation -> Objects .nonNull (generation .getOutput ()))
8283 .map (generation -> generation .getOutput ().getText ())
84+ .filter (StringUtils ::hasText )
8385 .map (text -> ServerSentEvent .<ChatAgentResponse >builder ()
8486 .data (new ChatAgentResponse (
8587 List .of (new TextContentPart (text ))))
You can’t perform that action at this time.
0 commit comments