fromMap static method
Implementation
static GptConfig fromMap(Map<String, dynamic> map) {
final Map<String, dynamic>? gpt = map['gpt'];
if (gpt == null) {
throw 'Missing gpt entry in config.';
}
final model = GptModel.values.firstWhereOrNull((e) => e.id == gpt['model']);
if (model == null) {
throw 'Unknown model: ${gpt['model']}\nAvailable models: ${GptModel.values.map((e) => e.id).join(', ')}';
}
final description = gpt['description'];
if (description == null) {
throw 'Missing description';
}
return GptConfig(
model: model,
description: description,
maxInputLength: gpt['max_input_length'] ?? model.defaultInputLength,
temperature: gpt['temperature']?.toDouble(),
excludes: (gpt['excludes'] as List?)
?.map((e) => I18nLocale.fromString(e))
.toList() ??
[],
);
}