Package org.springframework.ai.chat
Class ChatResponse
java.lang.Object
org.springframework.ai.chat.ChatResponse
- All Implemented Interfaces:
ModelResponse<Generation>
The chat completion (e.g. generation) response returned by an AI provider.
-
Constructor Summary
ConstructorsConstructorDescriptionChatResponse(List<Generation> generations) Construct a newChatResponseinstance without metadata.ChatResponse(List<Generation> generations, ChatResponseMetadata chatResponseMetadata) Construct a newChatResponseinstance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanRetrieves the response metadata associated with the AI model's response.Retrieves the result of the AI model.TheListofgenerated outputs.inthashCode()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
-
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.
-
toString
-
equals
-
hashCode
public int hashCode()
-