Package xyz.felh.openai
Class StreamChatCompletionListener
java.lang.Object
xyz.felh.openai.StreamChatCompletionListener
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()cancel eventSourcevoidNo further calls to this listener will be made.voidonEvent(String requestId, ChatCompletion chatCompletion) event linevoidonEventDone(String requestId) event message finishedvoidInvoked when an event source has been closed due to an error reading from or writing to the network.voidInvoked when an event source has been accepted by the remote peer and may begin transmitting events.voidsetEventSource(okhttp3.sse.EventSource eventSource)
-
Constructor Details
-
StreamChatCompletionListener
public StreamChatCompletionListener()
-
-
Method Details
-
setEventSource
public void setEventSource(okhttp3.sse.EventSource eventSource) -
onOpen
Invoked when an event source has been accepted by the remote peer and may begin transmitting events.- Parameters:
requestId- request IDresponse- OK http response
-
onEvent
event line- Parameters:
requestId- request IDchatCompletion- return chat completion
-
onEventDone
event message finished- Parameters:
requestId- request ID
-
onClosed
No further calls to this listener will be made.
- Parameters:
requestId- request ID
-
onFailure
Invoked when an event source has been closed due to an error reading from or writing to the network. Incoming events may have been lost. No further calls to this listener will be made.- Parameters:
requestId- request IDt- throwableresponse- response
-
close
public void close()cancel eventSource
-