Interface StreamObserver<R extends Response<?>>

Type Parameters:
R - The type of Response in the stream.

public interface StreamObserver<R extends Response<?>>
A simple interface for observing a stream of values, typically used for asynchronous token streaming from an AI model.
Author:
anahata-gemini-pro-2.5
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Called when the stream has completed successfully.
    void
    Called when an error occurs in the stream.
    void
    onNext(R value)
    Called when a new value is available in the stream.
    void
    onStart(List<? extends AbstractModelMessage> candidates)
    Called when the stream starts, providing the initial candidate messages.
  • Method Details

    • onStart

      void onStart(List<? extends AbstractModelMessage> candidates)
      Called when the stream starts, providing the initial candidate messages.
      Parameters:
      candidates - The list of candidate messages that will be updated.
    • onNext

      void onNext(R value)
      Called when a new value is available in the stream.
      Parameters:
      value - The next value.
    • onComplete

      void onComplete()
      Called when the stream has completed successfully.
    • onError

      void onError(Throwable t)
      Called when an error occurs in the stream.
      Parameters:
      t - The error that occurred.