Class EventStream
- java.lang.Object
 - 
- com.composum.ai.backend.slingbase.EventStream
 
 
- 
- All Implemented Interfaces:
 com.composum.ai.backend.base.service.chat.GPTCompletionCallback
public class EventStream extends Object implements com.composum.ai.backend.base.service.chat.GPTCompletionCallback
 
- 
- 
Nested Class Summary
- 
Nested classes/interfaces inherited from interface com.composum.ai.backend.base.service.chat.GPTCompletionCallback
com.composum.ai.backend.base.service.chat.GPTCompletionCallback.GPTCompletionCallbackWrapper, com.composum.ai.backend.base.service.chat.GPTCompletionCallback.GPTCompletionCollector, com.composum.ai.backend.base.service.chat.GPTCompletionCallback.GPTToolExecutionContext 
 - 
 
- 
Constructor Summary
Constructors Constructor Description EventStream() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddWholeResponseListener(Consumer<String> listener)SlingGPTExecutionContextgetToolExecutionContext()StringgetWholeResponse()Returns the whole response, but only if it was received completely, otherwise null.voidonError(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"}]}voidonFinish(com.composum.ai.backend.base.service.chat.GPTFinishReason finishReason)Successfull conclusion; puts event 'finished' into the stream with data JSON like this: {"success":true,"data":{"result":{"finishreason":"STOP"}}}voidonNext(String data)voidsetContext(SlingGPTExecutionContext context)voidsetId(String id)voidsetLoggingId(String loggingId)protected voidwriteData(String data)voidwriteTo(PrintWriter writer) 
 - 
 
- 
- 
Field Detail
- 
QUEUEEND
public static final String QUEUEEND
Special message in thequeuethat signals that we are done. Impossible in the normal stream.- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Method Detail
- 
setId
public void setId(String id)
 
- 
writeTo
public void writeTo(PrintWriter writer) throws InterruptedException
- Throws:
 InterruptedException
 
- 
onFinish
public void onFinish(com.composum.ai.backend.base.service.chat.GPTFinishReason finishReason)
Successfull conclusion; puts event 'finished' into the stream with data JSON like this: {"success":true,"data":{"result":{"finishreason":"STOP"}}}- Specified by:
 onFinishin interfacecom.composum.ai.backend.base.service.chat.GPTCompletionCallback
 
- 
setLoggingId
public void setLoggingId(String loggingId)
- Specified by:
 setLoggingIdin interfacecom.composum.ai.backend.base.service.chat.GPTCompletionCallback
 
- 
getWholeResponse
@Nullable public String getWholeResponse()
Returns the whole response, but only if it was received completely, otherwise null. 
- 
onNext
public void onNext(String data)
- Specified by:
 onNextin interfacecom.composum.ai.backend.base.service.chat.GPTCompletionCallback
 
- 
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:
 onErrorin interfacecom.composum.ai.backend.base.service.chat.GPTCompletionCallback
 
- 
setContext
public void setContext(SlingGPTExecutionContext context)
 
- 
getToolExecutionContext
public SlingGPTExecutionContext getToolExecutionContext()
- Specified by:
 getToolExecutionContextin interfacecom.composum.ai.backend.base.service.chat.GPTCompletionCallback
 
 - 
 
 -