AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
Add Metrics class with serialization and documentation
hunteraraujo50ef7b31eb8a
diff --git a/frontend/lib/models/benchmark/metrics.dart b/frontend/lib/models/benchmark/metrics.dartnew file mode 100644index 0000000000..3f3da440f7--- /dev/null+++ b/frontend/lib/models/benchmark/metrics.dart@@ -0,0 +1,67 @@+/// `Metrics` holds key performance metrics related to a benchmark test run.+///+/// The class encapsulates various data points like difficulty, success rate,+/// whether the task was attempted, the percentage of success, and other performance metrics.+class Metrics {+ /// The perceived difficulty level of the test, usually represented as a string.+ final String difficulty;++ /// A boolean indicating whether the test was successful.+ final bool success;++ /// A boolean indicating whether the test was attempted.+ final bool attempted;++ /// The percentage of success in the test, represented as a double.+ final double successPercentage;++ /// The cost metric, can be any type depending on what is being measured (time, resources, etc.).+ /// It is dynamic to allow for various types.+ final dynamic cost;++ /// The total runtime of the test, represented as a string.+ final String runTime;++ /// Constructs a new `Metrics` instance.+ ///+ /// [difficulty]: The perceived difficulty level of the test.+ /// [success]: A boolean indicating the success status of the test.+ /// [attempted]: A boolean indicating if the test was attempted.+ /// [successPercentage]: The success rate as a percentage.+ /// [cost]: The cost metric for the test.+ /// [runTime]: The total runtime of the test.+ Metrics({+ required this.difficulty,+ required this.success,+ required this.attempted,+ required this.successPercentage,+ required this.cost,+ required this.runTime,+ });++ /// Creates a `Metrics` instance from a map.+ ///+ /// [json]: A map containing key-value pairs corresponding to `Metrics` fields.+ ///+ /// Returns a new `Metrics` populated with values from the map.+ factory Metrics.fromJson(Map<String, dynamic> json) => Metrics(+ difficulty: json['difficulty'],+ success: json['success'],+ attempted: json['attempted'],+ successPercentage: json['success_percentage'].toDouble(),+ cost: json['cost'],+ runTime: json['run_time'],+ );++ /// Converts the `Metrics` instance to a map.+ ///+ /// Returns a map containing key-value pairs corresponding to `Metrics` fields.+ Map<String, dynamic> toJson() => {+ 'difficulty': difficulty,+ 'success': success,+ 'attempted': attempted,+ 'success_percentage': successPercentage,+ 'cost': cost,+ 'run_time': runTime,+ };+}