fromJson static method
Returns a new CreateClassificationRequest instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static CreateClassificationRequest? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
requiredKeys.forEach((key) {
assert(json.containsKey(key), 'Required key "CreateClassificationRequest[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "CreateClassificationRequest[$key]" has a null value in JSON.');
});
return true;
}());
return CreateClassificationRequest(
model: mapValueOfType<String>(json, r'model')!,
query: mapValueOfType<String>(json, r'query')!,
examples: json[r'examples'] is List
? (json[r'examples'] as List).map(
(e) => e == null ? null : (e as List).cast<String>()
).toList()
: null,
file: mapValueOfType<String>(json, r'file'),
labels: json[r'labels'] is List
? (json[r'labels'] as List).cast<String>()
: const [],
searchModel: mapValueOfType<String>(json, r'search_model') ?? 'ada',
temperature: json[r'temperature'] == null
? 0
: num.parse(json[r'temperature'].toString()),
logprobs: mapValueOfType<int>(json, r'logprobs'),
maxExamples: mapValueOfType<int>(json, r'max_examples') ?? 200,
logitBias: mapValueOfType<Object>(json, r'logit_bias'),
returnPrompt: mapValueOfType<bool>(json, r'return_prompt') ?? false,
returnMetadata: mapValueOfType<bool>(json, r'return_metadata') ?? false,
expand: Object.listFromJson(json[r'expand']) ?? const [],
user: mapValueOfType<String>(json, r'user'),
);
}
return null;
}