@webority/chat-react 0.88.1 → 0.90.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat-react.js +1 -1
- package/dist/guidance.json +214 -0
- package/dist/types/ChatMarkdown.meta.d.ts +31 -0
- package/dist/types/components/ActionCard.meta.d.ts +89 -0
- package/dist/types/components/ChatComposer.d.ts +3 -3
- package/dist/types/components/ChatComposer.meta.d.ts +40 -0
- package/dist/types/components/ChatConversationList.d.ts +1 -1
- package/dist/types/components/ChatConversationList.meta.d.ts +37 -0
- package/dist/types/components/ChatLauncher.d.ts +6 -6
- package/dist/types/components/ChatLauncher.meta.d.ts +50 -0
- package/dist/types/components/ChatMessage.meta.d.ts +153 -0
- package/dist/types/components/ChatPanel.d.ts +9 -10
- package/dist/types/components/ChatPanel.meta.d.ts +208 -0
- package/dist/types/components/ChatThread.d.ts +1 -1
- package/dist/types/components/ChatThread.meta.d.ts +131 -0
- package/dist/types/components/CitationChip.d.ts +2 -2
- package/dist/types/components/CitationChip.meta.d.ts +48 -0
- package/dist/types/components/ConfirmCard.d.ts +2 -2
- package/dist/types/components/ConfirmCard.meta.d.ts +43 -0
- package/dist/types/components/ReplyRating.d.ts +2 -2
- package/dist/types/components/ReplyRating.meta.d.ts +34 -0
- package/package.json +9 -7
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
export declare const meta: {
|
|
2
|
+
readonly name: "ChatMessage";
|
|
3
|
+
readonly marker: "ChatMessage";
|
|
4
|
+
readonly platforms: readonly ["web"];
|
|
5
|
+
readonly acceptsChildren: false;
|
|
6
|
+
readonly props: {
|
|
7
|
+
readonly turn: {
|
|
8
|
+
readonly type: "object";
|
|
9
|
+
readonly required: true;
|
|
10
|
+
readonly description: "The turn to show: the person's question and the assistant's answer.";
|
|
11
|
+
readonly fields: {
|
|
12
|
+
readonly id: {
|
|
13
|
+
readonly type: "string";
|
|
14
|
+
readonly required: true;
|
|
15
|
+
readonly description: "Local key for the turn; for a reopened conversation, the stored message's id.";
|
|
16
|
+
};
|
|
17
|
+
readonly question: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly required: true;
|
|
20
|
+
readonly description: "What the person asked. Left empty, no question bubble shows.";
|
|
21
|
+
};
|
|
22
|
+
readonly answer: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly required: true;
|
|
25
|
+
readonly description: "The answer shown: the streamed text so far, then the reply of record.";
|
|
26
|
+
};
|
|
27
|
+
readonly streaming: {
|
|
28
|
+
readonly type: "boolean";
|
|
29
|
+
readonly required: true;
|
|
30
|
+
readonly description: "True while the answer is still arriving.";
|
|
31
|
+
};
|
|
32
|
+
readonly step: {
|
|
33
|
+
readonly type: "string";
|
|
34
|
+
readonly required: false;
|
|
35
|
+
readonly description: "The name of the tool the assistant is running. Unset when none is.";
|
|
36
|
+
};
|
|
37
|
+
readonly error: {
|
|
38
|
+
readonly type: "object";
|
|
39
|
+
readonly required: false;
|
|
40
|
+
readonly description: "Set when the turn failed; its message shows in an alert.";
|
|
41
|
+
readonly fields: {
|
|
42
|
+
readonly code: {
|
|
43
|
+
readonly type: "string";
|
|
44
|
+
readonly required: true;
|
|
45
|
+
readonly description: "A short code for the failure.";
|
|
46
|
+
};
|
|
47
|
+
readonly message: {
|
|
48
|
+
readonly type: "string";
|
|
49
|
+
readonly required: true;
|
|
50
|
+
readonly description: "Written for the person.";
|
|
51
|
+
};
|
|
52
|
+
readonly resetsAtUtc: {
|
|
53
|
+
readonly type: "string";
|
|
54
|
+
readonly required: false;
|
|
55
|
+
readonly description: "When a limit resets, as an ISO time.";
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
readonly actions: {
|
|
60
|
+
readonly type: "array";
|
|
61
|
+
readonly required: true;
|
|
62
|
+
readonly description: "Support actions the assistant prepared for this turn.";
|
|
63
|
+
};
|
|
64
|
+
readonly messageId: {
|
|
65
|
+
readonly type: "string";
|
|
66
|
+
readonly required: false;
|
|
67
|
+
readonly description: "The stored reply's id. The rating needs it.";
|
|
68
|
+
};
|
|
69
|
+
readonly rating: {
|
|
70
|
+
readonly type: "enum";
|
|
71
|
+
readonly values: readonly ["Up", "Down"];
|
|
72
|
+
readonly required: false;
|
|
73
|
+
readonly description: "The rating already given to the reply.";
|
|
74
|
+
};
|
|
75
|
+
readonly ratingNote: {
|
|
76
|
+
readonly type: "string";
|
|
77
|
+
readonly required: false;
|
|
78
|
+
readonly description: "The note saved with the rating.";
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
readonly labels: {
|
|
83
|
+
readonly type: "object";
|
|
84
|
+
readonly required: false;
|
|
85
|
+
readonly description: "Replacements for the built-in wording, such as the labels for You, Assistant and Thinking.";
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
readonly examples: readonly [{
|
|
89
|
+
readonly id: "ChatMessage";
|
|
90
|
+
readonly title: "Default";
|
|
91
|
+
readonly props: {
|
|
92
|
+
readonly turn: {
|
|
93
|
+
readonly id: "t1";
|
|
94
|
+
readonly question: "Where is my order?";
|
|
95
|
+
readonly answer: "Your order ships today.";
|
|
96
|
+
readonly streaming: false;
|
|
97
|
+
readonly actions: readonly [];
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
readonly wrap: {
|
|
101
|
+
readonly component: "ul";
|
|
102
|
+
readonly props: {
|
|
103
|
+
readonly className: "list-unstyled mb-0";
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
}, {
|
|
107
|
+
readonly id: "ChatMessage.user";
|
|
108
|
+
readonly title: "Question only";
|
|
109
|
+
readonly props: {
|
|
110
|
+
readonly turn: {
|
|
111
|
+
readonly id: "message-user";
|
|
112
|
+
readonly question: "How do I turn on two-step sign-in?";
|
|
113
|
+
readonly answer: "";
|
|
114
|
+
readonly streaming: false;
|
|
115
|
+
readonly actions: readonly [];
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
readonly wrap: {
|
|
119
|
+
readonly component: "ul";
|
|
120
|
+
readonly props: {
|
|
121
|
+
readonly className: "list-unstyled mb-0";
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
}, {
|
|
125
|
+
readonly id: "ChatMessage.assistant";
|
|
126
|
+
readonly title: "Answer only";
|
|
127
|
+
readonly props: {
|
|
128
|
+
readonly turn: {
|
|
129
|
+
readonly id: "message-assistant";
|
|
130
|
+
readonly question: "";
|
|
131
|
+
readonly answer: "Open the security settings and choose two-step sign-in.";
|
|
132
|
+
readonly streaming: false;
|
|
133
|
+
readonly actions: readonly [];
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
readonly wrap: {
|
|
137
|
+
readonly component: "ul";
|
|
138
|
+
readonly props: {
|
|
139
|
+
readonly className: "list-unstyled mb-0";
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
}];
|
|
143
|
+
readonly usage: {
|
|
144
|
+
readonly when: readonly ["Show one question and its answer inside a chat thread.", "Draw a single stored or streaming turn on its own, such as in a history view."];
|
|
145
|
+
readonly whenNot: readonly [{
|
|
146
|
+
readonly text: "Showing the whole conversation, oldest turn first, with the newest text kept in view.";
|
|
147
|
+
readonly instead: "ChatThread";
|
|
148
|
+
}];
|
|
149
|
+
readonly do: readonly [];
|
|
150
|
+
readonly dont: readonly [];
|
|
151
|
+
readonly a11y: readonly ["The answer sits in a polite live region, so a screen reader reads it once it settles; it is marked busy while it streams.", "Visually hidden labels name who is speaking, taken from the You and Assistant labels.", "While the first text is awaited, a spinner carries the Thinking label."];
|
|
152
|
+
};
|
|
153
|
+
};
|
|
@@ -5,24 +5,23 @@
|
|
|
5
5
|
* while it is open, Escape closes it, and the question box takes focus when it opens.
|
|
6
6
|
*
|
|
7
7
|
* @param {object} props
|
|
8
|
-
* @param {ReturnType<typeof import('../useChat.js').useChat>} props.chat
|
|
8
|
+
* @param {ReturnType<typeof import('../useChat.js').useChat>} props.chat
|
|
9
9
|
* @param {boolean} props.open
|
|
10
10
|
* @param {() => void} props.onClose
|
|
11
|
-
* @param {import('react').ReactNode} [props.title]
|
|
12
|
-
* @param {string} [props.titleIcon="sparkles"]
|
|
13
|
-
* @param {import('react').ReactNode} [props.headerActions]
|
|
14
|
-
*
|
|
15
|
-
* @param {import('react').ReactNode} [props.
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {number} [props.
|
|
18
|
-
* @param {number} [props.allowanceThreshold=10] Show the questions left once this many or fewer remain.
|
|
11
|
+
* @param {import('react').ReactNode} [props.title]
|
|
12
|
+
* @param {string} [props.titleIcon="sparkles"]
|
|
13
|
+
* @param {import('react').ReactNode} [props.headerActions]
|
|
14
|
+
* @param {import('react').ReactNode} [props.empty]
|
|
15
|
+
* @param {import('react').ReactNode} [props.disclaimer]
|
|
16
|
+
* @param {number} [props.maxLength=4000]
|
|
17
|
+
* @param {number} [props.allowanceThreshold=10]
|
|
19
18
|
* @param {string} [props.width="440px"]
|
|
20
19
|
* @param {(href: string) => string|null|undefined} [props.resolveLink] See `ChatMarkdown`.
|
|
21
20
|
* @param {import('react').ElementType} [props.linkComponent] A router link (it receives `to`).
|
|
22
21
|
* @param {(token: string) => Promise<{ id: string, number: string }>} [props.confirmAction] Shows
|
|
23
22
|
* support action cards, e.g. `supportClient.confirmAction`.
|
|
24
23
|
* @param {(ticket: { id: string, number: string }) => void} [props.onViewTicket]
|
|
25
|
-
* @param {boolean} [props.rating=true]
|
|
24
|
+
* @param {boolean} [props.rating=true]
|
|
26
25
|
* @param {(turn: import('../useChat.js').ChatTurn, state: { streaming: boolean }) => import('react').ReactNode} [props.renderReply]
|
|
27
26
|
* Draws each assistant answer instead of `ChatMarkdown`; see `ChatMessage`.
|
|
28
27
|
* @param {Partial<typeof import('@webority/ui-elements/chat-core').DEFAULT_CHAT_LABELS>} [props.labels]
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
export declare const meta: {
|
|
2
|
+
readonly name: "ChatPanel";
|
|
3
|
+
readonly marker: "ChatPanel";
|
|
4
|
+
readonly platforms: readonly ["web"];
|
|
5
|
+
readonly acceptsChildren: false;
|
|
6
|
+
readonly props: {
|
|
7
|
+
readonly chat: {
|
|
8
|
+
readonly type: "object";
|
|
9
|
+
readonly required: true;
|
|
10
|
+
readonly description: "The chat state the panel shows; the app takes it from useChat. The kit draws a stand-in with these fields.";
|
|
11
|
+
readonly fields: {
|
|
12
|
+
readonly turns: {
|
|
13
|
+
readonly type: "array";
|
|
14
|
+
readonly required: true;
|
|
15
|
+
readonly description: "The conversation, oldest turn first.";
|
|
16
|
+
readonly itemFields: {
|
|
17
|
+
readonly id: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly required: true;
|
|
20
|
+
readonly description: "Local key for the turn.";
|
|
21
|
+
};
|
|
22
|
+
readonly question: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly required: true;
|
|
25
|
+
readonly description: "What the person asked.";
|
|
26
|
+
};
|
|
27
|
+
readonly answer: {
|
|
28
|
+
readonly type: "string";
|
|
29
|
+
readonly required: true;
|
|
30
|
+
readonly description: "The answer shown.";
|
|
31
|
+
};
|
|
32
|
+
readonly streaming: {
|
|
33
|
+
readonly type: "boolean";
|
|
34
|
+
readonly required: true;
|
|
35
|
+
readonly description: "True while the answer is still arriving.";
|
|
36
|
+
};
|
|
37
|
+
readonly step: {
|
|
38
|
+
readonly type: "string";
|
|
39
|
+
readonly required: false;
|
|
40
|
+
readonly description: "The tool the assistant is running.";
|
|
41
|
+
};
|
|
42
|
+
readonly error: {
|
|
43
|
+
readonly type: "object";
|
|
44
|
+
readonly required: false;
|
|
45
|
+
readonly description: "Set when the turn failed.";
|
|
46
|
+
readonly fields: {
|
|
47
|
+
readonly code: {
|
|
48
|
+
readonly type: "string";
|
|
49
|
+
readonly required: true;
|
|
50
|
+
readonly description: "A short code for the failure.";
|
|
51
|
+
};
|
|
52
|
+
readonly message: {
|
|
53
|
+
readonly type: "string";
|
|
54
|
+
readonly required: true;
|
|
55
|
+
readonly description: "Written for the person.";
|
|
56
|
+
};
|
|
57
|
+
readonly resetsAtUtc: {
|
|
58
|
+
readonly type: "string";
|
|
59
|
+
readonly required: false;
|
|
60
|
+
readonly description: "When a limit resets, as an ISO time.";
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
readonly actions: {
|
|
65
|
+
readonly type: "array";
|
|
66
|
+
readonly required: true;
|
|
67
|
+
readonly description: "Support actions prepared for the turn.";
|
|
68
|
+
};
|
|
69
|
+
readonly messageId: {
|
|
70
|
+
readonly type: "string";
|
|
71
|
+
readonly required: false;
|
|
72
|
+
readonly description: "The stored reply's id.";
|
|
73
|
+
};
|
|
74
|
+
readonly rating: {
|
|
75
|
+
readonly type: "enum";
|
|
76
|
+
readonly values: readonly ["Up", "Down"];
|
|
77
|
+
readonly required: false;
|
|
78
|
+
readonly description: "The rating given.";
|
|
79
|
+
};
|
|
80
|
+
readonly ratingNote: {
|
|
81
|
+
readonly type: "string";
|
|
82
|
+
readonly required: false;
|
|
83
|
+
readonly description: "The note saved with the rating.";
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
readonly messagesLeftToday: {
|
|
88
|
+
readonly type: "number";
|
|
89
|
+
readonly required: false;
|
|
90
|
+
readonly description: "Questions left today. Unset when not known.";
|
|
91
|
+
};
|
|
92
|
+
readonly loading: {
|
|
93
|
+
readonly type: "boolean";
|
|
94
|
+
readonly required: true;
|
|
95
|
+
readonly description: "True while a saved conversation loads.";
|
|
96
|
+
};
|
|
97
|
+
readonly streaming: {
|
|
98
|
+
readonly type: "boolean";
|
|
99
|
+
readonly required: true;
|
|
100
|
+
readonly description: "True while an answer is arriving.";
|
|
101
|
+
};
|
|
102
|
+
readonly loadError: {
|
|
103
|
+
readonly type: "object";
|
|
104
|
+
readonly required: false;
|
|
105
|
+
readonly description: "Set when a saved conversation failed to load.";
|
|
106
|
+
readonly fields: {
|
|
107
|
+
readonly message: {
|
|
108
|
+
readonly type: "string";
|
|
109
|
+
readonly required: true;
|
|
110
|
+
readonly description: "Written for the person.";
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
readonly open: {
|
|
117
|
+
readonly type: "boolean";
|
|
118
|
+
readonly required: true;
|
|
119
|
+
readonly description: "Whether the drawer is shown.";
|
|
120
|
+
};
|
|
121
|
+
readonly title: {
|
|
122
|
+
readonly type: "node";
|
|
123
|
+
readonly description: "The drawer title. Defaults to the panel title label.";
|
|
124
|
+
};
|
|
125
|
+
readonly titleIcon: {
|
|
126
|
+
readonly type: "string";
|
|
127
|
+
readonly default: "sparkles";
|
|
128
|
+
readonly description: "A library icon name shown before the title.";
|
|
129
|
+
};
|
|
130
|
+
readonly headerActions: {
|
|
131
|
+
readonly type: "node";
|
|
132
|
+
readonly description: "Extra header controls placed before New chat.";
|
|
133
|
+
};
|
|
134
|
+
readonly empty: {
|
|
135
|
+
readonly type: "node";
|
|
136
|
+
readonly description: "Shown before the first question.";
|
|
137
|
+
};
|
|
138
|
+
readonly disclaimer: {
|
|
139
|
+
readonly type: "node";
|
|
140
|
+
readonly description: "The footnote under the question box. Defaults to the disclaimer label.";
|
|
141
|
+
};
|
|
142
|
+
readonly maxLength: {
|
|
143
|
+
readonly type: "number";
|
|
144
|
+
readonly default: 4000;
|
|
145
|
+
readonly description: "The most characters a question may have.";
|
|
146
|
+
};
|
|
147
|
+
readonly allowanceThreshold: {
|
|
148
|
+
readonly type: "number";
|
|
149
|
+
readonly default: 10;
|
|
150
|
+
readonly description: "The questions left note shows once this many or fewer remain.";
|
|
151
|
+
};
|
|
152
|
+
readonly width: {
|
|
153
|
+
readonly type: "string";
|
|
154
|
+
readonly default: "440px";
|
|
155
|
+
readonly description: "The drawer width on wide screens.";
|
|
156
|
+
};
|
|
157
|
+
readonly rating: {
|
|
158
|
+
readonly type: "boolean";
|
|
159
|
+
readonly default: true;
|
|
160
|
+
readonly description: "Offer thumbs under stored replies.";
|
|
161
|
+
};
|
|
162
|
+
readonly labels: {
|
|
163
|
+
readonly type: "object";
|
|
164
|
+
readonly description: "Replacements for the built-in wording.";
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
readonly examples: readonly [{
|
|
168
|
+
readonly id: "ChatPanel";
|
|
169
|
+
readonly title: "Default";
|
|
170
|
+
readonly props: {
|
|
171
|
+
readonly chat: {
|
|
172
|
+
readonly turns: readonly [];
|
|
173
|
+
readonly messagesLeftToday: 8;
|
|
174
|
+
readonly loading: false;
|
|
175
|
+
readonly streaming: false;
|
|
176
|
+
};
|
|
177
|
+
readonly open: false;
|
|
178
|
+
};
|
|
179
|
+
}, {
|
|
180
|
+
readonly id: "ChatPanel.conversation";
|
|
181
|
+
readonly title: "With a conversation";
|
|
182
|
+
readonly props: {
|
|
183
|
+
readonly chat: {
|
|
184
|
+
readonly turns: readonly [{
|
|
185
|
+
readonly id: "demo-question";
|
|
186
|
+
readonly question: "How do I turn on two-step sign-in?";
|
|
187
|
+
readonly answer: "Open the security settings and choose two-step sign-in.";
|
|
188
|
+
readonly streaming: false;
|
|
189
|
+
readonly actions: readonly [];
|
|
190
|
+
}];
|
|
191
|
+
readonly messagesLeftToday: 8;
|
|
192
|
+
readonly loading: false;
|
|
193
|
+
readonly streaming: false;
|
|
194
|
+
};
|
|
195
|
+
readonly open: false;
|
|
196
|
+
};
|
|
197
|
+
}];
|
|
198
|
+
readonly usage: {
|
|
199
|
+
readonly when: readonly ["Offer the assistant as a drawer that opens from a launcher.", "Show the conversation, the question box, the questions left today and the footnote in one place."];
|
|
200
|
+
readonly whenNot: readonly [{
|
|
201
|
+
readonly text: "Showing only the conversation inside a page.";
|
|
202
|
+
readonly instead: "ChatThread";
|
|
203
|
+
}];
|
|
204
|
+
readonly do: readonly [];
|
|
205
|
+
readonly dont: readonly [];
|
|
206
|
+
readonly a11y: readonly ["Focus stays inside the drawer while it is open, Escape closes it, and the question box takes focus when it opens.", "The drawer is named by its title.", "The questions left note is a status region."];
|
|
207
|
+
};
|
|
208
|
+
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @param {object} props
|
|
6
6
|
* @param {import('../useChat.js').ChatTurn[]} props.turns
|
|
7
|
-
* @param {import('react').ReactNode} [props.empty]
|
|
7
|
+
* @param {import('react').ReactNode} [props.empty]
|
|
8
8
|
* @param {(turnId: string, rating: "Up"|"Down", note?: string) => Promise<unknown>} [props.onRate]
|
|
9
9
|
* @param {(href: string) => string|null|undefined} [props.resolveLink]
|
|
10
10
|
* @param {import('react').ElementType} [props.linkComponent]
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
export declare const meta: {
|
|
2
|
+
readonly name: "ChatThread";
|
|
3
|
+
readonly marker: "ChatThread";
|
|
4
|
+
readonly platforms: readonly ["web"];
|
|
5
|
+
readonly acceptsChildren: false;
|
|
6
|
+
readonly props: {
|
|
7
|
+
readonly turns: {
|
|
8
|
+
readonly type: "array";
|
|
9
|
+
readonly required: true;
|
|
10
|
+
readonly description: "The conversation, oldest turn first. With none, the empty state shows.";
|
|
11
|
+
readonly itemFields: {
|
|
12
|
+
readonly id: {
|
|
13
|
+
readonly type: "string";
|
|
14
|
+
readonly required: true;
|
|
15
|
+
readonly description: "Local key for the turn.";
|
|
16
|
+
};
|
|
17
|
+
readonly question: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly required: true;
|
|
20
|
+
readonly description: "What the person asked.";
|
|
21
|
+
};
|
|
22
|
+
readonly answer: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly required: true;
|
|
25
|
+
readonly description: "The answer shown: the streamed text so far, then the reply of record.";
|
|
26
|
+
};
|
|
27
|
+
readonly streaming: {
|
|
28
|
+
readonly type: "boolean";
|
|
29
|
+
readonly required: true;
|
|
30
|
+
readonly description: "True while the answer is still arriving.";
|
|
31
|
+
};
|
|
32
|
+
readonly step: {
|
|
33
|
+
readonly type: "string";
|
|
34
|
+
readonly required: false;
|
|
35
|
+
readonly description: "The name of the tool the assistant is running. Unset when none is.";
|
|
36
|
+
};
|
|
37
|
+
readonly error: {
|
|
38
|
+
readonly type: "object";
|
|
39
|
+
readonly required: false;
|
|
40
|
+
readonly description: "Set when the turn failed.";
|
|
41
|
+
readonly fields: {
|
|
42
|
+
readonly code: {
|
|
43
|
+
readonly type: "string";
|
|
44
|
+
readonly required: true;
|
|
45
|
+
readonly description: "A short code for the failure.";
|
|
46
|
+
};
|
|
47
|
+
readonly message: {
|
|
48
|
+
readonly type: "string";
|
|
49
|
+
readonly required: true;
|
|
50
|
+
readonly description: "Written for the person.";
|
|
51
|
+
};
|
|
52
|
+
readonly resetsAtUtc: {
|
|
53
|
+
readonly type: "string";
|
|
54
|
+
readonly required: false;
|
|
55
|
+
readonly description: "When a limit resets, as an ISO time.";
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
readonly actions: {
|
|
60
|
+
readonly type: "array";
|
|
61
|
+
readonly required: true;
|
|
62
|
+
readonly description: "Support actions the assistant prepared for this turn.";
|
|
63
|
+
};
|
|
64
|
+
readonly messageId: {
|
|
65
|
+
readonly type: "string";
|
|
66
|
+
readonly required: false;
|
|
67
|
+
readonly description: "The stored reply's id. The rating needs it.";
|
|
68
|
+
};
|
|
69
|
+
readonly rating: {
|
|
70
|
+
readonly type: "enum";
|
|
71
|
+
readonly values: readonly ["Up", "Down"];
|
|
72
|
+
readonly required: false;
|
|
73
|
+
readonly description: "The rating already given to the reply.";
|
|
74
|
+
};
|
|
75
|
+
readonly ratingNote: {
|
|
76
|
+
readonly type: "string";
|
|
77
|
+
readonly required: false;
|
|
78
|
+
readonly description: "The note saved with the rating.";
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
readonly empty: {
|
|
83
|
+
readonly type: "node";
|
|
84
|
+
readonly required: false;
|
|
85
|
+
readonly description: "Shown when there are no turns; defaults to a short How can I help state.";
|
|
86
|
+
};
|
|
87
|
+
readonly labels: {
|
|
88
|
+
readonly type: "object";
|
|
89
|
+
readonly required: false;
|
|
90
|
+
readonly description: "Replacements for the built-in wording, such as the thread name and the empty-state text.";
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
readonly examples: readonly [{
|
|
94
|
+
readonly id: "ChatThread";
|
|
95
|
+
readonly title: "Default";
|
|
96
|
+
readonly props: {
|
|
97
|
+
readonly turns: readonly [{
|
|
98
|
+
readonly id: "t-1";
|
|
99
|
+
readonly question: "What is due?";
|
|
100
|
+
readonly answer: "Two invoices.";
|
|
101
|
+
readonly streaming: false;
|
|
102
|
+
readonly actions: readonly [];
|
|
103
|
+
}, {
|
|
104
|
+
readonly id: "t-2";
|
|
105
|
+
readonly question: "And next?";
|
|
106
|
+
readonly answer: "One more.";
|
|
107
|
+
readonly streaming: false;
|
|
108
|
+
readonly actions: readonly [];
|
|
109
|
+
}];
|
|
110
|
+
};
|
|
111
|
+
}, {
|
|
112
|
+
readonly id: "ChatThread.empty";
|
|
113
|
+
readonly title: "No turns yet";
|
|
114
|
+
readonly props: {
|
|
115
|
+
readonly turns: readonly [];
|
|
116
|
+
};
|
|
117
|
+
}];
|
|
118
|
+
readonly usage: {
|
|
119
|
+
readonly when: readonly ["Show a whole conversation, oldest turn first, in a panel or a page.", "Let the thread follow the newest text as an answer streams."];
|
|
120
|
+
readonly whenNot: readonly [{
|
|
121
|
+
readonly text: "Showing one turn on its own.";
|
|
122
|
+
readonly instead: "ChatMessage";
|
|
123
|
+
}, {
|
|
124
|
+
readonly text: "Showing the full assistant drawer with its header and question box.";
|
|
125
|
+
readonly instead: "ChatPanel";
|
|
126
|
+
}];
|
|
127
|
+
readonly do: readonly [];
|
|
128
|
+
readonly dont: readonly [];
|
|
129
|
+
readonly a11y: readonly ["The turns are an ordered list named by the thread label.", "Each answer is a polite live region; see ChatMessage.", "Only the nearest box that scrolls on its own follows the newest text, so the page itself never jumps."];
|
|
130
|
+
};
|
|
131
|
+
};
|
|
@@ -17,8 +17,8 @@ export declare function splitCitations(text: string, isCitation: (inner: string)
|
|
|
17
17
|
*
|
|
18
18
|
* @param {object} props
|
|
19
19
|
* @param {string} props.citation
|
|
20
|
-
* @param {string} [props.label]
|
|
21
|
-
* @param {string} [props.ariaLabel]
|
|
20
|
+
* @param {string} [props.label]
|
|
21
|
+
* @param {string} [props.ariaLabel]
|
|
22
22
|
* @param {(citation: string) => void} props.onOpen
|
|
23
23
|
*/
|
|
24
24
|
export default function CitationChip({ citation, label, ariaLabel, onOpen }: {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export declare const meta: {
|
|
2
|
+
readonly name: "CitationChip";
|
|
3
|
+
readonly marker: any;
|
|
4
|
+
readonly platforms: readonly ["web"];
|
|
5
|
+
readonly acceptsChildren: false;
|
|
6
|
+
readonly props: {
|
|
7
|
+
readonly citation: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly required: true;
|
|
10
|
+
readonly description: "The source the assistant named in its reply, written as [inner] in the text. It is the chip's text and its accessible name unless label or ariaLabel replace them.";
|
|
11
|
+
};
|
|
12
|
+
readonly label: {
|
|
13
|
+
readonly type: "string";
|
|
14
|
+
readonly required: false;
|
|
15
|
+
readonly description: "Text on the chip. Defaults to the citation.";
|
|
16
|
+
};
|
|
17
|
+
readonly ariaLabel: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly required: false;
|
|
20
|
+
readonly description: "Accessible label for the chip. Defaults to the citation.";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
readonly examples: readonly [{
|
|
24
|
+
readonly id: "CitationChip";
|
|
25
|
+
readonly title: "Default";
|
|
26
|
+
readonly props: {
|
|
27
|
+
readonly citation: "Clause 4.2";
|
|
28
|
+
};
|
|
29
|
+
}, {
|
|
30
|
+
readonly id: "CitationChip.label";
|
|
31
|
+
readonly title: "With a label";
|
|
32
|
+
readonly props: {
|
|
33
|
+
readonly citation: "Table 1";
|
|
34
|
+
readonly label: "Table 1, page 3";
|
|
35
|
+
readonly ariaLabel: "Open Table 1";
|
|
36
|
+
};
|
|
37
|
+
}];
|
|
38
|
+
readonly usage: {
|
|
39
|
+
readonly when: readonly ["Show a source the assistant named in a reply as a small chip the person can select to open it.", "Pair it with splitCitations to turn [source] runs in reply text into chips."];
|
|
40
|
+
readonly whenNot: readonly [{
|
|
41
|
+
readonly text: "Showing a general label or removable token that is not a source.";
|
|
42
|
+
readonly instead: "AppChip";
|
|
43
|
+
}];
|
|
44
|
+
readonly do: readonly [];
|
|
45
|
+
readonly dont: readonly [];
|
|
46
|
+
readonly a11y: readonly ["The chip is a button named by ariaLabel, or by the citation when none is given.", "Selecting it by pointer or keyboard calls onOpen with the citation."];
|
|
47
|
+
};
|
|
48
|
+
};
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* @param {object} props
|
|
7
7
|
* @param {string} props.title
|
|
8
8
|
* @param {string} [props.subtitle]
|
|
9
|
-
* @param {string[]} [props.lines]
|
|
10
|
-
* @param {string} [props.note]
|
|
9
|
+
* @param {string[]} [props.lines]
|
|
10
|
+
* @param {string} [props.note]
|
|
11
11
|
* @param {() => Promise<{ message?: string } | void>} props.onConfirm Sends the person's yes; resolves to
|
|
12
12
|
* an optional message for the done state. A rejection's `message` is shown when present.
|
|
13
13
|
* @param {Partial<typeof import('@webority/ui-elements/chat-core').DEFAULT_CHAT_LABELS>} [props.labels]
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare const meta: {
|
|
2
|
+
readonly name: "ConfirmCard";
|
|
3
|
+
readonly marker: any;
|
|
4
|
+
readonly platforms: readonly ["web"];
|
|
5
|
+
readonly acceptsChildren: false;
|
|
6
|
+
readonly props: {
|
|
7
|
+
readonly title: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly required: true;
|
|
10
|
+
readonly description: "The action the assistant prepared, written as what happens when the person confirms.";
|
|
11
|
+
};
|
|
12
|
+
readonly subtitle: {
|
|
13
|
+
readonly type: "string";
|
|
14
|
+
readonly description: "A line under the title that says more about the action.";
|
|
15
|
+
};
|
|
16
|
+
readonly lines: {
|
|
17
|
+
readonly type: "array";
|
|
18
|
+
readonly description: "One paragraph per entry, shown above the note.";
|
|
19
|
+
};
|
|
20
|
+
readonly note: {
|
|
21
|
+
readonly type: "string";
|
|
22
|
+
readonly description: "Replaces the default line saying nothing is sent until the person confirms.";
|
|
23
|
+
};
|
|
24
|
+
readonly labels: {
|
|
25
|
+
readonly type: "object";
|
|
26
|
+
readonly description: "Replaces any of the chat texts the card shows, such as the confirm and not now button texts and the done message.";
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
readonly examples: readonly [{
|
|
30
|
+
readonly id: "ConfirmCard";
|
|
31
|
+
readonly title: "Default";
|
|
32
|
+
readonly props: {
|
|
33
|
+
readonly title: "Copy assessment";
|
|
34
|
+
};
|
|
35
|
+
}];
|
|
36
|
+
readonly usage: {
|
|
37
|
+
readonly when: readonly ["The assistant has prepared an action and nothing should happen until the person says yes.", "The action is one step the person can send now or decline."];
|
|
38
|
+
readonly whenNot: readonly [];
|
|
39
|
+
readonly do: readonly [];
|
|
40
|
+
readonly dont: readonly [];
|
|
41
|
+
readonly a11y: readonly ["Confirm and Not now are native buttons, and Confirm shows its loading state while the action is sent.", "The done message is a status message.", "A failed confirm shows its message in an alert above the buttons and returns the card to ready."];
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* that saves the same rating again with the note. Either choice can be changed.
|
|
4
4
|
*
|
|
5
5
|
* @param {object} props
|
|
6
|
-
* @param {"Up"|"Down"|null} [props.rating]
|
|
6
|
+
* @param {"Up"|"Down"|null} [props.rating]
|
|
7
7
|
* @param {(rating: "Up"|"Down", note?: string) => Promise<unknown>} props.onRate Rejects on failure.
|
|
8
|
-
* @param {number} [props.noteMaxLength
|
|
8
|
+
* @param {number} [props.noteMaxLength]
|
|
9
9
|
* @param {Partial<typeof import('@webority/ui-elements/chat-core').DEFAULT_CHAT_LABELS>} [props.labels]
|
|
10
10
|
*/
|
|
11
11
|
export default function ReplyRating({ rating, onRate, noteMaxLength, labels: labelOverrides }: {
|