copyWith method

AIMessage copyWith({
  1. AIRole? role,
  2. String? content,
  3. List<AIAttachment>? attachments,
  4. Map<String, dynamic>? metadata,
  5. List<AIToolCall>? toolCalls,
  6. String? toolCallId,
})

Creates a copy with modified fields.

Implementation

AIMessage copyWith({
  AIRole? role,
  String? content,
  List<AIAttachment>? attachments,
  Map<String, dynamic>? metadata,
  List<AIToolCall>? toolCalls,
  String? toolCallId,
}) {
  return AIMessage(
    role: role ?? this.role,
    content: content ?? this.content,
    attachments: attachments ?? this.attachments,
    metadata: metadata ?? this.metadata,
    toolCalls: toolCalls ?? this.toolCalls,
    toolCallId: toolCallId ?? this.toolCallId,
    timestamp: timestamp,
    id: id,
  );
}