ModelInfo.fromJson constructor

ModelInfo.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory ModelInfo.fromJson(Map<String, dynamic> json) {
  return ModelInfo(
    id: json['id'] as String,
    name: json['name'] as String,
    category: ModelCategory.fromRawValue(json['category'] as String) ??
        ModelCategory.language,
    format: ModelFormat.fromRawValue(json['format'] as String? ?? 'unknown'),
    framework: InferenceFramework.fromRawValue(
        json['framework'] as String? ?? 'unknown'),
    downloadURL: json['downloadURL'] != null
        ? Uri.parse(json['downloadURL'] as String)
        : null,
    localPath: json['localPath'] != null
        ? Uri.parse(json['localPath'] as String)
        : null,
    artifactType: json['artifactType'] != null
        ? ModelArtifactType.fromJson(
            json['artifactType'] as Map<String, dynamic>)
        : null,
    downloadSize: json['downloadSize'] as int?,
    contextLength: json['contextLength'] as int?,
    supportsThinking: json['supportsThinking'] as bool? ?? false,
    thinkingPattern: json['thinkingPattern'] != null
        ? ThinkingTagPattern.fromJson(
            json['thinkingPattern'] as Map<String, dynamic>)
        : null,
    description: json['description'] as String?,
    source: ModelSource.fromRawValue(json['source'] as String? ?? 'remote'),
    createdAt: json['createdAt'] != null
        ? DateTime.parse(json['createdAt'] as String)
        : null,
    updatedAt: json['updatedAt'] != null
        ? DateTime.parse(json['updatedAt'] as String)
        : null,
  );
}