Class EventStream

    • Field Detail

      • QUEUEEND

        public static final String QUEUEEND
        Special message in the queue that signals that we are done. Impossible in the normal stream.
        See Also:
        Constant Field Values
    • Constructor Detail

      • EventStream

        public EventStream()
    • Method Detail

      • setId

        public void setId​(String id)
      • onFinish

        public void onFinish​(GPTFinishReason finishReason)
        Successfull conclusion; puts event 'finished' into the stream with data JSON like this: {"success":true,"data":{"result":{"finishreason":"STOP"}}}
        Specified by:
        onFinish in interface GPTCompletionCallback
      • setLoggingId

        public void setLoggingId​(String loggingId)
        Description copied from interface: GPTCompletionCallback
        For debugging: this sets the internal ID that is used for logging purposes. Not a good ID give to the world, though.
        Specified by:
        setLoggingId in interface GPTCompletionCallback
      • addWholeResponseListener

        public void addWholeResponseListener​(Consumer<String> listener)
      • getWholeResponse

        @Nullable
        public String getWholeResponse()
        Returns the whole response, but only if it was received completely, otherwise null.
      • writeData

        protected void writeData​(String data)
      • onError

        public void onError​(Throwable throwable)
        Puts an 'exception' event into the stream with data JSON like this: {"success":false,"title":"Internal error","messages":[{"level":"error","text":"something happened"}]}
        Specified by:
        onError in interface GPTCompletionCallback