agent_reply_service.dart
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/// 经营助手“回复数据源”统一契约。
///
/// 后续接入后台接口时,实现 [AgentReplyService] 并返回 [AgentReplyOutput],
/// 其中 `card` 使用与本地会话持久化一致的 JSON 结构(kind/title/items/followUps),
/// 页面即可无缝切换为后台真实数据,无需改动 UI 层。
class AgentReplyTurn {
const AgentReplyTurn({required this.role, required this.content});
/// user 或 assistant。
final String role;
final String content;
}
class AgentReplyRequest {
const AgentReplyRequest({
required this.storeId,
required this.storeName,
required this.question,
required this.history,
});
final String storeId;
final String storeName;
final String question;
/// 最近几轮对话,用于连续追问。
final List<AgentReplyTurn> history;
}
class AgentReplyOutput {
const AgentReplyOutput({
required this.intent,
required this.text,
this.card,
this.followUps = const <String>[],
});
/// 意图标识,便于日志与后续埋点。
final String intent;
/// 展示给用户的一句话/一段话回复。
final String text;
/// 结构化业务卡片,字段与 [AgentChatStore] 持久化格式一致:
/// `{kind, title, items, followUps}`。
final Map<String, dynamic>? card;
final List<String> followUps;
}
/// 后台回复服务接口(预留)。
///
/// 现阶段由页面内置的本地模拟逻辑兜底;后续实现
/// `BackendAgentReplyService` 调用门店经营接口即可替换。
abstract class AgentReplyService {
Future<AgentReplyOutput> reply(AgentReplyRequest request);
}