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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AiMessageaiMessage(ToolExecutionRequest... toolExecutionRequests) Create a newAiMessagewith the given tool execution requests.static AiMessageCreate a newAiMessagewith the given text.static AiMessageaiMessage(List<ToolExecutionRequest> toolExecutionRequests) Create a newAiMessagewith the given tool execution requests.booleanstatic AiMessagefrom(ToolExecutionRequest... toolExecutionRequests) Create a newAiMessagewith the given tool execution requests.static AiMessageCreate a newAiMessagewith the given text.static AiMessagefrom(List<ToolExecutionRequest> toolExecutionRequests) Create a newAiMessagewith the given tool execution requests.inthashCode()booleanCheck 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
-
Method Details
-
text
Get the text of the message.- Specified by:
textin 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:ChatMessageThe type of the message.- Specified by:
typein interfaceChatMessage- Returns:
- the type of the message
-
equals
-
hashCode
public int hashCode() -
toString
-
from
Create a newAiMessagewith the given text.- Parameters:
text- the text of the message.- Returns:
- the new
AiMessage.
-
from
Create a newAiMessagewith the given tool execution requests.- Parameters:
toolExecutionRequests- the tool execution requests of the message.- Returns:
- the new
AiMessage.
-
from
Create a newAiMessagewith the given tool execution requests.- Parameters:
toolExecutionRequests- the tool execution requests of the message.- Returns:
- the new
AiMessage.
-
aiMessage
Create a newAiMessagewith the given text.- Parameters:
text- the text of the message.- Returns:
- the new
AiMessage.
-
aiMessage
Create a newAiMessagewith the given tool execution requests.- Parameters:
toolExecutionRequests- the tool execution requests of the message.- Returns:
- the new
AiMessage.
-
aiMessage
Create a newAiMessagewith the given tool execution requests.- Parameters:
toolExecutionRequests- the tool execution requests of the message.- Returns:
- the new
AiMessage.
-