Class ResponseListener.ResponseEvent

java.lang.Object
com.vaadin.flow.component.ai.orchestrator.ResponseListener.ResponseEvent
All Implemented Interfaces:
Serializable
Enclosing interface:
ResponseListener

public static class ResponseListener.ResponseEvent extends Object implements Serializable
Event fired when a turn ends, on success or failure.
See Also:
  • Constructor Details

    • ResponseEvent

      public ResponseEvent(String response, Throwable error, ResponseMetadata metadata)
      Creates a turn-outcome event. The orchestrator builds this for every turn; it is public so an application can construct one when unit testing an AIController implementation.
      Parameters:
      response - the assistant's response text, not null
      error - the cause of failure, or null on success
      metadata - the provider's metadata for the turn, or null when none was reported
      Since:
      25.3
  • Method Details

    • getResponse

      public String 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

      public Optional<Throwable> 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

      public Optional<ResponseMetadata> 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 custom LLMProvider that 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