Package com.google.adk.models
Class LlmResponse
java.lang.Object
com.google.adk.JsonBaseModel
com.google.adk.models.LlmResponse
Represents a response received from the LLM.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionError code if the response is an error.static LlmResponse.Builderbuilder()abstract Optional<com.google.genai.types.Content>content()Returns the content of the first candidate in the response, if available.static LlmResponsecreate(com.google.genai.types.GenerateContentResponse response) static LlmResponseReturns the custom metadata of the response, if available.abstract Optional<com.google.genai.types.FinishReason>Error code if the response is an error.Error message if the response is an error.abstract Optional<com.google.genai.types.FinishReason>Error code if the response is an error.abstract Optional<com.google.genai.types.GroundingMetadata>Returns the grounding metadata of the first candidate in the response, if available.Indicates that LLM was interrupted when generating the content.The model version used to generate the response.partial()Indicates whether the text content is part of a unfinished text stream.abstract LlmResponse.BuilderIndicates whether the response from the model is complete.abstract Optional<com.google.genai.types.GenerateContentResponseUsageMetadata>Usage metadata about the response(s).Methods inherited from class com.google.adk.JsonBaseModel
fromJsonNode, fromJsonString, getMapper, toJson, toJsonNode, toJsonString
-
Method Details
-
content
Returns the content of the first candidate in the response, if available.- Returns:
- An
Contentof the firstCandidatein theGenerateContentResponseif the response contains at least one candidate., or an empty optional if no candidates are present in the response.
-
groundingMetadata
Returns the grounding metadata of the first candidate in the response, if available.- Returns:
- An
OptionalcontainingGroundingMetadataor empty.
-
customMetadata
Returns the custom metadata of the response, if available.- Returns:
- An
Optionalcontaining a list ofCustomMetadataor empty.
-
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
Indicates whether the response from the model is complete.Only used for streaming mode.
-
errorCode
Error code if the response is an error. Code varies by model. -
finishReason
Error code if the response is an error. Code varies by model. -
avgLogprobs
Error code if the response is an error. Code varies by model. -
errorMessage
Error message if the response is an error. -
interrupted
Indicates that LLM was interrupted when generating the content. Usually it's due to user interruption during a bidi streaming. -
usageMetadata
public abstract Optional<com.google.genai.types.GenerateContentResponseUsageMetadata> usageMetadata()Usage metadata about the response(s). -
modelVersion
The model version used to generate the response. -
toBuilder
-
builder
-
create
-
create
-