Package com.google.genkit.ai
Class Message
java.lang.Object
com.google.genkit.ai.Message
Message represents a message in a conversation with a generative AI model.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a part to the message content.static Message.Builderbuilder()Creates a builder for Message.getRole()getText()Returns the text content from all text parts.static MessageCreates a model message with text content.voidsetContent(List<Part> content) voidsetMetadata(Map<String, Object> metadata) voidstatic MessageCreates a system message with text content.static MessageCreates a tool message with content.static MessageCreates a user message with text content.
-
Constructor Details
-
Message
public Message()Default constructor. -
Message
Creates a message with the given role and content.- Parameters:
role- the message rolecontent- the content parts
-
-
Method Details
-
user
Creates a user message with text content.- Parameters:
text- the text content- Returns:
- a new user message
-
system
Creates a system message with text content.- Parameters:
text- the text content- Returns:
- a new system message
-
model
Creates a model message with text content.- Parameters:
text- the text content- Returns:
- a new model message
-
tool
Creates a tool message with content.- Parameters:
content- the content parts- Returns:
- a new tool message
-
getText
Returns the text content from all text parts.- Returns:
- the concatenated text
-
getRole
-
setRole
-
getContent
-
setContent
-
getMetadata
-
setMetadata
-
addPart
Adds a part to the message content.- Parameters:
part- the part to add- Returns:
- this message for chaining
-
builder
Creates a builder for Message.- Returns:
- a new builder
-