OpenAIChatCompletionChoiceModel.fromMap constructor
This is used to convert a Map<String, dynamic> object to a OpenAIChatCompletionChoiceModel object.
Implementation
factory OpenAIChatCompletionChoiceModel.fromMap(Map<String, dynamic> json) {
return OpenAIChatCompletionChoiceModel(
//! Here we use the [int.tryParse] method to convert the [String] to an [int] if it's possible, otherwise we use the [String] value.
index: json['index'] is int
? json['index']
: int.tryParse(json['index'].toString()) ?? json['index'],
message: OpenAIChatCompletionChoiceMessageModel.fromMap(json['message']),
finishReason: json['finish_reason'],
);
}