CodeInterpreterOutput.fromJson constructor

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

Creates a CodeInterpreterOutput from JSON.

Implementation

factory CodeInterpreterOutput.fromJson(Map<String, dynamic> json) {
  final type = json['type'] as String;
  return switch (type) {
    'logs' => LogsOutput.fromJson(json),
    'image' => ImageOutput.fromJson(json),
    _ => throw FormatException('Unknown output type: $type'),
  };
}