You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.1 KiB

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? voiceWelcomeMessage;
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,
this.voiceWelcomeMessage,
required this.systemPrompt,
});
// 添加一个fromJson构造函数
factory Agent.fromJson(Map<String, dynamic> 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<String, dynamic> toJson() {
return {
'id': id,
'name': name,
'avatarUrl': avatarUrl,
'description': description,
'tag': tag,
'isOnline': isOnline,
'voice': voice,
'welcomeMessage': welcomeMessage,
'systemPrompt': systemPrompt,
'voiceWelcomeMessage': voiceWelcomeMessage,
};
}
// 添加一个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,
voiceWelcomeMessage: voiceWelcomeMessage ?? this.voiceWelcomeMessage,
);
}
}