Package com.hw.openai.stream
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
ConstructorDescriptionResponseBodyCallback
(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 TypeMethodDescriptionvoid
void
onResponse
(@NonNull retrofit2.Call<okhttp3.ResponseBody> call, @NonNull retrofit2.Response<okhttp3.ResponseBody> response)
-
Constructor Details
-
ResponseBodyCallback
-
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 interfaceretrofit2.Callback<okhttp3.ResponseBody>
-
onFailure
public void onFailure(@NonNull @NonNull retrofit2.Call<okhttp3.ResponseBody> call, @NonNull @NonNull Throwable t) - Specified by:
onFailure
in interfaceretrofit2.Callback<okhttp3.ResponseBody>
-