File size: 1,580 Bytes
b225a21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// TODO: Refactor this to match which values are required and optional
import 'package:auto_gpt_flutter_client/models/artifact.dart';

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<Artifact> 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'] as List)
          .map(
              (artifact) => Artifact.fromJson(artifact as Map<String, dynamic>))
          .toList(),
      isLast: map['is_last'] ?? false,
    );
  }
}