Package dev.langchain4j.data.message
Class AiMessage
java.lang.Object
dev.langchain4j.data.message.AiMessage
- All Implemented Interfaces:
ChatMessage
Represents a response message from an AI (language model).
The message can contain either a textual response or a request to execute one/multiple tool(s).
In the case of tool execution, the response to this message should be one/multiple
ToolExecutionResultMessage
.-
Constructor Summary
ConstructorDescriptionCreate a newAiMessage
with the given text.AiMessage
(String text, List<ToolExecutionRequest> toolExecutionRequests) Create a newAiMessage
with the given text and tool execution requests.AiMessage
(List<ToolExecutionRequest> toolExecutionRequests) Create a newAiMessage
with the given tool execution requests. -
Method Summary
Modifier and TypeMethodDescriptionstatic AiMessage
aiMessage
(ToolExecutionRequest... toolExecutionRequests) Create a newAiMessage
with the given tool execution requests.static AiMessage
Create a newAiMessage
with the given text.static AiMessage
aiMessage
(String text, List<ToolExecutionRequest> toolExecutionRequests) Create a newAiMessage
with the given text and tool execution requests.static AiMessage
aiMessage
(List<ToolExecutionRequest> toolExecutionRequests) Create a newAiMessage
with the given tool execution requests.boolean
static AiMessage
from
(ToolExecutionRequest... toolExecutionRequests) Create a newAiMessage
with the given tool execution requests.static AiMessage
Create a newAiMessage
with the given text.static AiMessage
from
(String text, List<ToolExecutionRequest> toolExecutionRequests) Create a newAiMessage
with the given text and tool execution requests.static AiMessage
from
(List<ToolExecutionRequest> toolExecutionRequests) Create a newAiMessage
with the given tool execution requests.int
hashCode()
boolean
Check if the message has ToolExecutionRequests.text()
Get the text of the message.Get the tool execution requests of the message.toString()
type()
The type of the message.
-
Constructor Details
-
AiMessage
Create a newAiMessage
with the given text.- Parameters:
text
- the text of the message.
-
AiMessage
Create a newAiMessage
with the given tool execution requests.- Parameters:
toolExecutionRequests
- the tool execution requests of the message.
-
AiMessage
Create a newAiMessage
with the given text and tool execution requests.- Parameters:
text
- the text of the message.toolExecutionRequests
- the tool execution requests of the message.
-
-
Method Details
-
text
Get the text of the message.- Specified by:
text
in interfaceChatMessage
- Returns:
- the text of the message.
-
toolExecutionRequests
Get the tool execution requests of the message.- Returns:
- the tool execution requests of the message.
-
hasToolExecutionRequests
public boolean hasToolExecutionRequests()Check if the message has ToolExecutionRequests.- Returns:
- true if the message has ToolExecutionRequests, false otherwise.
-
type
Description copied from interface:ChatMessage
The type of the message.- Specified by:
type
in interfaceChatMessage
- Returns:
- the type of the message
-
equals
-
hashCode
public int hashCode() -
toString
-
from
Create a newAiMessage
with the given text.- Parameters:
text
- the text of the message.- Returns:
- the new
AiMessage
.
-
from
Create a newAiMessage
with the given tool execution requests.- Parameters:
toolExecutionRequests
- the tool execution requests of the message.- Returns:
- the new
AiMessage
.
-
from
Create a newAiMessage
with the given tool execution requests.- Parameters:
toolExecutionRequests
- the tool execution requests of the message.- Returns:
- the new
AiMessage
.
-
from
Create a newAiMessage
with the given text and tool execution requests.- Parameters:
text
- the text of the message.toolExecutionRequests
- the tool execution requests of the message.- Returns:
- the new
AiMessage
.
-
aiMessage
Create a newAiMessage
with the given text.- Parameters:
text
- the text of the message.- Returns:
- the new
AiMessage
.
-
aiMessage
Create a newAiMessage
with the given tool execution requests.- Parameters:
toolExecutionRequests
- the tool execution requests of the message.- Returns:
- the new
AiMessage
.
-
aiMessage
Create a newAiMessage
with the given tool execution requests.- Parameters:
toolExecutionRequests
- the tool execution requests of the message.- Returns:
- the new
AiMessage
.
-
aiMessage
Create a newAiMessage
with the given text and tool execution requests.- Parameters:
text
- the text of the message.toolExecutionRequests
- the tool execution requests of the message.- Returns:
- the new
AiMessage
.
-