public static class AIGuard.Message extends Object
Example usage:
// User prompt
var userPrompt = AIGuard.Message.message("user", "What's the weather like?");
// Assistant response with tool calls
var assistantWithTools = AIGuard.Message.assistant(
AIGuard.ToolCall.toolCall("call_123", "get_weather", "{\"location\": \"New York\"}")
);
// Tool response
var toolResponse = AIGuard.Message.tool("call_123", "Sunny, 75°F");
| Constructor and Description |
|---|
Message(String role,
String content,
List<AIGuard.ToolCall> toolCalls,
String toolCallId)
Creates a new message with the specified parameters.
|
| Modifier and Type | Method and Description |
|---|---|
static AIGuard.Message |
assistant(AIGuard.ToolCall... toolCalls)
Creates an assistant message with tool calls but no text content.
|
String |
getContent()
Returns the text content of the message.
|
String |
getRole()
Returns the role of the message sender.
|
String |
getToolCallId()
Returns the tool call ID that this message is responding to.
|
List<AIGuard.ToolCall> |
getToolCalls()
Returns the list of tool calls associated with this message.
|
static AIGuard.Message |
message(String role,
String content)
Creates a message with specified role and text content.
|
static AIGuard.Message |
tool(String toolCallId,
String content)
Creates a tool response message.
|
public Message(String role, String content, List<AIGuard.ToolCall> toolCalls, String toolCallId)
role - the role of the message sender (e.g., "user", "assistant", "system", "tool")content - the text content of the message, or null for assistant messages with only tool
callstoolCalls - list of tool calls associated with this message, or null if no tool callstoolCallId - the tool call ID this message is responding to, or null if not a tool
responsepublic String getRole()
public String getContent()
public List<AIGuard.ToolCall> getToolCalls()
public String getToolCallId()
public static AIGuard.Message message(String role, String content)
role - the role of the message sender (e.g., "user", "system")content - the text content of the messagepublic static AIGuard.Message tool(String toolCallId, String content)
toolCallId - the ID of the tool call this message is responding tocontent - the result or output from the tool executionpublic static AIGuard.Message assistant(AIGuard.ToolCall... toolCalls)
toolCalls - the tool calls the assistant wants to make