reachat 2.1.0-alpha.21 → 2.1.0-alpha.22
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/{CSVFileRenderer-GYEEFRXD.js → CSVFileRenderer-DC2ZhtNx.js} +2 -2
- package/dist/{CSVFileRenderer-GYEEFRXD.js.map → CSVFileRenderer-DC2ZhtNx.js.map} +1 -1
- package/dist/ChatInput/ChatInput.d.ts +9 -1
- package/dist/ChatInput/FileDropzone.d.ts +33 -0
- package/dist/ChatInput/FileInput.d.ts +0 -4
- package/dist/ChatInput/index.d.ts +1 -0
- package/dist/ChatSuggestions/ChatSuggestion.d.ts +9 -0
- package/dist/ChatSuggestions/ChatSuggestions.d.ts +22 -0
- package/dist/ChatSuggestions/index.d.ts +2 -0
- package/dist/{DefaultFileRenderer-CUcl0kc2.js → DefaultFileRenderer-3oHDLIk4.js} +2 -2
- package/dist/{DefaultFileRenderer-CUcl0kc2.js.map → DefaultFileRenderer-3oHDLIk4.js.map} +1 -1
- package/dist/MessageStatus/MessageStatus.d.ts +44 -0
- package/dist/MessageStatus/MessageStatusItem.d.ts +9 -0
- package/dist/MessageStatus/StatusIcon.d.ts +17 -0
- package/dist/MessageStatus/index.d.ts +3 -0
- package/dist/SessionMessages/SessionMessages.d.ts +4 -0
- package/dist/docs.json +555 -16
- package/dist/{index-CwH75cwk.js → index-CWCW-OiG.js} +471 -122
- package/dist/index-CWCW-OiG.js.map +1 -0
- package/dist/index.css +186 -55
- package/dist/index.d.ts +2 -0
- package/dist/index.js +30 -24
- package/dist/index.umd.cjs +444 -97
- package/dist/index.umd.cjs.map +1 -1
- package/dist/stories/ChatSuggestions.stories.tsx +542 -0
- package/dist/stories/Console.stories.tsx +101 -623
- package/dist/stories/Files.stories.tsx +348 -0
- package/dist/stories/Markdown.stories.tsx +108 -1
- package/dist/stories/MessageStatus.stories.tsx +326 -0
- package/dist/stories/SessionsList.stories.tsx +276 -0
- package/dist/stories/assets/sparkles.svg +7 -0
- package/dist/stories/examples.ts +34 -0
- package/dist/theme.d.ts +46 -0
- package/dist/types.d.ts +10 -0
- package/package.json +7 -4
- package/dist/index-CwH75cwk.js.map +0 -1
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { useState, useRef, FC, useContext } from 'react';
|
|
2
|
-
import AttachIcon from './assets/paperclip.svg?react';
|
|
1
|
+
import { useState, useRef, FC, useContext, useEffect } from 'react';
|
|
3
2
|
import { Meta } from '@storybook/react';
|
|
4
3
|
import {
|
|
5
4
|
Chat,
|
|
6
5
|
Session,
|
|
7
|
-
remarkCve,
|
|
8
6
|
SessionsList,
|
|
9
7
|
SessionsGroup,
|
|
10
8
|
SessionListItem,
|
|
@@ -17,6 +15,9 @@ import {
|
|
|
17
15
|
SessionMessagesHeader,
|
|
18
16
|
ChatContext,
|
|
19
17
|
SessionMessage,
|
|
18
|
+
MessageStatus,
|
|
19
|
+
MessageStatusStep,
|
|
20
|
+
MessageStatusState
|
|
20
21
|
} from 'reachat';
|
|
21
22
|
import {
|
|
22
23
|
Card,
|
|
@@ -29,7 +30,7 @@ import {
|
|
|
29
30
|
ListItem,
|
|
30
31
|
Menu
|
|
31
32
|
} from 'reablocks';
|
|
32
|
-
import {
|
|
33
|
+
import { subMinutes, subHours } from 'date-fns';
|
|
33
34
|
import MenuIcon from './assets/menu.svg?react';
|
|
34
35
|
import Placeholder from './assets/placeholder.svg?react';
|
|
35
36
|
import PlaceholderDark from './assets/placeholder-dark.svg?react';
|
|
@@ -40,11 +41,9 @@ import { MessageResponse } from 'reachat';
|
|
|
40
41
|
import { MessageSources } from 'reachat';
|
|
41
42
|
import {
|
|
42
43
|
fakeSessions,
|
|
43
|
-
fakeSessionsWithEmbeds,
|
|
44
44
|
sessionWithSources,
|
|
45
45
|
sessionsWithFiles,
|
|
46
|
-
sessionsWithPartialConversation
|
|
47
|
-
sessionWithCSVFiles
|
|
46
|
+
sessionsWithPartialConversation
|
|
48
47
|
} from './examples';
|
|
49
48
|
|
|
50
49
|
export default {
|
|
@@ -86,76 +85,6 @@ export const Basic = () => {
|
|
|
86
85
|
);
|
|
87
86
|
};
|
|
88
87
|
|
|
89
|
-
export const Embeds = () => {
|
|
90
|
-
return (
|
|
91
|
-
<div
|
|
92
|
-
className="dark:bg-(--color-background-basic-black) bg-(--color-background-basic-white)"
|
|
93
|
-
style={{
|
|
94
|
-
position: 'absolute',
|
|
95
|
-
top: 0,
|
|
96
|
-
left: 0,
|
|
97
|
-
right: 0,
|
|
98
|
-
bottom: 0,
|
|
99
|
-
padding: 20,
|
|
100
|
-
margin: 20,
|
|
101
|
-
borderRadius: 5
|
|
102
|
-
}}
|
|
103
|
-
>
|
|
104
|
-
<Chat
|
|
105
|
-
sessions={fakeSessionsWithEmbeds}
|
|
106
|
-
activeSessionId="1"
|
|
107
|
-
onDeleteSession={() => alert('delete!')}
|
|
108
|
-
>
|
|
109
|
-
<SessionsList>
|
|
110
|
-
<NewSessionButton />
|
|
111
|
-
<SessionGroups />
|
|
112
|
-
</SessionsList>
|
|
113
|
-
<SessionMessagePanel>
|
|
114
|
-
<SessionMessagesHeader />
|
|
115
|
-
<SessionMessages />
|
|
116
|
-
<ChatInput />
|
|
117
|
-
</SessionMessagePanel>
|
|
118
|
-
</Chat>
|
|
119
|
-
</div>
|
|
120
|
-
);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export const DefaultSession = () => {
|
|
124
|
-
return (
|
|
125
|
-
<div
|
|
126
|
-
className="dark:bg-(--color-background-basic-black) bg-(--color-background-basic-white)"
|
|
127
|
-
style={{
|
|
128
|
-
position: 'absolute',
|
|
129
|
-
top: 0,
|
|
130
|
-
left: 0,
|
|
131
|
-
right: 0,
|
|
132
|
-
bottom: 0,
|
|
133
|
-
padding: 20,
|
|
134
|
-
margin: 20,
|
|
135
|
-
borderRadius: 5
|
|
136
|
-
}}
|
|
137
|
-
>
|
|
138
|
-
<Chat
|
|
139
|
-
viewType="console"
|
|
140
|
-
sessions={fakeSessions}
|
|
141
|
-
activeSessionId="1"
|
|
142
|
-
onDeleteSession={() => alert('delete!')}
|
|
143
|
-
>
|
|
144
|
-
<SessionsList>
|
|
145
|
-
<NewSessionButton />
|
|
146
|
-
<SessionGroups />
|
|
147
|
-
</SessionsList>
|
|
148
|
-
|
|
149
|
-
<SessionMessagePanel>
|
|
150
|
-
<SessionMessagesHeader />
|
|
151
|
-
<SessionMessages />
|
|
152
|
-
<ChatInput />
|
|
153
|
-
</SessionMessagePanel>
|
|
154
|
-
</Chat>
|
|
155
|
-
</div>
|
|
156
|
-
);
|
|
157
|
-
};
|
|
158
|
-
|
|
159
88
|
export const Loading = () => {
|
|
160
89
|
return (
|
|
161
90
|
<div
|
|
@@ -193,67 +122,6 @@ export const Loading = () => {
|
|
|
193
122
|
);
|
|
194
123
|
};
|
|
195
124
|
|
|
196
|
-
export const FileUploads = () => {
|
|
197
|
-
const [sessions, setSessions] = useState(sessionsWithFiles);
|
|
198
|
-
const [selectedFile, setSelectedFile] = useState<File | null>(null);
|
|
199
|
-
|
|
200
|
-
return (
|
|
201
|
-
<div
|
|
202
|
-
className="dark:bg-(--color-background-basic-black) bg-(--color-background-basic-white)"
|
|
203
|
-
style={{
|
|
204
|
-
position: 'absolute',
|
|
205
|
-
top: 0,
|
|
206
|
-
left: 0,
|
|
207
|
-
right: 0,
|
|
208
|
-
bottom: 0,
|
|
209
|
-
padding: 20,
|
|
210
|
-
margin: 20,
|
|
211
|
-
borderRadius: 5
|
|
212
|
-
}}
|
|
213
|
-
>
|
|
214
|
-
<Chat
|
|
215
|
-
viewType="console"
|
|
216
|
-
sessions={sessions}
|
|
217
|
-
activeSessionId="session-files"
|
|
218
|
-
onSendMessage={(message) => setSessions((sessions) => {
|
|
219
|
-
const session = sessions[0];
|
|
220
|
-
|
|
221
|
-
setSelectedFile(null);
|
|
222
|
-
|
|
223
|
-
return [{
|
|
224
|
-
...session,
|
|
225
|
-
conversations: [
|
|
226
|
-
...session.conversations,
|
|
227
|
-
{
|
|
228
|
-
id: (Math.random() * 100).toString(),
|
|
229
|
-
createdAt: new Date(),
|
|
230
|
-
question: message,
|
|
231
|
-
...(selectedFile ? { files: [{
|
|
232
|
-
name: selectedFile.name,
|
|
233
|
-
size: selectedFile.size,
|
|
234
|
-
type: selectedFile.type,
|
|
235
|
-
}]} : [])
|
|
236
|
-
}
|
|
237
|
-
]
|
|
238
|
-
}];
|
|
239
|
-
})}
|
|
240
|
-
onFileUpload={setSelectedFile}
|
|
241
|
-
onDeleteSession={() => alert('delete!')}
|
|
242
|
-
>
|
|
243
|
-
<SessionsList>
|
|
244
|
-
<NewSessionButton />
|
|
245
|
-
<SessionGroups />
|
|
246
|
-
</SessionsList>
|
|
247
|
-
<SessionMessagePanel>
|
|
248
|
-
<SessionMessagesHeader />
|
|
249
|
-
<SessionMessages />
|
|
250
|
-
<ChatInput attachIcon={<AttachIcon className={cn({'text-green-500': selectedFile})} />} allowedFiles={['.pdf', '.docx']} />
|
|
251
|
-
</SessionMessagePanel>
|
|
252
|
-
</Chat>
|
|
253
|
-
</div>
|
|
254
|
-
);
|
|
255
|
-
};
|
|
256
|
-
|
|
257
125
|
export const DefaultInputValue = () => {
|
|
258
126
|
return (
|
|
259
127
|
<div
|
|
@@ -283,168 +151,7 @@ export const DefaultInputValue = () => {
|
|
|
283
151
|
<SessionMessagePanel>
|
|
284
152
|
<SessionMessagesHeader />
|
|
285
153
|
<SessionMessages />
|
|
286
|
-
<ChatInput />
|
|
287
|
-
</SessionMessagePanel>
|
|
288
|
-
</Chat>
|
|
289
|
-
</div>
|
|
290
|
-
);
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
export const UndeleteableSessions = () => {
|
|
294
|
-
return (
|
|
295
|
-
<div
|
|
296
|
-
className="dark:bg-(--color-background-basic-black) bg-(--color-background-basic-white)"
|
|
297
|
-
style={{
|
|
298
|
-
position: 'absolute',
|
|
299
|
-
top: 0,
|
|
300
|
-
left: 0,
|
|
301
|
-
right: 0,
|
|
302
|
-
bottom: 0,
|
|
303
|
-
padding: 20,
|
|
304
|
-
margin: 20,
|
|
305
|
-
borderRadius: 5
|
|
306
|
-
}}
|
|
307
|
-
>
|
|
308
|
-
<Chat viewType="console" sessions={fakeSessions} activeSessionId="1">
|
|
309
|
-
<SessionsList>
|
|
310
|
-
<NewSessionButton />
|
|
311
|
-
<SessionGroups>
|
|
312
|
-
{groups =>
|
|
313
|
-
groups.map(({ heading, sessions }) => (
|
|
314
|
-
<SessionsGroup heading={heading} key={heading}>
|
|
315
|
-
{sessions.map(s => (
|
|
316
|
-
<SessionListItem key={s.id} session={s} deletable={false} />
|
|
317
|
-
))}
|
|
318
|
-
</SessionsGroup>
|
|
319
|
-
))
|
|
320
|
-
}
|
|
321
|
-
</SessionGroups>
|
|
322
|
-
</SessionsList>
|
|
323
|
-
|
|
324
|
-
<SessionMessagePanel>
|
|
325
|
-
<SessionMessagesHeader />
|
|
326
|
-
<SessionMessages />
|
|
327
|
-
<ChatInput />
|
|
328
|
-
</SessionMessagePanel>
|
|
329
|
-
</Chat>
|
|
330
|
-
</div>
|
|
331
|
-
);
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
export const SessionGrouping = () => {
|
|
335
|
-
const createSessionWithDate = (
|
|
336
|
-
id: string,
|
|
337
|
-
title: string,
|
|
338
|
-
daysAgo: number
|
|
339
|
-
): Session => ({
|
|
340
|
-
id,
|
|
341
|
-
title,
|
|
342
|
-
createdAt: subDays(new Date(), daysAgo),
|
|
343
|
-
updatedAt: subDays(new Date(), daysAgo),
|
|
344
|
-
conversations: [
|
|
345
|
-
{
|
|
346
|
-
id: `${id}-1`,
|
|
347
|
-
question: 'Sample question',
|
|
348
|
-
response: 'Sample response',
|
|
349
|
-
createdAt: subDays(new Date(), daysAgo),
|
|
350
|
-
updatedAt: subDays(new Date(), daysAgo)
|
|
351
|
-
}
|
|
352
|
-
]
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
const sessionsWithVariousDates: Session[] = [
|
|
356
|
-
createSessionWithDate('1', 'Today Session', 0),
|
|
357
|
-
createSessionWithDate('2', 'Yesterday Session', 1),
|
|
358
|
-
createSessionWithDate('3', 'Yesterday Session 2', 1),
|
|
359
|
-
createSessionWithDate('4', 'Last Week Session', 6),
|
|
360
|
-
createSessionWithDate('5', 'Two Weeks Ago Session', 14),
|
|
361
|
-
createSessionWithDate('6', 'Last Month Session', 32),
|
|
362
|
-
createSessionWithDate('7', 'Two Months Ago Session', 65),
|
|
363
|
-
createSessionWithDate('8', 'Six Months Ago Session', 180),
|
|
364
|
-
createSessionWithDate('9', 'Last Year Session', 370),
|
|
365
|
-
createSessionWithDate('10', 'Two Years Ago Session', 740)
|
|
366
|
-
];
|
|
367
|
-
|
|
368
|
-
return (
|
|
369
|
-
<div
|
|
370
|
-
className="dark:bg-(--color-background-basic-black) bg-(--color-background-basic-white)"
|
|
371
|
-
style={{
|
|
372
|
-
position: 'absolute',
|
|
373
|
-
top: 0,
|
|
374
|
-
left: 0,
|
|
375
|
-
right: 0,
|
|
376
|
-
bottom: 0,
|
|
377
|
-
padding: 20,
|
|
378
|
-
margin: 20,
|
|
379
|
-
borderRadius: 5
|
|
380
|
-
}}
|
|
381
|
-
>
|
|
382
|
-
<Chat
|
|
383
|
-
viewType="console"
|
|
384
|
-
sessions={sessionsWithVariousDates}
|
|
385
|
-
isLoading={false}
|
|
386
|
-
onDeleteSession={() => {}}
|
|
387
|
-
>
|
|
388
|
-
<SessionsList>
|
|
389
|
-
<NewSessionButton />
|
|
390
|
-
<SessionGroups />
|
|
391
|
-
</SessionsList>
|
|
392
|
-
|
|
393
|
-
<SessionMessagePanel>
|
|
394
|
-
<SessionMessagesHeader />
|
|
395
|
-
<SessionMessages />
|
|
396
|
-
<ChatInput placeholder="Send a message" />
|
|
397
|
-
</SessionMessagePanel>
|
|
398
|
-
</Chat>
|
|
399
|
-
</div>
|
|
400
|
-
);
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
export const HundredSessions = () => {
|
|
404
|
-
const generateFakeSessions = (count: number): Session[] => {
|
|
405
|
-
return Array.from({ length: count }, (_, index) => ({
|
|
406
|
-
id: `session-${index + 1}`,
|
|
407
|
-
title: `Session ${index + 1}`,
|
|
408
|
-
createdAt: subDays(new Date(), index),
|
|
409
|
-
updatedAt: subDays(new Date(), index),
|
|
410
|
-
conversations: [
|
|
411
|
-
{
|
|
412
|
-
id: `conv-${index}-1`,
|
|
413
|
-
question: `Question for session ${index + 1}`,
|
|
414
|
-
response: `Response for session ${index + 1}`,
|
|
415
|
-
createdAt: subDays(new Date(), index),
|
|
416
|
-
updatedAt: subDays(new Date(), index)
|
|
417
|
-
}
|
|
418
|
-
]
|
|
419
|
-
}));
|
|
420
|
-
};
|
|
421
|
-
|
|
422
|
-
const hundredSessions = generateFakeSessions(100);
|
|
423
|
-
|
|
424
|
-
return (
|
|
425
|
-
<div
|
|
426
|
-
className="dark:bg-(--color-background-basic-black) bg-(--color-background-basic-white)"
|
|
427
|
-
style={{
|
|
428
|
-
position: 'absolute',
|
|
429
|
-
top: 0,
|
|
430
|
-
left: 0,
|
|
431
|
-
right: 0,
|
|
432
|
-
bottom: 0,
|
|
433
|
-
padding: 20,
|
|
434
|
-
margin: 20,
|
|
435
|
-
borderRadius: 5
|
|
436
|
-
}}
|
|
437
|
-
>
|
|
438
|
-
<Chat viewType="console" sessions={hundredSessions}>
|
|
439
|
-
<SessionsList>
|
|
440
|
-
<NewSessionButton />
|
|
441
|
-
<SessionGroups />
|
|
442
|
-
</SessionsList>
|
|
443
|
-
|
|
444
|
-
<SessionMessagePanel>
|
|
445
|
-
<SessionMessagesHeader />
|
|
446
|
-
<SessionMessages />
|
|
447
|
-
<ChatInput />
|
|
154
|
+
<ChatInput defaultValue="Hello, tell me more" />
|
|
448
155
|
</SessionMessagePanel>
|
|
449
156
|
</Chat>
|
|
450
157
|
</div>
|
|
@@ -498,252 +205,7 @@ export const HundredConversations = () => {
|
|
|
498
205
|
|
|
499
206
|
<SessionMessagePanel>
|
|
500
207
|
<SessionMessagesHeader />
|
|
501
|
-
<SessionMessages />
|
|
502
|
-
<ChatInput />
|
|
503
|
-
</SessionMessagePanel>
|
|
504
|
-
</Chat>
|
|
505
|
-
</div>
|
|
506
|
-
);
|
|
507
|
-
};
|
|
508
|
-
|
|
509
|
-
export const LongSessionNames = () => {
|
|
510
|
-
const generateFakeSessionsWithLongNames = (count: number) => {
|
|
511
|
-
return Array.from({ length: count }, (_, index) => ({
|
|
512
|
-
id: `session-${index + 1}`,
|
|
513
|
-
title: `Session ${index + 1}: This is a very long session name to test how the UI handles overflow and text wrapping in the session list. It should be truncated or wrapped appropriately to ensure a good user experience.`,
|
|
514
|
-
createdAt: subHours(new Date(), count - index),
|
|
515
|
-
updatedAt: new Date(),
|
|
516
|
-
conversations: [
|
|
517
|
-
{
|
|
518
|
-
id: '1',
|
|
519
|
-
question:
|
|
520
|
-
'Can you provide an in-depth explanation of the theory of relativity, including its historical context, key principles, mathematical foundations, experimental evidence, and its implications for our understanding of space, time, and gravity? Additionally, how does it relate to quantum mechanics, and what are the current challenges in reconciling these two fundamental theories of physics? Can you provide an in-depth explanation of the theory of relativity, including its historical context, key principles, mathematical foundations, experimental evidence, and its implications for our understanding of space, time, and gravity? Additionally, how does it relate to quantum mechanics, and what are the current challenges in reconciling these two fundamental theories of physics? Can you provide an in-depth explanation of the theory of relativity, including its historical context, key principles, mathematical foundations, experimental evidence, and its implications for our understanding of space, time, and gravity? Additionally, how does it relate to quantum mechanics, and what are the current challenges in reconciling these two fundamental theories of physics? Can you provide an in-depth explanation of the theory of relativity, including its historical context, key principles, mathematical foundations, experimental evidence, and its implications for our understanding of space, time, and gravity? Additionally, how does it relate to quantum mechanics, and what are the current challenges in reconciling these two fundamental theories of physics? Can you provide an in-depth explanation of the theory of relativity, including its historical context, key principles, mathematical foundations, experimental evidence, and its implications for our understanding of space, time, and gravity? Additionally, how does it relate to quantum mechanics, and what are the current challenges in reconciling these two fundamental theories of physics? Can you provide an in-depth explanation of the theory of relativity, including its historical context, key principles, mathematical foundations, experimental evidence, and its implications for our understanding of space, time, and gravity? Additionally, how does it relate to quantum mechanics, and what are the current challenges in reconciling these two fundamental theories of physics? Can you provide an in-depth explanation of the theory of relativity, including its historical context, key principles, mathematical foundations, experimental evidence, and its implications for our understanding of space, time, and gravity? Additionally, how does it relate to quantum mechanics, and what are the current challenges in reconciling these two fundamental theories of physics? Can you provide an in-depth explanation of the theory of relativity, including its historical context, key principles, mathematical foundations, experimental evidence, and its implications for our understanding of space, time, and gravity? Additionally, how does it relate to quantum mechanics, and what are the current challenges in reconciling these two fundamental theories of physics? Can you provide an in-depth explanation of the theory of relativity, including its historical context, key principles, mathematical foundations, experimental evidence, and its implications for our understanding of space, time, and gravity? Additionally, how does it relate to quantum mechanics, and what are the current challenges in reconciling these two fundamental theories of physics? Can you provide an in-depth explanation of the theory of relativity, including its historical context, key principles, mathematical foundations, experimental evidence, and its implications for our understanding of space, time, and gravity? Additionally, how does it relate to quantum mechanics, and what are the current challenges in reconciling these two fundamental theories of physics?',
|
|
521
|
-
response:
|
|
522
|
-
'Can you provide an in-depth explanation of the theory of relativity, including its historical context, key principles, mathematical foundations, experimental evidence, and its implications for our understanding of space, time, and gravity? Additionally, how does it relate to quantum mechanics, and what are the current challenges in reconciling these two fundamental theories of physics? Can you provide an in-depth explanation of the theory of relativity, including its historical context, key principles, mathematical foundations, experimental evidence, and its implications for our understanding of space, time, and gravity? Additionally, how does it relate to quantum mechanics, and what are the current challenges in reconciling these two fundamental theories of physics? Can you provide an in-depth explanation of the theory of relativity, including its historical context, key principles, mathematical foundations, experimental evidence, and its implications for our understanding of space, time, and gravity? Additionally, how does it relate to quantum mechanics, and what are the current challenges in reconciling these two fundamental theories of physics? Can you provide an in-depth explanation of the theory of relativity, including its historical context, key principles, mathematical foundations, experimental evidence, and its implications for our understanding of space, time, and gravity? Additionally, how does it relate to quantum mechanics, and what are the current challenges in reconciling these two fundamental theories of physics? Can you provide an in-depth explanation of the theory of relativity, including its historical context, key principles, mathematical foundations, experimental evidence, and its implications for our understanding of space, time, and gravity? Additionally, how does it relate to quantum mechanics, and what are the current challenges in reconciling these two fundamental theories of physics?',
|
|
523
|
-
createdAt: new Date(),
|
|
524
|
-
updatedAt: new Date()
|
|
525
|
-
}
|
|
526
|
-
]
|
|
527
|
-
}));
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
const sessionsWithLongNames = generateFakeSessionsWithLongNames(10);
|
|
531
|
-
|
|
532
|
-
return (
|
|
533
|
-
<div
|
|
534
|
-
className="dark:bg-(--color-background-basic-black) bg-(--color-background-basic-white)"
|
|
535
|
-
style={{
|
|
536
|
-
position: 'absolute',
|
|
537
|
-
top: 0,
|
|
538
|
-
left: 0,
|
|
539
|
-
right: 0,
|
|
540
|
-
bottom: 0,
|
|
541
|
-
padding: 20,
|
|
542
|
-
margin: 20,
|
|
543
|
-
borderRadius: 5
|
|
544
|
-
}}
|
|
545
|
-
>
|
|
546
|
-
<Chat
|
|
547
|
-
viewType="console"
|
|
548
|
-
sessions={sessionsWithLongNames}
|
|
549
|
-
activeSessionId="session-10"
|
|
550
|
-
>
|
|
551
|
-
<SessionsList>
|
|
552
|
-
<NewSessionButton />
|
|
553
|
-
<SessionGroups />
|
|
554
|
-
</SessionsList>
|
|
555
|
-
|
|
556
|
-
<SessionMessagePanel>
|
|
557
|
-
<SessionMessagesHeader />
|
|
558
|
-
<SessionMessages />
|
|
559
|
-
<ChatInput />
|
|
560
|
-
</SessionMessagePanel>
|
|
561
|
-
</Chat>
|
|
562
|
-
</div>
|
|
563
|
-
);
|
|
564
|
-
};
|
|
565
|
-
|
|
566
|
-
export const MarkdownShowcase = () => {
|
|
567
|
-
const markdownQuestion = `
|
|
568
|
-
**What is the purpose of life?**
|
|
569
|
-
`;
|
|
570
|
-
|
|
571
|
-
const markdownResponse = `
|
|
572
|
-
**The purpose of life is a philosophical question concerning the significance of life or existence in general.**
|
|
573
|
-
|
|
574
|
-
1. Burning of fossil fuels (coal, oil, and natural gas)
|
|
575
|
-
2. Deforestation and land-use changes
|
|
576
|
-
3. Industrial processes
|
|
577
|
-
4. Agriculture and livestock farming
|
|
578
|
-
|
|
579
|
-
or
|
|
580
|
-
|
|
581
|
-
- Burning
|
|
582
|
-
- Deforestation
|
|
583
|
-
- Industrial
|
|
584
|
-
- Agriculture
|
|
585
|
-
|
|
586
|
-
Here is a table to illustrate different perspectives:
|
|
587
|
-
|
|
588
|
-
| Perspective | Description |
|
|
589
|
-
|-------------------|-----------------------------------------------------------------------------|
|
|
590
|
-
| Religious | Belief in a higher power or divine purpose. |
|
|
591
|
-
| Philosophical | Various theories including existentialism, nihilism, and absurdism. |
|
|
592
|
-
| Scientific | Understanding life through biology, evolution, and the universe. |
|
|
593
|
-
| Personal | Individual goals, happiness, and fulfillment. |
|
|
594
|
-
|
|
595
|
-
\`\`\`python
|
|
596
|
-
def purpose_of_life():
|
|
597
|
-
return 42
|
|
598
|
-
\`\`\`
|
|
599
|
-
|
|
600
|
-
\`\`\`json
|
|
601
|
-
{
|
|
602
|
-
"perspectives": [
|
|
603
|
-
{
|
|
604
|
-
"type": "Religious",
|
|
605
|
-
"description": "Belief in a higher power or divine purpose."
|
|
606
|
-
},
|
|
607
|
-
{
|
|
608
|
-
"type": "Philosophical",
|
|
609
|
-
"description": "Various theories including existentialism, nihilism, and absurdism."
|
|
610
|
-
},
|
|
611
|
-
{
|
|
612
|
-
"type": "Scientific",
|
|
613
|
-
"description": "Understanding life through biology, evolution, and the universe."
|
|
614
|
-
},
|
|
615
|
-
{
|
|
616
|
-
"type": "Personal",
|
|
617
|
-
"description": "Individual goals, happiness, and fulfillment."
|
|
618
|
-
}
|
|
619
|
-
]
|
|
620
|
-
}
|
|
621
|
-
\`\`\`
|
|
622
|
-
|
|
623
|
-
The answer to the ultimate question of life, the universe, and everything is **42**.
|
|
624
|
-
|
|
625
|
-
\`\`\`math
|
|
626
|
-
L = \\frac{1}{2} \\rho v^2 S C_L
|
|
627
|
-
\`\`\`
|
|
628
|
-
|
|
629
|
-
[Perspective](https://en.wikipedia.org/wiki/Philosophical_question)
|
|
630
|
-
`;
|
|
631
|
-
|
|
632
|
-
const sessionWithMarkdown: Session[] = [
|
|
633
|
-
{
|
|
634
|
-
id: 'session-markdown',
|
|
635
|
-
title: 'Markdown Showcase',
|
|
636
|
-
createdAt: subHours(new Date(), 1),
|
|
637
|
-
updatedAt: new Date(),
|
|
638
|
-
conversations: [
|
|
639
|
-
{
|
|
640
|
-
id: 'conversation-1',
|
|
641
|
-
question: markdownQuestion,
|
|
642
|
-
response: markdownResponse,
|
|
643
|
-
createdAt: new Date()
|
|
644
|
-
}
|
|
645
|
-
]
|
|
646
|
-
}
|
|
647
|
-
];
|
|
648
|
-
|
|
649
|
-
return (
|
|
650
|
-
<div
|
|
651
|
-
className="dark:bg-(--color-background-basic-black) bg-(--color-background-basic-white)"
|
|
652
|
-
style={{
|
|
653
|
-
position: 'absolute',
|
|
654
|
-
top: 0,
|
|
655
|
-
left: 0,
|
|
656
|
-
right: 0,
|
|
657
|
-
bottom: 0,
|
|
658
|
-
padding: 20,
|
|
659
|
-
margin: 20,
|
|
660
|
-
borderRadius: 5
|
|
661
|
-
}}
|
|
662
|
-
>
|
|
663
|
-
<Chat
|
|
664
|
-
viewType="console"
|
|
665
|
-
sessions={sessionWithMarkdown}
|
|
666
|
-
activeSessionId="session-markdown"
|
|
667
|
-
>
|
|
668
|
-
<SessionsList>
|
|
669
|
-
<NewSessionButton />
|
|
670
|
-
<SessionGroups />
|
|
671
|
-
</SessionsList>
|
|
672
|
-
|
|
673
|
-
<SessionMessagePanel>
|
|
674
|
-
<SessionMessagesHeader />
|
|
675
|
-
<SessionMessages />
|
|
676
|
-
<ChatInput />
|
|
677
|
-
</SessionMessagePanel>
|
|
678
|
-
</Chat>
|
|
679
|
-
</div>
|
|
680
|
-
);
|
|
681
|
-
};
|
|
682
|
-
|
|
683
|
-
export const CVEExample = () => {
|
|
684
|
-
const markdownQuestion = `# Security Report
|
|
685
|
-
|
|
686
|
-
Please review the following CVEs:
|
|
687
|
-
|
|
688
|
-
- CVE-2021-34527
|
|
689
|
-
- CVE-2021-44228
|
|
690
|
-
- CVE-2021-45046
|
|
691
|
-
`;
|
|
692
|
-
|
|
693
|
-
const markdownResponse = `## Analysis
|
|
694
|
-
|
|
695
|
-
The listed CVEs are critical vulnerabilities that need immediate attention.
|
|
696
|
-
|
|
697
|
-
- CVE-2021-34527
|
|
698
|
-
- [CVE-2021-44228](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44228) < Has link
|
|
699
|
-
- CVE-2021-45046
|
|
700
|
-
`;
|
|
701
|
-
|
|
702
|
-
const sessionWithMarkdown: Session[] = [
|
|
703
|
-
{
|
|
704
|
-
id: 'session-cve',
|
|
705
|
-
title: 'CVE Showcase',
|
|
706
|
-
createdAt: subHours(new Date(), 1),
|
|
707
|
-
updatedAt: new Date(),
|
|
708
|
-
conversations: [
|
|
709
|
-
{
|
|
710
|
-
id: 'conversation-1',
|
|
711
|
-
question: markdownQuestion,
|
|
712
|
-
response: markdownResponse,
|
|
713
|
-
createdAt: new Date()
|
|
714
|
-
}
|
|
715
|
-
]
|
|
716
|
-
}
|
|
717
|
-
];
|
|
718
|
-
|
|
719
|
-
return (
|
|
720
|
-
<div
|
|
721
|
-
className="dark:bg-(--color-background-basic-black) bg-(--color-background-basic-white)"
|
|
722
|
-
style={{
|
|
723
|
-
position: 'absolute',
|
|
724
|
-
top: 0,
|
|
725
|
-
left: 0,
|
|
726
|
-
right: 0,
|
|
727
|
-
bottom: 0,
|
|
728
|
-
padding: 20,
|
|
729
|
-
margin: 20,
|
|
730
|
-
borderRadius: 5
|
|
731
|
-
}}
|
|
732
|
-
>
|
|
733
|
-
<Chat
|
|
734
|
-
viewType="console"
|
|
735
|
-
sessions={sessionWithMarkdown}
|
|
736
|
-
activeSessionId="session-cve"
|
|
737
|
-
remarkPlugins={[remarkCve as any]}
|
|
738
|
-
>
|
|
739
|
-
<SessionsList>
|
|
740
|
-
<NewSessionButton />
|
|
741
|
-
<SessionGroups />
|
|
742
|
-
</SessionsList>
|
|
743
|
-
|
|
744
|
-
<SessionMessagePanel>
|
|
745
|
-
<SessionMessagesHeader />
|
|
746
|
-
<SessionMessages />
|
|
208
|
+
<SessionMessages showScrollBottomButton />
|
|
747
209
|
<ChatInput />
|
|
748
210
|
</SessionMessagePanel>
|
|
749
211
|
</Chat>
|
|
@@ -1032,56 +494,76 @@ export const CustomComponents = () => {
|
|
|
1032
494
|
);
|
|
1033
495
|
};
|
|
1034
496
|
|
|
1035
|
-
export const
|
|
1036
|
-
const
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
497
|
+
export const WithToolStatus = () => {
|
|
498
|
+
const [status, setStatus] = useState<MessageStatusState>('loading');
|
|
499
|
+
const [steps, setSteps] = useState<MessageStatusStep[]>([
|
|
500
|
+
{ id: '1', text: 'Reading src/index.ts', status: 'loading' }
|
|
501
|
+
]);
|
|
502
|
+
|
|
503
|
+
useEffect(() => {
|
|
504
|
+
const timeline = [
|
|
505
|
+
{
|
|
506
|
+
delay: 1500,
|
|
507
|
+
action: () => {
|
|
508
|
+
setSteps(prev =>
|
|
509
|
+
prev.map(s => (s.id === '1' ? { ...s, status: 'complete' as const } : s))
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
delay: 2000,
|
|
515
|
+
action: () => {
|
|
516
|
+
setSteps(prev => [
|
|
517
|
+
...prev,
|
|
518
|
+
{ id: '2', text: 'Searching for dependencies', status: 'loading' as const }
|
|
519
|
+
]);
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
delay: 3500,
|
|
524
|
+
action: () => {
|
|
525
|
+
setSteps(prev =>
|
|
526
|
+
prev.map(s => (s.id === '2' ? { ...s, status: 'complete' as const } : s))
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
delay: 4000,
|
|
532
|
+
action: () => {
|
|
533
|
+
setSteps(prev => [
|
|
534
|
+
...prev,
|
|
535
|
+
{ id: '3', text: 'Analyzing code patterns', status: 'loading' as const }
|
|
536
|
+
]);
|
|
537
|
+
}
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
delay: 6000,
|
|
541
|
+
action: () => {
|
|
542
|
+
setSteps(prev =>
|
|
543
|
+
prev.map(s => (s.id === '3' ? { ...s, status: 'complete' as const } : s))
|
|
544
|
+
);
|
|
545
|
+
setStatus('complete');
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
];
|
|
1062
549
|
|
|
1063
|
-
|
|
550
|
+
const timeouts = timeline.map(item => setTimeout(item.action, item.delay));
|
|
551
|
+
return () => timeouts.forEach(clearTimeout);
|
|
552
|
+
}, []);
|
|
553
|
+
|
|
554
|
+
const sessionWithToolStatus: Session[] = [
|
|
1064
555
|
{
|
|
1065
|
-
id: 'session-
|
|
1066
|
-
title: '
|
|
556
|
+
id: 'session-tool-status',
|
|
557
|
+
title: 'Tool Status Demo',
|
|
1067
558
|
createdAt: subHours(new Date(), 1),
|
|
1068
559
|
updatedAt: new Date(),
|
|
1069
560
|
conversations: [
|
|
1070
561
|
{
|
|
1071
562
|
id: 'conversation-1',
|
|
1072
|
-
question: '
|
|
563
|
+
question: 'Can you analyze my codebase and find any issues?',
|
|
1073
564
|
response:
|
|
1074
|
-
'I\'
|
|
1075
|
-
createdAt: new Date()
|
|
1076
|
-
files: staticImageFiles
|
|
1077
|
-
},
|
|
1078
|
-
{
|
|
1079
|
-
id: 'conversation-2',
|
|
1080
|
-
question: 'Analyze these images and describe what you see.',
|
|
1081
|
-
response:
|
|
1082
|
-
'I\'m sorry, but as an AI language model, I cannot actually see or analyze images. I can only process and respond to text input. If you\'d like me to describe or analyze images, you would need to provide detailed textual descriptions of the images.',
|
|
1083
|
-
createdAt: new Date(),
|
|
1084
|
-
files: [staticImageFiles[0]]
|
|
565
|
+
'I\'ll analyze your codebase now. Let me read through the files and check for any potential issues.',
|
|
566
|
+
createdAt: new Date()
|
|
1085
567
|
}
|
|
1086
568
|
]
|
|
1087
569
|
}
|
|
@@ -1103,8 +585,9 @@ export const ImageFiles = () => {
|
|
|
1103
585
|
>
|
|
1104
586
|
<Chat
|
|
1105
587
|
viewType="console"
|
|
1106
|
-
sessions={
|
|
1107
|
-
activeSessionId="session-
|
|
588
|
+
sessions={sessionWithToolStatus}
|
|
589
|
+
activeSessionId="session-tool-status"
|
|
590
|
+
isLoading={status === 'loading'}
|
|
1108
591
|
>
|
|
1109
592
|
<SessionsList>
|
|
1110
593
|
<NewSessionButton />
|
|
@@ -1113,42 +596,37 @@ export const ImageFiles = () => {
|
|
|
1113
596
|
|
|
1114
597
|
<SessionMessagePanel>
|
|
1115
598
|
<SessionMessagesHeader />
|
|
1116
|
-
<SessionMessages
|
|
599
|
+
<SessionMessages>
|
|
600
|
+
{conversations =>
|
|
601
|
+
conversations.map((conversation, index) => (
|
|
602
|
+
<SessionMessage
|
|
603
|
+
conversation={conversation}
|
|
604
|
+
isLast={index === conversations.length - 1}
|
|
605
|
+
key={conversation.id}
|
|
606
|
+
>
|
|
607
|
+
<MessageQuestion
|
|
608
|
+
question={conversation.question}
|
|
609
|
+
files={conversation.files}
|
|
610
|
+
/>
|
|
611
|
+
<MessageResponse response={conversation.response} />
|
|
612
|
+
<div className="mt-4">
|
|
613
|
+
<MessageStatus
|
|
614
|
+
status={status}
|
|
615
|
+
text={status === 'complete' ? 'Analysis complete' : 'Analyzing codebase...'}
|
|
616
|
+
steps={steps}
|
|
617
|
+
/>
|
|
618
|
+
</div>
|
|
619
|
+
<MessageActions
|
|
620
|
+
question={conversation.question}
|
|
621
|
+
response={conversation.response}
|
|
622
|
+
/>
|
|
623
|
+
</SessionMessage>
|
|
624
|
+
))
|
|
625
|
+
}
|
|
626
|
+
</SessionMessages>
|
|
1117
627
|
<ChatInput />
|
|
1118
628
|
</SessionMessagePanel>
|
|
1119
629
|
</Chat>
|
|
1120
630
|
</div>
|
|
1121
631
|
);
|
|
1122
632
|
};
|
|
1123
|
-
|
|
1124
|
-
export const CSVPreview = () => {
|
|
1125
|
-
return (
|
|
1126
|
-
<div
|
|
1127
|
-
className="dark:bg-(--color-background-basic-black) bg-(--color-background-basic-white)"
|
|
1128
|
-
style={{
|
|
1129
|
-
position: 'absolute',
|
|
1130
|
-
inset: 0,
|
|
1131
|
-
padding: 20,
|
|
1132
|
-
margin: 20,
|
|
1133
|
-
borderRadius: 5
|
|
1134
|
-
}}
|
|
1135
|
-
>
|
|
1136
|
-
<Chat
|
|
1137
|
-
sessions={sessionWithCSVFiles}
|
|
1138
|
-
activeSessionId="1"
|
|
1139
|
-
onDeleteSession={() => alert('delete!')}
|
|
1140
|
-
>
|
|
1141
|
-
<SessionsList>
|
|
1142
|
-
<NewSessionButton />
|
|
1143
|
-
<SessionGroups />
|
|
1144
|
-
</SessionsList>
|
|
1145
|
-
|
|
1146
|
-
<SessionMessagePanel>
|
|
1147
|
-
<SessionMessagesHeader />
|
|
1148
|
-
<SessionMessages />
|
|
1149
|
-
<ChatInput allowedFiles={['.pdf', '.docx', '.csv']} />
|
|
1150
|
-
</SessionMessagePanel>
|
|
1151
|
-
</Chat>
|
|
1152
|
-
</div>
|
|
1153
|
-
);
|
|
1154
|
-
};
|