Conference session(会议议程)
议程卡片介绍分享主题、时间和地点,并为两位讲者提供详情入口。
loading
安装
bash
npm install @assistant-ui/generative-ui zod1
用法
将下方规格传给渲染器。提供 dispatch 可接收按钮或表单的动作载荷。演示只在本地显示操作反馈。
tsx
import { defaultGenerativeUILibrary, renderGenerativeUI } from "@assistant-ui/generative-ui/react";
renderGenerativeUI(spec, defaultGenerativeUILibrary, {
status: "done",
dispatch: (action) => {
// 将用户操作交给应用。
console.log(action);
},
});1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
规格
tsx
const spec = {
"$type": "Card",
"children": [
{
"$type": "Caption",
"$key": "kicker",
"value": "分会场 2 · AI 工程"
},
{
"$type": "Header",
"$key": "title",
"text": "构建可靠的智能体循环",
"size": "md"
},
{
"$type": "Text",
"$key": "description",
"value": "结合生产案例,讲解重试、工具调用验证和人工介入方式。",
"size": "sm",
"color": "secondary"
},
{
"$type": "Row",
"$key": "meta",
"gap": 3,
"children": [
{
"$type": "Caption",
"$key": "location",
"value": "B 厅"
},
{
"$type": "Caption",
"$key": "time",
"value": "14:30 至 15:15"
}
]
},
{
"$type": "Divider",
"$key": "divider"
},
{
"$type": "Row",
"$key": "speaker-1",
"justify": "between",
"align": "center",
"children": [
{
"$type": "Row",
"$key": "info",
"align": "center",
"children": [
{
"$type": "Image",
"$key": "avatar",
"src": "https://i.pravatar.cc/150?img=47",
"alt": "普丽娅·奈尔",
"size": "sm",
"round": true
},
{
"$type": "Col",
"$key": "text",
"gap": 0,
"children": [
{
"$type": "Text",
"$key": "name",
"value": "普丽娅·奈尔",
"weight": "medium"
},
{
"$type": "Caption",
"$key": "title",
"value": "Agentbase 资深工程师"
}
]
}
]
},
{
"$type": "Button",
"$key": "view",
"label": "查看",
"buttonStyle": "outline",
"$action": {
"type": "view_speaker",
"speakerId": "priya-nair"
}
}
]
},
{
"$type": "Row",
"$key": "speaker-2",
"justify": "between",
"align": "center",
"children": [
{
"$type": "Row",
"$key": "info",
"align": "center",
"children": [
{
"$type": "Image",
"$key": "avatar",
"src": "https://i.pravatar.cc/150?img=33",
"alt": "德文·布鲁克斯",
"size": "sm",
"round": true
},
{
"$type": "Col",
"$key": "text",
"gap": 0,
"children": [
{
"$type": "Text",
"$key": "name",
"value": "德文·布鲁克斯",
"weight": "medium"
},
{
"$type": "Caption",
"$key": "title",
"value": "Agentbase 创始工程师"
}
]
}
]
},
{
"$type": "Button",
"$key": "view",
"label": "查看",
"buttonStyle": "outline",
"$action": {
"type": "view_speaker",
"speakerId": "devon-brooks"
}
}
]
}
]
}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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146