AttachmentTool.fromJson constructor

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

Creates an AttachmentTool from JSON.

Implementation

factory AttachmentTool.fromJson(Map<String, dynamic> json) {
  final type = json['type'] as String;
  return switch (type) {
    'code_interpreter' => const CodeInterpreterAttachmentTool(),
    'file_search' => const FileSearchAttachmentTool(),
    _ => throw FormatException('Unknown tool type: $type'),
  };
}