/// REST API response mapping for a single LLM chat message.
class LlmChatMessageEntity {
  final String? id;
  final String role; // 'user' or 'assistant'
  final String content;
  final DateTime createdAt;

  const LlmChatMessageEntity({
    this.id,
    required this.role,
    required this.content,
    required this.createdAt,
  });

  factory LlmChatMessageEntity.fromJson(Map<String, dynamic> json) {
    return LlmChatMessageEntity(
      id: json['id'] as String?,
      role: json['role'] as String,
      content: json['content'] as String,
      createdAt: DateTime.parse(json['created_at'] as String),
    );
  }

  Map<String, dynamic> toJson() => {
        'role': role,
        'content': content,
        'created_at': createdAt.toUtc().toIso8601String(),
      };
}
