Class ResponseListener.ResponseEvent
java.lang.Object
com.vaadin.flow.component.ai.orchestrator.ResponseListener.ResponseEvent
- All Implemented Interfaces:
Serializable
- Enclosing interface:
ResponseListener
Event fired when a turn ends, on success or failure.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionResponseEvent(String response, Throwable error, ResponseMetadata metadata) Creates a turn-outcome event. -
Method Summary
Modifier and TypeMethodDescriptiongetError()Gets the failure cause if the turn ended with an error.Gets the metadata the provider reported for this turn, such as the finish reason and token usage.Gets the assistant's response text.
-
Constructor Details
-
ResponseEvent
Creates a turn-outcome event. The orchestrator builds this for every turn; it is public so an application can construct one when unit testing anAIControllerimplementation.- Parameters:
response- the assistant's response text, notnullerror- the cause of failure, ornullon successmetadata- the provider's metadata for the turn, ornullwhen none was reported- Since:
- 25.3
-
-
Method Details
-
getResponse
Gets the assistant's response text. On success this is the full text (may be empty when the model emitted only tool calls); on failure the orchestrator passes an empty string, even if text was received before the error.- Returns:
- the response text, never
null
-
getError
Gets the failure cause if the turn ended with an error. Returns an empty optional on a successful turn.- Returns:
- the failure cause, or empty on success
-
getMetadata
Gets the metadata the provider reported for this turn, such as the finish reason and token usage. On a failed turn this is what was observed before the failure. Returns an empty optional when the provider reported none — a customLLMProviderthat does not publish metadata, or a turn that failed before any was observed.- Returns:
- the response metadata, or empty when the provider reported none
- Since:
- 25.3
-