diff --git a/lib/models/task.dart b/lib/models/task.dart index 970a9bf0..056ed468 100644 --- a/lib/models/task.dart +++ b/lib/models/task.dart @@ -1,10 +1,17 @@ /// Represents a task or topic the user wants to discuss with the agent. class Task { final String id; + final Map? additionalInput; + final List? artifacts; + String _title; - Task({required this.id, required String title}) - : assert(title.isNotEmpty, 'Title cannot be empty'), + Task({ + required this.id, + this.additionalInput, + this.artifacts, + required String title, + }) : assert(title.isNotEmpty, 'Title cannot be empty'), _title = title; String get title => _title; @@ -17,11 +24,24 @@ class Task { } } - // Convert a Map (usually from JSON) to a Task object +// Convert a Map (usually from JSON) to a Task object factory Task.fromMap(Map map) { + Map? additionalInput; + List? artifacts; + + if (map['additional_input'] != null) { + additionalInput = Map.from(map['additional_input']); + } + + if (map['artifacts'] != null) { + artifacts = List.from(map['artifacts'].map((e) => e.toString())); + } + return Task( - id: map['id'], - title: map['title'], + id: map['task_id'], + additionalInput: additionalInput, + artifacts: artifacts, + title: map['input'], ); }