Class GPTChatCompletionServiceImpl.StreamDecodingResponseConsumer
- java.lang.Object
-
- org.apache.hc.core5.http.nio.entity.AbstractCharDataConsumer
-
- org.apache.hc.client5.http.async.methods.AbstractCharResponseConsumer<Void>
-
- com.composum.ai.backend.base.service.chat.impl.GPTChatCompletionServiceImpl.StreamDecodingResponseConsumer
-
- All Implemented Interfaces:
org.apache.hc.core5.http.nio.AsyncDataConsumer,org.apache.hc.core5.http.nio.AsyncResponseConsumer<Void>,org.apache.hc.core5.http.nio.ResourceHolder
- Enclosing class:
- GPTChatCompletionServiceImpl
protected class GPTChatCompletionServiceImpl.StreamDecodingResponseConsumer extends org.apache.hc.client5.http.async.methods.AbstractCharResponseConsumer<Void>
-
-
Field Summary
Fields Modifier and Type Field Description protected GPTCompletionCallbackcallbackprotected IntegererrorStatusCodeIf set, we collect the data for the error message, of false we process it as stream.protected longidprotected CompletableFuture<Void>resultprotected StringBuilderresultBuilder
-
Constructor Summary
Constructors Constructor Description StreamDecodingResponseConsumer(GPTCompletionCallback callback, CompletableFuture<Void> result, long id)The result of the webservice call is written to callback; result is set when either it completed or aborted.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected VoidbuildResult()protected intcapacityIncrement()protected voiddata(CharBuffer src, boolean endOfStream)voidfailed(Exception cause)voidreleaseResources()protected voidstart(org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.ContentType contentType)-
Methods inherited from class org.apache.hc.client5.http.async.methods.AbstractCharResponseConsumer
completed, consumeResponse, informationResponse
-
Methods inherited from class org.apache.hc.core5.http.nio.entity.AbstractCharDataConsumer
consume, setCharset, streamEnd, updateCapacity
-
-
-
-
Field Detail
-
callback
protected final GPTCompletionCallback callback
-
result
protected final CompletableFuture<Void> result
-
resultBuilder
protected final StringBuilder resultBuilder
-
id
protected final long id
-
errorStatusCode
protected Integer errorStatusCode
If set, we collect the data for the error message, of false we process it as stream.
-
-
Constructor Detail
-
StreamDecodingResponseConsumer
public StreamDecodingResponseConsumer(GPTCompletionCallback callback, CompletableFuture<Void> result, long id)
The result of the webservice call is written to callback; result is set when either it completed or aborted.
-
-
Method Detail
-
start
protected void start(org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.ContentType contentType) throws org.apache.hc.core5.http.HttpException, IOException- Specified by:
startin classorg.apache.hc.client5.http.async.methods.AbstractCharResponseConsumer<Void>- Throws:
org.apache.hc.core5.http.HttpExceptionIOException
-
data
protected void data(CharBuffer src, boolean endOfStream) throws IOException
- Specified by:
datain classorg.apache.hc.core5.http.nio.entity.AbstractCharDataConsumer- Throws:
IOException
-
buildResult
protected Void buildResult() throws IOException
- Specified by:
buildResultin classorg.apache.hc.client5.http.async.methods.AbstractCharResponseConsumer<Void>- Throws:
IOException
-
failed
public void failed(Exception cause)
-
capacityIncrement
protected int capacityIncrement()
- Specified by:
capacityIncrementin classorg.apache.hc.core5.http.nio.entity.AbstractCharDataConsumer
-
releaseResources
public void releaseResources()
-
-