Class StreamingChatModelHelper
java.lang.Object
dev.langchain4j.model.chat.StreamingChatModelHelper
Bridges a single reactive
StreamingChatModel.chat(ChatRequest) call to a CompletableFuture of its
terminal ChatResponse: it subscribes with unbounded demand and completes the future with the last
ChatResponse emitted by the stream. This lets callers that need the whole response (driving a tool loop,
output-guardrail reprompts, ...) work with a streaming-only model without blocking.
Uses the reactive publisher API, not the handler-based chat(request, handler) overload. This is a
raw model call: it does not fire request/response observability events.
-
Method Summary
Modifier and TypeMethodDescriptionstatic CompletableFuture<ChatResponse> chatAsync(StreamingChatModel streamingChatModel, ChatRequest request) static CompletableFuture<ChatResponse> chatAsync(StreamingChatModel streamingChatModel, ChatRequest request, Consumer<Throwable> errorHandler) AschatAsync(StreamingChatModel, ChatRequest), but additionally notifieserrorHandler(if non-null) when the stream fails, before the returned future completes exceptionally.
-
Method Details
-
chatAsync
public static CompletableFuture<ChatResponse> chatAsync(StreamingChatModel streamingChatModel, ChatRequest request) -
chatAsync
public static CompletableFuture<ChatResponse> chatAsync(StreamingChatModel streamingChatModel, ChatRequest request, Consumer<Throwable> errorHandler) AschatAsync(StreamingChatModel, ChatRequest), but additionally notifieserrorHandler(if non-null) when the stream fails, before the returned future completes exceptionally.
-