CompletionStreamListener
org.llm4s.javaapi.CompletionStreamListener
trait CompletionStreamListener
Receives a streamed completion from JLlmClient.stream: each piece of the reply's text, in order, through onPartial, then exactly one of onComplete (the whole reply) or onError (the error the call failed with, a cancellation included). Calls are made one at a time, never on the caller's thread.
Only onPartial is abstract, so a Java lambda is a listener:
CompletionStream stream = client.stream("Tell me a story", System.out::print).get();
LlmResult<JCompletion> reply = stream.await();
A listener that throws from onPartial stops the call (its thread is interrupted, which is how llm4s providers are cancelled), and onError receives what it threw.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
In this article