mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-12 07:45:14 -05:00
Restructuring the Repo to make it clear the difference between classic autogpt and the autogpt platform: * Move the "classic" projects `autogpt`, `forge`, `frontend`, and `benchmark` into a `classic` folder * Also rename `autogpt` to `original_autogpt` for absolute clarity * Rename `rnd/` to `autogpt_platform/` * `rnd/autogpt_builder` -> `autogpt_platform/frontend` * `rnd/autogpt_server` -> `autogpt_platform/backend` * Adjust any paths accordingly
52 lines
1.8 KiB
Dart
52 lines
1.8 KiB
Dart
import 'dart:async';
|
|
import 'package:auto_gpt_flutter_client/models/benchmark/benchmark_step_request_body.dart';
|
|
import 'package:auto_gpt_flutter_client/models/benchmark/benchmark_task_request_body.dart';
|
|
import 'package:auto_gpt_flutter_client/utils/rest_api_utility.dart';
|
|
import 'package:auto_gpt_flutter_client/models/benchmark/api_type.dart';
|
|
|
|
class BenchmarkService {
|
|
final RestApiUtility api;
|
|
|
|
BenchmarkService(this.api);
|
|
|
|
/// Creates a new benchmark task.
|
|
///
|
|
/// [benchmarkTaskRequestBody] is a Map representing the request body for creating a task.
|
|
Future<Map<String, dynamic>> createBenchmarkTask(
|
|
BenchmarkTaskRequestBody benchmarkTaskRequestBody) async {
|
|
try {
|
|
return await api.post('agent/tasks', benchmarkTaskRequestBody.toJson(),
|
|
apiType: ApiType.benchmark);
|
|
} catch (e) {
|
|
throw Exception('Failed to create a new task: $e');
|
|
}
|
|
}
|
|
|
|
/// Executes a step in a specific benchmark task.
|
|
///
|
|
/// [taskId] is the ID of the task.
|
|
/// [benchmarkStepRequestBody] is a Map representing the request body for executing a step.
|
|
Future<Map<String, dynamic>> executeBenchmarkStep(
|
|
String taskId, BenchmarkStepRequestBody benchmarkStepRequestBody) async {
|
|
try {
|
|
return await api.post(
|
|
'agent/tasks/$taskId/steps', benchmarkStepRequestBody.toJson(),
|
|
apiType: ApiType.benchmark);
|
|
} catch (e) {
|
|
throw Exception('Failed to execute step: $e');
|
|
}
|
|
}
|
|
|
|
/// Triggers an evaluation for a specific benchmark task.
|
|
///
|
|
/// [taskId] is the ID of the task.
|
|
Future<Map<String, dynamic>> triggerEvaluation(String taskId) async {
|
|
try {
|
|
return await api.post('agent/tasks/$taskId/evaluations', {},
|
|
apiType: ApiType.benchmark);
|
|
} catch (e) {
|
|
throw Exception('Failed to trigger evaluation: $e');
|
|
}
|
|
}
|
|
}
|