From 313b07ce4caf97415fbc32d134c3bf70e2949744 Mon Sep 17 00:00:00 2001 From: Anas Fikhi Date: Wed, 22 Nov 2023 03:41:57 +0100 Subject: [PATCH] [ Edit, Add ] edited and updated docs of moderation model directory files code --- lib/src/core/models/moderation/moderation.dart | 14 ++++++++++---- .../models/moderation/sub_models/catgeories.dart | 4 ++++ .../moderation/sub_models/catgeories_scores.dart | 3 +++ .../core/models/moderation/sub_models/result.dart | 5 ++++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/src/core/models/moderation/moderation.dart b/lib/src/core/models/moderation/moderation.dart index 3490a6a5..73980cb7 100644 --- a/lib/src/core/models/moderation/moderation.dart +++ b/lib/src/core/models/moderation/moderation.dart @@ -6,21 +6,27 @@ import 'sub_models/result.dart'; export 'sub_models/result.dart'; +/// {@template openai_moderation_model} +/// This class is used to represent an OpenAI moderation job. +/// {@endtemplate} @immutable final class OpenAIModerationModel { - /// The ID of the moderation job. + /// The [id]entifier of the moderation job. final String id; - /// The model used for moderation. + /// The [model] used for moderation. final String model; - /// The results of the moderation job. + /// The [results] of the moderation job. final List results; + /// Weither the moderation job have at least one result in [results]. + bool get haveResults => results.isNotEmpty; + @override int get hashCode => id.hashCode ^ model.hashCode ^ results.hashCode; - /// This class is used to represent an OpenAI moderation job. + /// {@macro openai_moderation_model} const OpenAIModerationModel({ required this.id, required this.model, diff --git a/lib/src/core/models/moderation/sub_models/catgeories.dart b/lib/src/core/models/moderation/sub_models/catgeories.dart index a68d551b..e61f357f 100644 --- a/lib/src/core/models/moderation/sub_models/catgeories.dart +++ b/lib/src/core/models/moderation/sub_models/catgeories.dart @@ -1,5 +1,8 @@ import 'package:meta/meta.dart'; +/// {@template openai_moderation_result_categories_model} +/// This class is used to represent an OpenAI moderation job result categories. +/// {@endtemplate} @immutable final class OpenAIModerationResultCategoriesModel { /// The hate category. @@ -56,6 +59,7 @@ final class OpenAIModerationResultCategoriesModel { /// Whether the moderation request is not safe or not. bool get isNotSafe => !isSafe; + @override int get hashCode { return hate.hashCode ^ diff --git a/lib/src/core/models/moderation/sub_models/catgeories_scores.dart b/lib/src/core/models/moderation/sub_models/catgeories_scores.dart index 38b27bcf..f0606236 100644 --- a/lib/src/core/models/moderation/sub_models/catgeories_scores.dart +++ b/lib/src/core/models/moderation/sub_models/catgeories_scores.dart @@ -1,5 +1,8 @@ import 'package:meta/meta.dart'; +/// {@template openai_moderation_result_scores_model} +/// This class is used to represent an OpenAI moderation job result scores. +/// {@endtemplate} @immutable final class OpenAIModerationResultScoresModel { /// The hate score of the moderation job. diff --git a/lib/src/core/models/moderation/sub_models/result.dart b/lib/src/core/models/moderation/sub_models/result.dart index b5ccaa1e..3b7bd7ef 100644 --- a/lib/src/core/models/moderation/sub_models/result.dart +++ b/lib/src/core/models/moderation/sub_models/result.dart @@ -6,6 +6,9 @@ import 'catgeories_scores.dart'; export 'catgeories.dart'; export 'catgeories_scores.dart'; +/// {@template openai_moderation_result_model} +/// This class is used to represent an OpenAI moderation job result. +/// {@endtemplate} @immutable final class OpenAIModerationResultModel { /// The categories of the moderation job. @@ -21,7 +24,7 @@ final class OpenAIModerationResultModel { int get hashCode => categories.hashCode ^ categoryScores.hashCode ^ flagged.hashCode; - /// This class is used to represent an OpenAI moderation job result. + /// {@macro openai_moderation_result_model} const OpenAIModerationResultModel({ required this.categories, required this.categoryScores,