RagModelPackManifest.fromJsonString constructor

RagModelPackManifest.fromJsonString(
  1. String source
)

Implementation

factory RagModelPackManifest.fromJsonString(String source) {
  try {
    final decoded = jsonDecode(source);
    if (decoded is! Map<String, dynamic>) {
      throw const RagModelPackException(
        RagModelPackErrorCode.invalidManifest,
        'The model-pack manifest must be a JSON object.',
      );
    }
    return RagModelPackManifest.fromJson(decoded);
  } on FormatException catch (_) {
    throw const RagModelPackException(
      RagModelPackErrorCode.invalidManifest,
      'The model-pack manifest is not valid JSON.',
    );
  }
}