Class LambdaStreamingResponseHandler<T>

java.lang.Object
dev.langchain4j.model.LambdaStreamingResponseHandler<T>
Type Parameters:
T - The type of the response.

public class LambdaStreamingResponseHandler<T> extends Object
Utility class with lambda-based streaming response handlers. Lets you use Java lambda functions to receive onNext and onError events, from your streaming chat model, instead of creating an anonymous inner class implementing StreamingResponseHandler. Example:
 import static dev.langchain4j.model.LambdaStreamingResponseHandler.*;

 model.generate("Why is the sky blue?",
       onNext(text -> System.out.println(text));
 model.generate("Why is the sky blue?",
       onNext(System.out::println);
 model.generate("Why is the sky blue?",
       onNextAndError(System.out::println, Throwable::printStackTrace));
 
See Also: