ChatMessage class
A single message in a chat conversation.
Constructors
- ChatMessage.new({required ChatRole role, required MessageType messageType, required String content, String? name})
-
const
- ChatMessage.assistant(String content)
-
Create an assistant message
factory
-
ChatMessage.file({required ChatRole role, required FileMime mime, required List<
int> data, String content = ''}) -
Create a file message
factory
-
ChatMessage.image({required ChatRole role, required ImageMime mime, required List<
int> data, String content = ''}) -
Create an image message
factory
- ChatMessage.imageUrl({required ChatRole role, required String url, String content = ''})
-
Create an image URL message
factory
-
ChatMessage.pdf({required ChatRole role, required List<
int> data, String content = ''}) -
Create a PDF document message (convenience method)
factory
- ChatMessage.system(String content, {String? name})
-
Create a system message
factory
-
ChatMessage.toolResult({required List<
ToolCall> results, String content = ''}) -
Create a tool result message
factory
-
ChatMessage.toolUse({required List<
ToolCall> toolCalls, String content = ''}) -
Create a tool use message
factory
- ChatMessage.user(String content)
-
Create a user message
factory
Properties
- content → String
-
The text content of the message
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- messageType → MessageType
-
The type of the message (text, image, audio, video, etc)
final
- name → String?
-
Optional name for the participant (useful for system messages)
final
- role → ChatRole
-
The role of who sent this message (user or assistant)
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited