@@ -10,7 +10,13 @@ import { FileSearchResult, ResponseStreamEventData } from '../../../shared/types
10
10
import useRetryTimeout from '../../hooks/useRetryTimeout'
11
11
import { useTranslation } from 'react-i18next'
12
12
import { handleCompletionStreamError } from './error'
13
- import { Box , Button , IconButton } from '@mui/material'
13
+
14
+ import { Box , Button , IconButton , Typography } from '@mui/material'
15
+ import SettingsIcon from '@mui/icons-material/Settings'
16
+ import AddCommentIcon from '@mui/icons-material/AddComment'
17
+ import EmailIcon from '@mui/icons-material/Email'
18
+ import DeleteIcon from '@mui/icons-material/Delete'
19
+
14
20
import { Disclaimer } from './Disclaimer'
15
21
import { Conversation } from './Conversation'
16
22
import { ChatBox } from './ChatBox'
@@ -22,6 +28,9 @@ import { Link } from 'react-router-dom'
22
28
// import { useScrollToBottom } from './useScrollToBottom'
23
29
import { CitationsBox } from './CitationsBox'
24
30
import { useRagIndices } from '../../hooks/useRagIndices'
31
+ import CourseOption from './generics/CourseOption'
32
+ import SettingsButton from './generics/SettingsButton'
33
+
25
34
26
35
export const ChatV2 = ( ) => {
27
36
const { courseId } = useParams ( )
@@ -84,7 +93,8 @@ export const ChatV2 = () => {
84
93
let parsedChunk : ResponseStreamEventData = null
85
94
try {
86
95
parsedChunk = JSON . parse ( chunk )
87
- } catch ( _e ) {
96
+ } catch ( e : any ) {
97
+ console . error ( 'Error' , e )
88
98
console . error ( 'Could not parse the chunk:' , chunk )
89
99
}
90
100
@@ -196,51 +206,63 @@ export const ChatV2 = () => {
196
206
flex : 1 ,
197
207
display : 'flex' ,
198
208
flexDirection : 'row' ,
199
- p : 0 ,
209
+ height : '100%' ,
200
210
} }
201
211
>
202
212
{ /* Course chats columns */ }
203
- < Box sx = { { borderRight : '1px solid lightgray' } } >
204
- < div > Course Chats</ div >
213
+ < Box sx = { { position : 'relative' , flex : 1 , borderRight : '1px solid lightgray' } } >
214
+ < Box sx = { { position : 'sticky' , left : 0 , top : 0 , padding : '2rem 1.5rem' } } >
215
+ < Typography variant = "h6" fontWeight = "light" >
216
+ Currechat
217
+ </ Typography >
218
+ < CourseOption link = "/v2" > Basic</ CourseOption >
219
+
220
+ < Typography variant = "h6" fontWeight = "light" sx = { { mt : '2rem' } } >
221
+ Kurssichatit
222
+ </ Typography >
223
+ < CourseOption link = "/v2/sandbox" > Ohtu sandbox</ CourseOption >
224
+ </ Box >
205
225
</ Box >
206
226
227
+ { /* Chat view */ }
207
228
< Box
208
229
sx = { {
209
230
flex : 4 ,
210
231
position : 'relative' ,
211
232
display : 'flex' ,
212
233
flexDirection : 'column' ,
234
+ height : '100%' ,
213
235
} }
214
236
>
215
- < SettingsModal
216
- open = { settingsModalOpen }
217
- setOpen = { setSettingsModalOpen }
218
- model = { model . name }
219
- setModel = { ( name ) => setModel ( { name } ) }
220
- setRagIndex = { setRagIndexId }
221
- ragIndices = { ragIndices }
222
- currentRagIndex = { ragIndex }
223
- />
237
+
224
238
< Box
225
239
sx = { {
240
+ position : 'sticky' ,
241
+ top : 0 ,
226
242
display : 'flex' ,
227
- justifyContent : 'space-between ' ,
243
+ justifyContent : 'center ' ,
228
244
alignItems : 'center' ,
229
- flexShrink : 0 ,
245
+ gap : '1.2rem' ,
246
+ backgroundColor : 'white' ,
247
+ padding : '1.8rem 1rem 0.8rem 1rem' ,
230
248
} }
231
249
>
232
- < Box sx = { { display : 'flex' , gap : '1rem' } } >
233
- { disclaimerInfo && < Disclaimer disclaimer = { disclaimerInfo } /> }
250
+ { /* {disclaimerInfo && <Disclaimer disclaimer={disclaimerInfo} /> }
234
251
<SystemPrompt content={system.content} setContent={(content) => setSystem({ content })} />
235
252
<Button onClick={handleReset}>Reset</Button>
236
253
<IconButton onClick={() => setSettingsModalOpen(true)} title="Settings">
237
254
<Settings></Settings>
238
- </ IconButton >
239
- </ Box >
240
- { courseId ? < Link to = { '/v2' } > CurreChat</ Link > : < Link to = { '/v2/sandbox' } > Ohtu Sandbox</ Link > }
255
+ </IconButton> */ }
256
+ < SettingsButton startIcon = { < SettingsIcon /> } > Keskustelun asetukset</ SettingsButton >
257
+ { /* <SettingsButton startIcon={<AddCommentIcon />}>Alustus</SettingsButton> */ }
258
+ < SettingsButton startIcon = { < EmailIcon /> } > Tallenna sähköpostina</ SettingsButton >
259
+ < SettingsButton startIcon = { < DeleteIcon /> } > Tyhjennä</ SettingsButton >
260
+ { /* {courseId ? <Link to={'/v2'}>CurreChat</Link> : <Link to={'/v2/sandbox'}>Ohtu Sandbox</Link> } */ }
241
261
</ Box >
242
- < Box sx = { { flex : 1 , display : 'flex' , width : '100%' , overflow : 'hidden' } } >
243
- < Conversation messages = { messages } completion = { completion } fileSearchResult = { fileSearchResult } />
262
+
263
+ < Conversation messages = { messages } completion = { completion } fileSearchResult = { fileSearchResult } />
264
+
265
+ < Box sx = { { position : 'sticky' , bottom : 0 , backgroundColor : 'white' , paddingBottom : '1.2rem' } } >
244
266
< ChatBox
245
267
disabled = { false }
246
268
onSubmit = { ( message ) => {
@@ -254,12 +276,23 @@ export const ChatV2 = () => {
254
276
</ Box >
255
277
256
278
{ /* Annotations columns */ }
257
- { /* <Box sx={{ flex: 1 }}></Box> */ }
258
- { ragIndex && (
259
- < Box flex = { 1 } >
260
- < CitationsBox messages = { messages } fileSearchResult = { fileSearchResult } />
261
- </ Box >
262
- ) }
279
+ < Box sx = { { flex : 1 , borderLeft : '1px solid lightgray' , position : 'relative' } } >
280
+ { ragIndex && (
281
+ < Box sx = { { position : 'sticky' , top : 0 } } >
282
+ < CitationsBox messages = { messages } fileSearchResult = { fileSearchResult } />
283
+ </ Box >
284
+ ) }
285
+ </ Box >
286
+
287
+ < SettingsModal
288
+ open = { settingsModalOpen }
289
+ setOpen = { setSettingsModalOpen }
290
+ model = { model . name }
291
+ setModel = { ( name ) => setModel ( { name } ) }
292
+ setRagIndex = { setRagIndexId }
293
+ ragIndices = { ragIndices }
294
+ currentRagIndex = { ragIndex }
295
+ />
263
296
</ Box >
264
297
)
265
298
}
0 commit comments