class Agent { final String id; final String name; final String avatarUrl; final String description; final String tag; final bool isOnline; final String voice; final String welcomeMessage; final String systemPrompt; const Agent({ required this.id, required this.name, required this.avatarUrl, required this.description, required this.tag, required this.isOnline, required this.voice, required this.welcomeMessage, required this.systemPrompt, }); // 添加一个fromJson构造函数 factory Agent.fromJson(Map json) { return Agent( id: json['id'] as String, name: json['name'] as String, avatarUrl: json['avatarUrl'] as String, description: json['description'] as String, tag: json['tag'] as String, isOnline: json['isOnline'] as bool, voice: json['voice'] as String, welcomeMessage: json['welcomeMessage'] as String, systemPrompt: json['systemPrompt'] as String, ); } // 添加一个toJson方法 Map toJson() { return { 'id': id, 'name': name, 'avatarUrl': avatarUrl, 'description': description, 'tag': tag, 'isOnline': isOnline, 'voice': voice, 'welcomeMessage': welcomeMessage, 'systemPrompt': systemPrompt, }; } // 添加一个copyWith方法 Agent copyWith({ String? id, String? name, String? avatarUrl, String? description, String? tag, bool? isOnline, String? voice, String? welcomeMessage, String? systemPrompt, }) { return Agent( id: id ?? this.id, name: name ?? this.name, avatarUrl: avatarUrl ?? this.avatarUrl, description: description ?? this.description, tag: tag ?? this.tag, isOnline: isOnline ?? this.isOnline, voice: voice ?? this.voice, welcomeMessage: welcomeMessage ?? this.welcomeMessage, systemPrompt: systemPrompt ?? this.systemPrompt, ); } }