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 GPTCompletionCallback
callback
protected Integer
errorStatusCode
If set, we collect the data for the error message, of false we process it as stream.protected long
id
protected CompletableFuture<Void>
result
protected StringBuilder
resultBuilder
-
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 Void
buildResult()
protected int
capacityIncrement()
protected void
data(CharBuffer src, boolean endOfStream)
void
failed(Exception cause)
void
releaseResources()
protected void
start(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:
start
in classorg.apache.hc.client5.http.async.methods.AbstractCharResponseConsumer<Void>
- Throws:
org.apache.hc.core5.http.HttpException
IOException
-
data
protected void data(CharBuffer src, boolean endOfStream) throws IOException
- Specified by:
data
in classorg.apache.hc.core5.http.nio.entity.AbstractCharDataConsumer
- Throws:
IOException
-
buildResult
protected Void buildResult() throws IOException
- Specified by:
buildResult
in classorg.apache.hc.client5.http.async.methods.AbstractCharResponseConsumer<Void>
- Throws:
IOException
-
failed
public void failed(Exception cause)
-
capacityIncrement
protected int capacityIncrement()
- Specified by:
capacityIncrement
in classorg.apache.hc.core5.http.nio.entity.AbstractCharDataConsumer
-
releaseResources
public void releaseResources()
-
-