File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
core/src/main/java/com/google/adk/agents Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,33 @@ public interface AfterModelCallback extends AfterModelCallbackBase {
6666 Maybe <LlmResponse > call (CallbackContext callbackContext , LlmResponse llmResponse );
6767 }
6868
69+ /** An extended callback interface for streaming LLM responses. */
70+ public interface StreamingAfterModelCallback extends AfterModelCallback {
71+ /**
72+ * Invoked repeatedly for each significant chunk during a live stream.
73+ *
74+ * @param callbackContext Callback context.
75+ * @param llmResponse LLM response chunk.
76+ * @return modified response chunk, or empty to keep original.
77+ */
78+ Maybe <LlmResponse > callInStream (CallbackContext callbackContext , LlmResponse llmResponse );
79+
80+ /**
81+ * Invoked once at turn completion.
82+ *
83+ * @param callbackContext Callback context.
84+ * @param finalResponse The final, aggregated LLM response.
85+ * @return modified final response, or empty to keep original.
86+ */
87+ Maybe <LlmResponse > callAtStreamEnd (CallbackContext callbackContext , LlmResponse finalResponse );
88+
89+ /** Defaults to the end-of-stream behavior. */
90+ @ Override
91+ default Maybe <LlmResponse > call (CallbackContext callbackContext , LlmResponse llmResponse ) {
92+ return callAtStreamEnd (callbackContext , llmResponse );
93+ }
94+ }
95+
6996 /**
7097 * Helper interface to allow for sync afterModelCallback. The function is wrapped into an async
7198 * one before being processed further.
You can’t perform that action at this time.
0 commit comments