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
-
Constructor Summary
ConstructorDescriptionChatResponse
(List<Generation> generations) Construct a newChatResponse
instance without metadata.ChatResponse
(List<Generation> generations, ChatResponseMetadata chatResponseMetadata) Construct a newChatResponse
instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic ChatResponse.Builder
builder()
boolean
Retrieves the response metadata associated with the AI model's response.Retrieves the result of the AI model.TheList
ofgenerated outputs
.int
hashCode()
boolean
Whether the model has requested the execution of a tool.toString()
-
Constructor Details
-
ChatResponse
Construct a newChatResponse
instance without metadata.- Parameters:
generations
- theList
ofGeneration
returned by the AI provider.
-
ChatResponse
Construct a newChatResponse
instance.- Parameters:
generations
- theList
ofGeneration
returned by the AI provider.chatResponseMetadata
-ChatResponseMetadata
containing information about the use of the AI provider's API.
-
-
Method Details
-
builder
-
getResults
TheList
ofgenerated outputs
.It is a
List
oflists
because the Prompt could request multiple outputgenerations
.- Specified by:
getResults
in interfaceModelResponse<Generation>
- Returns:
- the
List
ofgenerated outputs
.
-
getResult
Description copied from interface:ModelResponse
Retrieves the result of the AI model.- Specified by:
getResult
in interfaceModelResponse<Generation>
- Returns:
- Returns the first
Generation
in the generations list.
-
getMetadata
Description copied from interface:ModelResponse
Retrieves the response metadata associated with the AI model's response.- Specified by:
getMetadata
in interfaceModelResponse<Generation>
- Returns:
- Returns
ChatResponseMetadata
containing information about the use of the AI provider's API.
-
hasToolCalls
public boolean hasToolCalls()Whether the model has requested the execution of a tool. -
toString
-
equals
-
hashCode
public int hashCode()
-