Class AiMessage
-
- All Implemented Interfaces:
-
dev.langchain4j.data.message.ChatMessage
public class AiMessage implements 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classAiMessage.Builder
-
Constructor Summary
Constructors Constructor Description AiMessage(String text)Create a new AiMessage with the given text. AiMessage(List<ToolExecutionRequest> toolExecutionRequests)Create a new AiMessage with the given tool execution requests. AiMessage(String text, List<ToolExecutionRequest> toolExecutionRequests)Create a new AiMessage with the given text and tool execution requests.
-
Method Summary
Modifier and Type Method Description Stringtext()Get the text of the message. List<ToolExecutionRequest>toolExecutionRequests()Get the tool execution requests of the message. booleanhasToolExecutionRequests()Check if the message has ToolExecutionRequests. ChatMessageTypetype()The type of the message. booleanequals(Object o)inthashCode()StringtoString()static AiMessage.Builderbuilder()static AiMessagefrom(String text)Create a new AiMessage with the given text. static AiMessagefrom(Array<ToolExecutionRequest> toolExecutionRequests)Create a new AiMessage with the given tool execution requests. static AiMessagefrom(List<ToolExecutionRequest> toolExecutionRequests)Create a new AiMessage with the given tool execution requests. static AiMessagefrom(String text, List<ToolExecutionRequest> toolExecutionRequests)Create a new AiMessage with the given text and tool execution requests. static AiMessageaiMessage(String text)Create a new AiMessage with the given text. static AiMessageaiMessage(Array<ToolExecutionRequest> toolExecutionRequests)Create a new AiMessage with the given tool execution requests. static AiMessageaiMessage(List<ToolExecutionRequest> toolExecutionRequests)Create a new AiMessage with the given tool execution requests. static AiMessageaiMessage(String text, List<ToolExecutionRequest> toolExecutionRequests)Create a new AiMessage with the given text and tool execution requests. -
-
Constructor Detail
-
AiMessage
AiMessage(String text)
Create a new AiMessage with the given text.- Parameters:
text- the text of the message.
-
AiMessage
AiMessage(List<ToolExecutionRequest> toolExecutionRequests)
Create a new AiMessage with the given tool execution requests.- Parameters:
toolExecutionRequests- the tool execution requests of the message.
-
AiMessage
AiMessage(String text, List<ToolExecutionRequest> toolExecutionRequests)
Create a new AiMessage with the given text and tool execution requests.- Parameters:
text- the text of the message.toolExecutionRequests- the tool execution requests of the message.
-
-
Method Detail
-
toolExecutionRequests
List<ToolExecutionRequest> toolExecutionRequests()
Get the tool execution requests of the message.
- Returns:
the tool execution requests of the message.
-
hasToolExecutionRequests
boolean hasToolExecutionRequests()
Check if the message has ToolExecutionRequests.
- Returns:
true if the message has ToolExecutionRequests, false otherwise.
-
type
ChatMessageType type()
The type of the message.
- Returns:
the type of the message
-
hashCode
int hashCode()
-
builder
static AiMessage.Builder builder()
-
from
static AiMessage from(String text)
Create a new AiMessage with the given text.
- Parameters:
text- the text of the message.- Returns:
the new AiMessage.
-
from
static AiMessage from(Array<ToolExecutionRequest> toolExecutionRequests)
Create a new AiMessage with the given tool execution requests.
- Parameters:
toolExecutionRequests- the tool execution requests of the message.- Returns:
the new AiMessage.
-
from
static AiMessage from(List<ToolExecutionRequest> toolExecutionRequests)
Create a new AiMessage with the given tool execution requests.
- Parameters:
toolExecutionRequests- the tool execution requests of the message.- Returns:
the new AiMessage.
-
from
static AiMessage from(String text, List<ToolExecutionRequest> toolExecutionRequests)
Create a new AiMessage 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
static AiMessage aiMessage(String text)
Create a new AiMessage with the given text.
- Parameters:
text- the text of the message.- Returns:
the new AiMessage.
-
aiMessage
static AiMessage aiMessage(Array<ToolExecutionRequest> toolExecutionRequests)
Create a new AiMessage with the given tool execution requests.
- Parameters:
toolExecutionRequests- the tool execution requests of the message.- Returns:
the new AiMessage.
-
aiMessage
static AiMessage aiMessage(List<ToolExecutionRequest> toolExecutionRequests)
Create a new AiMessage with the given tool execution requests.
- Parameters:
toolExecutionRequests- the tool execution requests of the message.- Returns:
the new AiMessage.
-
aiMessage
static AiMessage aiMessage(String text, List<ToolExecutionRequest> toolExecutionRequests)
Create a new AiMessage 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.
-
-
-
-