AIMessage class
A single message in an AI conversation.
Constructors
-
AIMessage({required AIRole role, required String content, List<
AIAttachment> ? attachments, Map<String, dynamic> ? metadata, List<AIToolCall> ? toolCalls, String? toolCallId, DateTime? timestamp, String? id}) -
AIMessage.assistant(String content, {List<
AIToolCall> ? toolCalls}) -
Creates an assistant message (optionally with tool calls).
factory
-
AIMessage.fromJson(Map<
String, dynamic> json) -
factory
- AIMessage.system(String content)
-
Creates a system message.
factory
- AIMessage.toolResult(String toolCallId, String content)
-
Creates a tool result message.
factory
-
AIMessage.user(String content, {List<
AIAttachment> ? attachments}) -
Creates a user message.
factory
Properties
-
attachments
→ List<
AIAttachment> ? -
Optional attachments (images, audio, files).
final
- content → String
-
The text content of the message.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
Unique identifier for this message.
final
-
metadata
→ Map<
String, dynamic> ? -
Optional metadata for provider-specific data.
final
- role → AIRole
-
The role of the sender.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- timestamp → DateTime
-
When the message was created.
final
- toolCallId → String?
-
For 'tool' role: the specific ID of the tool call this message answers.
final
-
toolCalls
→ List<
AIToolCall> ? -
For 'assistant' role: a list of tool invocations requested by the model.
final
Methods
-
copyWith(
{AIRole? role, String? content, List< AIAttachment> ? attachments, Map<String, dynamic> ? metadata, List<AIToolCall> ? toolCalls, String? toolCallId}) → AIMessage - Creates a copy with modified fields.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited