mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 14:04:27 +01:00
This commit modifies the Ground class to make it more robust against optional or missing fields in the incoming JSON data. Default values have been added to ensure that the model can be instantiated even if some JSON fields are missing or set to null.
26 lines
694 B
Dart
26 lines
694 B
Dart
class Ground {
|
|
final String answer;
|
|
final List<String> shouldContain;
|
|
final List<String> shouldNotContain;
|
|
final List<String> files;
|
|
final Map<String, dynamic> eval;
|
|
|
|
Ground({
|
|
required this.answer,
|
|
required this.shouldContain,
|
|
required this.shouldNotContain,
|
|
required this.files,
|
|
required this.eval,
|
|
});
|
|
|
|
factory Ground.fromJson(Map<String, dynamic> json) {
|
|
return Ground(
|
|
answer: json['answer'] ?? "",
|
|
shouldContain: List<String>.from(json['should_contain'] ?? []),
|
|
shouldNotContain: List<String>.from(json['should_not_contain'] ?? []),
|
|
files: List<String>.from(json['files'] ?? []),
|
|
eval: json['eval'] ?? {},
|
|
);
|
|
}
|
|
}
|