Interface StreamingChatResponseHandler
public interface StreamingChatResponseHandler
TODO review all javadoc in this class
Represents a handler for streaming a response from a
StreamingChatLanguageModel
.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
onCompleteResponse
(ChatResponse completeResponse) Invoked when the model has finished streaming a response.void
This method is invoked when an error occurs during streaming.void
onPartialResponse
(String partialResponse) Invoked each time the model generates a partial response (usually a single token) in a textual response.
-
Method Details
-
onPartialResponse
Invoked each time the model generates a partial response (usually a single token) in a textual response. If the model decides to execute a tool instead, this method will not be invoked;onCompleteResponse(dev.langchain4j.model.chat.response.ChatResponse)
will be invoked instead.- Parameters:
partialResponse
- The partial response (usually a single token), which is a part of the complete response.
-
onCompleteResponse
Invoked when the model has finished streaming a response. If the model requests the execution of one or multiple tools, this can be accessed viaChatResponse.aiMessage()
->AiMessage.toolExecutionRequests()
.- Parameters:
completeResponse
- The complete response generated by the model. For textual responses, it contains all tokens fromonPartialResponse(java.lang.String)
concatenated.
-
onError
This method is invoked when an error occurs during streaming.- Parameters:
error
- The error that occurred
-