AIAssistantToolEndedEvent.fromMap constructor

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

Creates an instance from a map.

Implementation

factory AIAssistantToolEndedEvent.fromMap(Map<String, dynamic> map) {
  if (map.isEmpty) {
    throw ArgumentError('The AI Assistant tool ended event map is empty');
  }

  final base = AIAssistantBaseEvent.fromMap(map);
  final data = Map<String, dynamic>.from(map['data'] ?? <String, dynamic>{});

  return AIAssistantToolEndedEvent(
    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'] as String?,
    toolCallId: data['toolCallId'] as String?,
    toolCallName: data['toolCallName'] as String?,
    displayName: data['displayName'] as String?,
    executionText: data['executionText'] as String?,
    arguments: data['arguments'] as String?,
  );
}