mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-27 19:04:25 +01:00
Create Step Class to Model Step Information
This commit introduces the Step class to the codebase, designed to model the steps related to tasks. - Implemented Step class with both required and optional fields. - Provided a fromMap factory method for easy deserialization from API responses. - Ensured that optional fields are handled gracefully, providing default values where necessary. The addition of the Step class lays the foundation for more complex interactions with tasks, including the ability to handle steps with varying levels of information. This makes the application more flexible and robust when interfacing with the backend.
This commit is contained in:
49
lib/models/step.dart
Normal file
49
lib/models/step.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
// TODO: Refactor this to match which values are required and optional
|
||||
class Step {
|
||||
final String input;
|
||||
final Map<String, dynamic> additionalInput;
|
||||
final String taskId;
|
||||
final String stepId;
|
||||
final String name;
|
||||
final String status;
|
||||
final String output;
|
||||
final Map<String, dynamic> additionalOutput;
|
||||
final List<dynamic> artifacts;
|
||||
final bool isLast;
|
||||
|
||||
Step({
|
||||
required this.input,
|
||||
required this.additionalInput,
|
||||
required this.taskId,
|
||||
required this.stepId,
|
||||
required this.name,
|
||||
required this.status,
|
||||
required this.output,
|
||||
required this.additionalOutput,
|
||||
required this.artifacts,
|
||||
required this.isLast,
|
||||
});
|
||||
|
||||
factory Step.fromMap(Map<String, dynamic>? map) {
|
||||
if (map == null) {
|
||||
throw ArgumentError('Null map provided to Step.fromMap');
|
||||
}
|
||||
return Step(
|
||||
input: map['input'] ?? '',
|
||||
additionalInput: map['additional_input'] != null
|
||||
? Map<String, dynamic>.from(map['additional_input'])
|
||||
: {},
|
||||
taskId: map['task_id'] ?? '',
|
||||
stepId: map['step_id'] ?? '',
|
||||
name: map['name'] ?? '',
|
||||
status: map['status'] ?? '',
|
||||
output: map['output'] ?? '',
|
||||
additionalOutput: map['additional_output'] != null
|
||||
? Map<String, dynamic>.from(map['additional_output'])
|
||||
: {},
|
||||
artifacts:
|
||||
map['artifacts'] != null ? List<dynamic>.from(map['artifacts']) : [],
|
||||
isLast: map['is_last'] ?? false,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user