org.llm4s.javaapi.reactor
package org.llm4s.javaapi.reactor
Members list
Type members
Classlikes
object Streams
A model's reply as a Reactor Flux<String> of its text (#1492), for Spring WebFlux and other Reactor pipelines.
A model's reply as a Reactor Flux<String> of its text (#1492), for Spring WebFlux and other Reactor pipelines.
Each method adapts the JDK Flow.Publisher of org.llm4s.javaapi.JLlmClient#streamAsPublisher with Reactor's JdkFlowAdapter, so the Flux behaves as that publisher does:
- it is cold: each subscription makes its own provider call, on a thread of its own;
- it emits the pieces of the reply's text in order, then completes;
- a failed call ends it with
onError, carrying an LlmException whosegetKind()says what failed; - it honours backpressure: a subscriber that requests less than the model produces holds the provider's thread rather than losing text;
- cancelling the subscription (
dispose(),take(n), a client that disconnects) interrupts the provider call.
A null argument is never thrown: the Flux fails on subscription with an LlmException of kind VALIDATION.
Flux<String> reply = Streams.toFlux(client, "Explain monads in one sentence");
reply.subscribe(System.out::print);
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Streams.type
In this article