ChatResponse.fromJson constructor

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

Implementation

factory ChatResponse.fromJson(Map<String, dynamic> json) {
  return ChatResponse(
    id: json['id'] ?? '',
    model: json['model'] ?? '',
    usage: Usage.fromJson(json['usage'] ?? {}),
    choices: (json['choices'] as List?)
        ?.map((choice) => Choice.fromJson(choice))
        .toList() ?? [],
  );
}