Class AIMessage
public class AIMessage
extends Object
Represents a message in a conversation with an AI model.
AIMessage message = new AIMessage("user", "Summarize the sales report.");
-
Constructor Summary
Constructors
Initializes a new instance of the AIMessage class with the specified role and content.
-
Method Summary
Gets the content of the message.
Gets the role of the message.
void
Sets the content of the message.
void
Sets the role of the message.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
AIMessage
Initializes a new instance of the AIMessage class with the specified role and content.
AIMessage message = new AIMessage("system", "Return concise answers.");
- Parameters:
role - The role of the message. Common values: "system", "user"
content - The content of the message.
-
Method Details
-
getRole
Gets the role of the message. Common values: "system", "user"
AIMessage message = new AIMessage("user", "Translate this text.");
String role = message.getRole();
- Returns:
- The role of the message.
-
setRole
public void setRole(String role)
Sets the role of the message. Common values: "system", "user"
AIMessage message = new AIMessage("system", "Return JSON.");
message.setRole("user");
- Parameters:
role - The role of the message. Common values are "system" and "user".
-
getContent
Gets the content of the message.
AIMessage message = new AIMessage("user", "Classify this text.");
String content = message.getContent();
- Returns:
- The content of the message.
-
setContent
public void setContent(String content)
Sets the content of the message.
AIMessage message = new AIMessage("user", "Analyze revenue.");
message.setContent("Analyze expenses.");
- Parameters:
content - The message content.