Interface GPTCompletionCallback
-
- All Known Implementing Classes:
EventStream,GPTCompletionCallback.GPTCompletionCallbackWrapper,GPTCompletionCallback.GPTCompletionCollector
public interface GPTCompletionCallbackFor a streaming mode this is given as parameter for the method call and receives the streamed data; the method returns only when the response is complete.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classGPTCompletionCallback.GPTCompletionCallbackWrapperForwards all methods to a delegate.static classGPTCompletionCallback.GPTCompletionCollectorA simple collector that just takes note of things.static interfaceGPTCompletionCallback.GPTToolExecutionContextFor tool calls: context to execute actions in.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidclose()Notifies that the request is completely finished / closed, nothing more will arrive.default GPTCompletionCallback.GPTToolExecutionContextgetToolExecutionContext()For tool calls: set the context to execute actions in.voidonError(Throwable throwable)Called when an error occurs.voidonFinish(GPTFinishReason finishReason)This is called when the response is complete to specify the reason (e.g.voidonNext(String chars)Called when a couple of characters come in.voidsetLoggingId(String loggingId)For debugging: this sets the internal ID that is used for logging purposes.default voidsetRequest(String json)For debugging - the request that was sent to ChatGPT as JSON.default voidtoolDelta(List<GPTToolCall> toolCalls)Called when a tool call is made.
-
-
-
Method Detail
-
onFinish
void onFinish(GPTFinishReason finishReason)
This is called when the response is complete to specify the reason (e.g.GPTFinishReason.STOPwhen done orGPTFinishReason.LENGTHif the maximum length has been reached).
-
onNext
void onNext(String chars)
Called when a couple of characters come in.
-
onError
void onError(Throwable throwable)
Called when an error occurs.
-
setLoggingId
void setLoggingId(String loggingId)
For debugging: this sets the internal ID that is used for logging purposes. Not a good ID give to the world, though.
-
getToolExecutionContext
default GPTCompletionCallback.GPTToolExecutionContext getToolExecutionContext()
For tool calls: set the context to execute actions in.
-
setRequest
default void setRequest(String json)
For debugging - the request that was sent to ChatGPT as JSON.
-
close
default void close()
Notifies that the request is completely finished / closed, nothing more will arrive.
-
toolDelta
default void toolDelta(List<GPTToolCall> toolCalls)
Called when a tool call is made.
-
-