Class ResponseBodyCallback

java.lang.Object
com.hw.openai.stream.ResponseBodyCallback
All Implemented Interfaces:
retrofit2.Callback<okhttp3.ResponseBody>

public class ResponseBodyCallback extends Object implements retrofit2.Callback<okhttp3.ResponseBody>
Callback to parse Server Sent Events (SSE) from raw InputStream and emit the events with io.reactivex.FlowableEmitter to allow streaming of SSE.
Author:
HamaWhite
  • Constructor Summary

    Constructors
    Constructor
    Description
    ResponseBodyCallback(io.reactivex.FlowableEmitter<SSE> emitter, boolean emitDone)
     
    ResponseBodyCallback(io.reactivex.FlowableEmitter<SSE> emitter, boolean emitDone, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onFailure(@NonNull retrofit2.Call<okhttp3.ResponseBody> call, @NonNull Throwable t)
     
    void
    onResponse(@NonNull retrofit2.Call<okhttp3.ResponseBody> call, @NonNull retrofit2.Response<okhttp3.ResponseBody> response)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ResponseBodyCallback

      public ResponseBodyCallback(io.reactivex.FlowableEmitter<SSE> emitter, boolean emitDone)
    • ResponseBodyCallback

      public ResponseBodyCallback(io.reactivex.FlowableEmitter<SSE> emitter, boolean emitDone, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
  • Method Details

    • onResponse

      public void onResponse(@NonNull @NonNull retrofit2.Call<okhttp3.ResponseBody> call, @NonNull @NonNull retrofit2.Response<okhttp3.ResponseBody> response)
      Specified by:
      onResponse in interface retrofit2.Callback<okhttp3.ResponseBody>
    • onFailure

      public void onFailure(@NonNull @NonNull retrofit2.Call<okhttp3.ResponseBody> call, @NonNull @NonNull Throwable t)
      Specified by:
      onFailure in interface retrofit2.Callback<okhttp3.ResponseBody>