AgentData.fromJson constructor

AgentData.fromJson(
  1. Object? j
)

Implementation

factory AgentData.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return AgentData(
    agents: switch (json['agents']) {
      null => {},
      Map<String, Object?> $1 => {
        for (final e in $1.entries)
          decodeString(e.key): AgentConfig.fromJson(e.value),
      },
      _ => throw const FormatException('"agents" is not an object'),
    },
    turns: switch (json['turns']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) ConversationTurn.fromJson(i)],
      _ => throw const FormatException('"turns" is not a list'),
    },
  );
}