Class HttpStreamingChatPublisher

java.lang.Object
dev.langchain4j.reactive.streaming.HttpStreamingChatPublisher

public final class HttpStreamingChatPublisher extends Object
Builds a reactive Publisher<ChatModelStreamingEvent> for a streaming chat model from an upstream Publisher<HttpStreamingEvent> (typically httpClient.stream(request, parser)), factoring out the boilerplate every provider's reactive path otherwise hand-rolls:
  • a bounded, back-pressured Tube of ChatModelStreamingEvents (ZeroPublisher);
  • a subscriber whose cancellation is subscription-based — it cancels the upstream Flow.Subscription on any terminal signal (a downstream cancel, an error, or a buffer overflow), so, for example, an overflow actually aborts the HTTP connection; and
  • delegation of each upstream event to a provider-supplied HttpStreamingChatPublisher.Sink.
Only the per-event interpretation (parsing the provider's SSE payloads and driving a StreamingChatResponseHandler / TubeBackedStreamingChatResponseHandler) is provider-specific; that lives in the HttpStreamingChatPublisher.Sink, created per subscription from the Tube.