A completion being streamed from JLlmClient.stream to its CompletionStreamListener: cancel it, or await its reply. It is AutoCloseable, and close() cancels, so a try-with-resources block stops a call its body leaves.
Blocks until the listener has returned from its last call - CompletionStreamListener.onComplete or CompletionStreamListener.onError - then returns the same outcome. A call whose thread is interrupted first returns a failed result (CancelledError) with the interrupt flag still set, and the stream carries on. A call from the listener itself, which would wait on itself, returns a failed result at once.
Blocks until the listener has returned from its last call - CompletionStreamListener.onComplete or CompletionStreamListener.onError - then returns the same outcome. A call whose thread is interrupted first returns a failed result (CancelledError) with the interrupt flag still set, and the stream carries on. A call from the listener itself, which would wait on itself, returns a failed result at once.
Cancels the call: the provider's thread is interrupted, which is how llm4s providers are cancelled, and no further piece is delivered. The listener then receives CompletionStreamListener.onError with the cancellation - or onComplete, for a call that had already ended. Returns once the listener has heard, or after 5 seconds when a provider ignores the interrupt (logged at WARN). Safe to call more than once, from any thread, the listener's included.
Cancels the call: the provider's thread is interrupted, which is how llm4s providers are cancelled, and no further piece is delivered. The listener then receives CompletionStreamListener.onError with the cancellation - or onComplete, for a call that had already ended. Returns once the listener has heard, or after 5 seconds when a provider ignores the interrupt (logged at WARN). Safe to call more than once, from any thread, the listener's included.