Class LlmResponse

java.lang.Object
com.google.adk.JsonBaseModel
com.google.adk.models.LlmResponse

public abstract class LlmResponse extends JsonBaseModel
Represents a response received from the LLM.
  • Method Details

    • content

      public abstract Optional<com.google.genai.types.Content> content()
      Returns the content of the first candidate in the response, if available.
      Returns:
      An Content of the first Candidate in the GenerateContentResponse if the response contains at least one candidate., or an empty optional if no candidates are present in the response.
    • groundingMetadata

      public abstract Optional<com.google.genai.types.GroundingMetadata> groundingMetadata()
      Returns the grounding metadata of the first candidate in the response, if available.
      Returns:
      An Optional containing GroundingMetadata or empty.
    • partial

      public abstract Optional<Boolean> partial()
      Indicates whether the text content is part of a unfinished text stream.

      Only used for streaming mode and when the content is plain text.

    • turnComplete

      public abstract Optional<Boolean> turnComplete()
      Indicates whether the response from the model is complete.

      Only used for streaming mode.

    • errorCode

      public abstract Optional<com.google.genai.types.FinishReason> errorCode()
      Error code if the response is an error. Code varies by model.
    • errorMessage

      public abstract Optional<String> errorMessage()
      Error message if the response is an error.
    • interrupted

      public abstract Optional<Boolean> interrupted()
      Indicates that LLM was interrupted when generating the content. Usually it's due to user interruption during a bidi streaming.
    • toBuilder

      public abstract LlmResponse.Builder toBuilder()
    • builder

      public static LlmResponse.Builder builder()
    • create

      public static LlmResponse create(List<com.google.genai.types.Candidate> candidates)
    • create

      public static LlmResponse create(com.google.genai.types.GenerateContentResponse response)