Skip to content

Commit

Permalink
[ Edit, Add ] edited and updated docs of model model directory files …
Browse files Browse the repository at this point in the history
…code
  • Loading branch information
anasfik committed Nov 22, 2023
1 parent 85b4b6b commit a201cd8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
5 changes: 4 additions & 1 deletion lib/src/core/models/image/image/image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ export 'sub_models/data.dart';

@immutable
final class OpenAIImageModel {
/// The time the image was created.
/// The time the image was [created].
final DateTime created;

/// The data of the image.
final List<OpenAIImageData> data;

/// Weither the image have some [data].
bool get haveData => data.isNotEmpty;

@override
int get hashCode => created.hashCode ^ data.hashCode;

Expand Down
20 changes: 16 additions & 4 deletions lib/src/core/models/image/image/sub_models/data.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
import 'package:meta/meta.dart';

/// {@template openai_image_data_model}
/// This class is used to represent an OpenAI image data.
/// {@endtemplate}
@immutable
final class OpenAIImageData {
/// The URL of the image.
/// The [URL] of the image.
final String? url;

/// the [OpenAIImageResponseFormat] b64Json data
/// The [b64Json] data.
final String? b64Json;

///
/// The revised prompt.
final String? revisedPrompt;

/// Weither the image have a [URL] result.
bool get haveUrl => url != null;

/// Weither the image have a [b64Json] result.
bool get haveB64Json => b64Json != null;

/// Weither the image have a revised prompt.
bool get haveRevisedPrompt => revisedPrompt != null;

@override
int get hashCode => url.hashCode;
int get hashCode => url.hashCode ^ b64Json.hashCode ^ revisedPrompt.hashCode;

/// This class is used to represent an OpenAI image data.
const OpenAIImageData({
Expand Down
17 changes: 12 additions & 5 deletions lib/src/core/models/model/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@ import 'package:meta/meta.dart';

import 'sub_models/permission.dart';

/// {@template openai_model_model}
/// This class is used to represent an OpenAI model.
/// {@endtemplate}
@immutable
final class OpenAIModelModel {
/// The ID of the model.
/// The [id]entifier of the model.
final String id;

/// The name of the organization that owns the model.
final String ownedBy;

/// The permissions of the model.
/// The [permission]s of the model.
final List<OpenAIModelModelPermission>? permission;

/// Weither the model have at least one permission in [permission].
bool get havePermission => permission != null;

@override
int get hashCode => id.hashCode ^ ownedBy.hashCode;
int get hashCode => id.hashCode ^ ownedBy.hashCode ^ permission.hashCode;

/// This class is used to represent an OpenAI model.
/// {@macro openai_model_model}
const OpenAIModelModel({
required this.id,
required this.ownedBy,
Expand All @@ -43,7 +49,8 @@ final class OpenAIModelModel {
}

@override
String toString() => 'OpenAIModelModel(id: $id, ownedBy: $ownedBy)';
String toString() =>
'OpenAIModelModel(id: $id, ownedBy: $ownedBy, permission: $permission)';

@override
bool operator ==(covariant OpenAIModelModel other) {
Expand Down
7 changes: 5 additions & 2 deletions lib/src/core/models/model/sub_models/permission.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import 'package:meta/meta.dart';

/// {@template openai_model_model_permission}
/// This class is used to represent an OpenAI model permission.
/// {@endtemplate}
@immutable
final class OpenAIModelModelPermission {
/// The ID of the permission.
/// The [id]entifier of the permission.
final String? id;

/// The time the permission was created.
/// The time the permission was [created].
final DateTime? created;

/// Whether the permission allows the user to create engines.
Expand Down

0 comments on commit a201cd8

Please sign in to comment.