Package datadog.trace.api.aiguard
Class AIGuard.Message
java.lang.Object
datadog.trace.api.aiguard.AIGuard.Message
- Enclosing class:
AIGuard
Represents a message in an AI conversation. Messages can represent user prompts, assistant
responses, system messages, or tool outputs.
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AIGuard.Messageassistant(AIGuard.ToolCall... toolCalls) Creates an assistant message with tool calls but no text content.Returns the text content of the message.getRole()Returns the role of the message sender.Returns the tool call ID that this message is responding to.Returns the list of tool calls associated with this message.static AIGuard.MessageCreates a message with specified role and text content.static AIGuard.MessageCreates a tool response message.
-
Constructor Details
-
Message
Creates a new message with the specified parameters.- Parameters:
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 response
-
-
Method Details
-
getRole
Returns the role of the message sender.- Returns:
- the role (e.g., "user", "assistant", "system", "tool")
-
getContent
Returns the text content of the message.- Returns:
- the message content, or null for assistant messages with only tool calls
-
getToolCalls
Returns the list of tool calls associated with this message.- Returns:
- list of tool calls, or null if this message has no tool calls
-
getToolCallId
Returns the tool call ID that this message is responding to.- Returns:
- the tool call ID, or null if this is not a tool response message
-
message
Creates a message with specified role and text content.- Parameters:
role- the role of the message sender (e.g., "user", "system")content- the text content of the message- Returns:
- a new Message instance
-
tool
Creates a tool response message.- Parameters:
toolCallId- the ID of the tool call this message is responding tocontent- the result or output from the tool execution- Returns:
- a new Message instance with role "tool"
-
assistant
Creates an assistant message with tool calls but no text content.- Parameters:
toolCalls- the tool calls the assistant wants to make- Returns:
- a new Message instance with role "assistant" and no text content
-