Class StreamChatCompletionListener

java.lang.Object
xyz.felh.openai.StreamChatCompletionListener

public abstract class StreamChatCompletionListener extends Object
  • Constructor Details

    • StreamChatCompletionListener

      public StreamChatCompletionListener()
  • Method Details

    • setEventSource

      public void setEventSource(okhttp3.sse.EventSource eventSource)
    • onOpen

      public void onOpen(String requestId, okhttp3.Response response)
      Invoked when an event source has been accepted by the remote peer and may begin transmitting events.
      Parameters:
      requestId - request ID
      response - OK http response
    • onEvent

      public void onEvent(String requestId, ChatCompletion chatCompletion)
      event line
      Parameters:
      requestId - request ID
      chatCompletion - return chat completion
    • onEventDone

      public void onEventDone(String requestId)
      event message finished
      Parameters:
      requestId - request ID
    • onClosed

      public void onClosed(String requestId)

      No further calls to this listener will be made.

      Parameters:
      requestId - request ID
    • onFailure

      public void onFailure(String requestId, Throwable t, okhttp3.Response response)
      Invoked when an event source has been closed due to an error reading from or writing to the network. Incoming events may have been lost. No further calls to this listener will be made.
      Parameters:
      requestId - request ID
      t - throwable
      response - response
    • close

      public void close()
      cancel eventSource