Class GPTCompletionCallback.GPTCompletionCollector
- java.lang.Object
-
- com.composum.ai.backend.base.service.chat.GPTCompletionCallback.GPTCompletionCollector
-
- All Implemented Interfaces:
GPTCompletionCallback
- Enclosing interface:
- GPTCompletionCallback
public static class GPTCompletionCallback.GPTCompletionCollector extends Object implements GPTCompletionCallback
A simple collector that just takes note of things.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.composum.ai.backend.base.service.chat.GPTCompletionCallback
GPTCompletionCallback.GPTCompletionCallbackWrapper, GPTCompletionCallback.GPTCompletionCollector, GPTCompletionCallback.GPTToolExecutionContext
-
-
Constructor Summary
Constructors Constructor Description GPTCompletionCollector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Throwable
getError()
GPTFinishReason
getFinishReason()
String
getResult()
List<GPTToolCall>
getToolCalls()
GPTCompletionCallback.GPTToolExecutionContext
getToolExecutionContext()
For tool calls: set the context to execute actions in.void
onError(Throwable throwable)
Called when an error occurs.void
onFinish(GPTFinishReason finishReason)
This is called when the response is complete to specify the reason (e.g.void
onNext(String chars)
Called when a couple of characters come in.void
setLoggingId(String loggingId)
For debugging: this sets the internal ID that is used for logging purposes.void
toolDelta(List<GPTToolCall> toolCalls)
Called when a tool call is made.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.composum.ai.backend.base.service.chat.GPTCompletionCallback
close, setRequest
-
-
-
-
Method Detail
-
onFinish
public void onFinish(GPTFinishReason finishReason)
Description copied from interface:GPTCompletionCallback
This is called when the response is complete to specify the reason (e.g.GPTFinishReason.STOP
when done orGPTFinishReason.LENGTH
if the maximum length has been reached).- Specified by:
onFinish
in interfaceGPTCompletionCallback
-
onNext
public void onNext(String chars)
Description copied from interface:GPTCompletionCallback
Called when a couple of characters come in.- Specified by:
onNext
in interfaceGPTCompletionCallback
-
onError
public void onError(Throwable throwable)
Description copied from interface:GPTCompletionCallback
Called when an error occurs.- Specified by:
onError
in interfaceGPTCompletionCallback
-
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 interfaceGPTCompletionCallback
-
getFinishReason
public GPTFinishReason getFinishReason()
-
getResult
public String getResult()
-
getError
public Throwable getError()
-
toolDelta
public void toolDelta(List<GPTToolCall> toolCalls)
Description copied from interface:GPTCompletionCallback
Called when a tool call is made.- Specified by:
toolDelta
in interfaceGPTCompletionCallback
-
getToolCalls
public List<GPTToolCall> getToolCalls()
-
getToolExecutionContext
public GPTCompletionCallback.GPTToolExecutionContext getToolExecutionContext()
Description copied from interface:GPTCompletionCallback
For tool calls: set the context to execute actions in.- Specified by:
getToolExecutionContext
in interfaceGPTCompletionCallback
-
-