AIAssistantRunFinishedEvent.fromMap constructor

AIAssistantRunFinishedEvent.fromMap(
  1. Map<String, dynamic> map
)

Implementation

factory AIAssistantRunFinishedEvent.fromMap(Map<String, dynamic> map) {
  if (map.isEmpty) {
    throw ArgumentError('The AI Assistant run finished event map is empty');
  }
  final base = AIAssistantBaseEvent.fromMap(map);
  final data = Map<String, dynamic>.from(map['data'] ?? <String, dynamic>{});

  return AIAssistantRunFinishedEvent(
    id: base.id,
    type: base.type,
    conversationId: base.conversationId,
    parentId: base.parentId,
    additionalProperties: base.additionalProperties,
    runId: data['runId'] is int
        ? data['runId']
        : int.tryParse(data['runId']?.toString() ?? ''),
    threadId: data['threadId']?.toString(),
  );
}