feat(chat): add ToolResult and UiCard models
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'tool_result.g.dart';
|
||||
|
||||
/// 工具执行结果(给 AI 的原始数据)
|
||||
@JsonSerializable()
|
||||
class ToolResult {
|
||||
final String? eventId;
|
||||
final bool ok;
|
||||
final String? message;
|
||||
|
||||
ToolResult({this.eventId, this.ok = true, this.message});
|
||||
|
||||
factory ToolResult.fromJson(Map<String, dynamic> json) =>
|
||||
_$ToolResultFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$ToolResultToJson(this);
|
||||
}
|
||||
|
||||
/// UI 卡片 Schema(给 UI 渲染)
|
||||
@JsonSerializable()
|
||||
class UiCard {
|
||||
@JsonKey(name: 'type')
|
||||
final String cardType;
|
||||
|
||||
@JsonKey(name: 'version')
|
||||
final String? schemaVersion;
|
||||
|
||||
final Map<String, dynamic> data;
|
||||
final List<CardAction>? actions;
|
||||
|
||||
UiCard({
|
||||
required this.cardType,
|
||||
this.schemaVersion = 'v1',
|
||||
required this.data,
|
||||
this.actions,
|
||||
});
|
||||
|
||||
factory UiCard.fromJson(Map<String, dynamic> json) => _$UiCardFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$UiCardToJson(this);
|
||||
}
|
||||
|
||||
/// 卡片操作按钮
|
||||
@JsonSerializable()
|
||||
class CardAction {
|
||||
final String type;
|
||||
final String label;
|
||||
final String? target;
|
||||
final String? action;
|
||||
|
||||
CardAction({
|
||||
required this.type,
|
||||
required this.label,
|
||||
this.target,
|
||||
this.action,
|
||||
});
|
||||
|
||||
factory CardAction.fromJson(Map<String, dynamic> json) =>
|
||||
_$CardActionFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$CardActionToJson(this);
|
||||
}
|
||||
|
||||
/// 日历卡片数据
|
||||
@JsonSerializable()
|
||||
class CalendarCardData {
|
||||
final String id;
|
||||
final String title;
|
||||
final String? description;
|
||||
final String startAt;
|
||||
final String? endAt;
|
||||
final String? timezone;
|
||||
final String? location;
|
||||
final String? color;
|
||||
final String? sourceType;
|
||||
|
||||
CalendarCardData({
|
||||
required this.id,
|
||||
required this.title,
|
||||
this.description,
|
||||
required this.startAt,
|
||||
this.endAt,
|
||||
this.timezone,
|
||||
this.location,
|
||||
this.color,
|
||||
this.sourceType,
|
||||
});
|
||||
|
||||
factory CalendarCardData.fromJson(Map<String, dynamic> json) =>
|
||||
_$CalendarCardDataFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$CalendarCardDataToJson(this);
|
||||
}
|
||||
Reference in New Issue
Block a user