Interface GPTCompletionCallback
-
- All Known Implementing Classes:
EventStream
,GPTCompletionCallback.GPTCompletionCallbackWrapper
,GPTCompletionCallback.GPTCompletionCollector
public interface GPTCompletionCallback
For 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 class
GPTCompletionCallback.GPTCompletionCallbackWrapper
Forwards all methods to a delegate.static class
GPTCompletionCallback.GPTCompletionCollector
A simple collector that just takes note of things.static interface
GPTCompletionCallback.GPTToolExecutionContext
For tool calls: context to execute actions in.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
close()
Notifies that the request is completely finished / closed, nothing more will arrive.default 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.default void
setRequest(String json)
For debugging - the request that was sent to ChatGPT as JSON.default void
toolDelta(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.STOP
when done orGPTFinishReason.LENGTH
if 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.
-
-