Choice.fromJson constructor

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

Creates a Choice from a JSON map.

Implementation

factory Choice.fromJson(Map<String, dynamic> json) {
  print(json);
  return Choice(
    text: (json['message'] as Map<String, dynamic>)['content'] as String? ??
        'no-text',
    index: json['index'] as int,
    logprobs: json['logprobs'],
    finishReason: json['finish_reason'] as String?,
  );
}