Class 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 Detail

      • 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 class org.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 class org.apache.hc.core5.http.nio.entity.AbstractCharDataConsumer
        Throws:
        IOException
      • buildResult

        protected Void buildResult()
                            throws IOException
        Specified by:
        buildResult in class org.apache.hc.client5.http.async.methods.AbstractCharResponseConsumer<Void>
        Throws:
        IOException
      • failed

        public void failed​(Exception cause)
        Specified by:
        failed in interface org.apache.hc.core5.http.nio.AsyncResponseConsumer<Void>
        Overrides:
        failed in class org.apache.hc.client5.http.async.methods.AbstractCharResponseConsumer<Void>
      • capacityIncrement

        protected int capacityIncrement()
        Specified by:
        capacityIncrement in class org.apache.hc.core5.http.nio.entity.AbstractCharDataConsumer
      • releaseResources

        public void releaseResources()