Package io.agentscope.core.agui.model
Class AguiMessage
java.lang.Object
io.agentscope.core.agui.model.AguiMessage
Represents a message in the AG-UI protocol.
Messages are the primary communication unit in the AG-UI protocol. They contain content, role information, and optionally tool calls or tool call IDs.
Message roles:
- user - Messages from the user
- assistant - Messages from the AI assistant
- system - System instructions
- tool - Tool execution results
-
Constructor Summary
ConstructorsConstructorDescriptionAguiMessage(String id, String role, String content, List<AguiToolCall> toolCalls, String toolCallId) Creates a new AguiMessage. -
Method Summary
Modifier and TypeMethodDescriptionstatic AguiMessageassistantMessage(String id, String content) Creates a simple assistant message.booleanGet the message content.getId()Get the message ID.getRole()Get the message role.Get the tool call ID (for tool messages).Get the tool calls (for assistant messages).inthashCode()booleanCheck if this message has tool calls.booleanCheck if this is an assistant message.booleanCheck if this is a system message.booleanCheck if this is a tool message.booleanCheck if this is a user message.static AguiMessagesystemMessage(String id, String content) Creates a system message.static AguiMessagetoolMessage(String id, String toolCallId, String content) Creates a tool result message.toString()static AguiMessageuserMessage(String id, String content) Creates a simple user message.
-
Constructor Details
-
AguiMessage
public AguiMessage(String id, String role, String content, List<AguiToolCall> toolCalls, String toolCallId) Creates a new AguiMessage.- Parameters:
id- The unique message IDrole- The message role (user, assistant, system, tool)content- The message contenttoolCalls- Tool calls for assistant messages (optional)toolCallId- Tool call ID for tool messages (optional)
-
-
Method Details
-
userMessage
Creates a simple user message.- Parameters:
id- The message IDcontent- The message content- Returns:
- A new user message
-
assistantMessage
Creates a simple assistant message.- Parameters:
id- The message IDcontent- The message content- Returns:
- A new assistant message
-
systemMessage
Creates a system message.- Parameters:
id- The message IDcontent- The message content- Returns:
- A new system message
-
toolMessage
Creates a tool result message.- Parameters:
id- The message IDtoolCallId- The ID of the tool call this is responding tocontent- The tool result content- Returns:
- A new tool message
-
getId
Get the message ID.- Returns:
- The message ID
-
getRole
Get the message role.- Returns:
- The role (user, assistant, system, tool)
-
getContent
Get the message content.- Returns:
- The content, may be null
-
getToolCalls
Get the tool calls (for assistant messages).- Returns:
- The tool calls as an immutable list, empty if none
-
getToolCallId
Get the tool call ID (for tool messages).- Returns:
- The tool call ID, or null if not a tool message
-
isUserMessage
public boolean isUserMessage()Check if this is a user message.- Returns:
- true if role is "user"
-
isAssistantMessage
public boolean isAssistantMessage()Check if this is an assistant message.- Returns:
- true if role is "assistant"
-
isSystemMessage
public boolean isSystemMessage()Check if this is a system message.- Returns:
- true if role is "system"
-
isToolMessage
public boolean isToolMessage()Check if this is a tool message.- Returns:
- true if role is "tool"
-
hasToolCalls
public boolean hasToolCalls()Check if this message has tool calls.- Returns:
- true if tool calls are present
-
toString
-
equals
-
hashCode
public int hashCode()
-