Class ChatMessage
java.lang.Object
com.codename1.ai.ChatMessage
A single turn in a chat conversation. Holds a
Role, one or more
MessageParts, and (for assistant turns) any ToolCalls the model
produced. Construct via the static helpers (user(String),
system(String), etc.) for the common case, or pass parts
directly for multi-modal messages.-
Constructor Summary
ConstructorsConstructorDescriptionChatMessage(Role role, List<MessagePart> parts) ChatMessage(Role role, List<MessagePart> parts, List<ToolCall> toolCalls, String name, String toolCallId) -
Method Summary
Modifier and TypeMethodDescriptionstatic ChatMessagegetName()getParts()getRole()getText()Convenience: concatenates the text of everyTextPart.static ChatMessagestatic ChatMessagetoolResult(String toolCallId, String resultJson) Builds a TOOL message wrapping the result of a previous tool call.static ChatMessagestatic ChatMessageuserWithImage(String text, ImagePart image) Builds a USER message containing both a text and image part -- the common multi-modal pattern.
-
Constructor Details
-
ChatMessage
-
ChatMessage
-
-
Method Details
-
system
-
user
-
assistant
-
userWithImage
Builds a USER message containing both a text and image part -- the common multi-modal pattern. -
toolResult
Builds a TOOL message wrapping the result of a previous tool call. -
getRole
-
getParts
-
getToolCalls
-
getName
-
getToolCallId
-
getText
-