Class ChatResponse
java.lang.Object
org.springframework.ai.chat.model.ChatResponse
- All Implemented Interfaces:
ModelResponse<Generation>
The chat completion (e.g. generation) response returned by an AI provider.
- Author:
- Christian Tzolov, Mark Pollack, Soby Chacko, John Blum, Alexandros Pappas, Thomas Vitale
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionChatResponse(List<Generation> generations) Construct a newChatResponseinstance without metadata.ChatResponse(List<Generation> generations, ChatResponseMetadata chatResponseMetadata) Construct a newChatResponseinstance. -
Method Summary
Modifier and TypeMethodDescriptionstatic ChatResponse.Builderbuilder()booleanRetrieves the response metadata associated with the AI model's response.Retrieves the result of the AI model.TheListofgenerated outputs.booleanhasFinishReasons(Set<String> finishReasons) Whether the model has finished with any of the given finish reasons.inthashCode()booleanWhether the model has requested the execution of a tool.toString()
-
Constructor Details
-
ChatResponse
Construct a newChatResponseinstance without metadata.- Parameters:
generations- theListofGenerationreturned by the AI provider.
-
ChatResponse
Construct a newChatResponseinstance.- Parameters:
generations- theListofGenerationreturned by the AI provider.chatResponseMetadata-ChatResponseMetadatacontaining information about the use of the AI provider's API.
-
-
Method Details
-
builder
-
getResults
TheListofgenerated outputs.It is a
Listoflistsbecause the Prompt could request multiple outputgenerations.- Specified by:
getResultsin interfaceModelResponse<Generation>- Returns:
- the
Listofgenerated outputs.
-
getResult
Description copied from interface:ModelResponseRetrieves the result of the AI model.- Specified by:
getResultin interfaceModelResponse<Generation>- Returns:
- Returns the first
Generationin the generations list.
-
getMetadata
Description copied from interface:ModelResponseRetrieves the response metadata associated with the AI model's response.- Specified by:
getMetadatain interfaceModelResponse<Generation>- Returns:
- Returns
ChatResponseMetadatacontaining information about the use of the AI provider's API.
-
hasToolCalls
public boolean hasToolCalls()Whether the model has requested the execution of a tool. -
hasFinishReasons
Whether the model has finished with any of the given finish reasons. -
toString
-
equals
-
hashCode
public int hashCode()
-