@@ -15,7 +15,8 @@ import 'katex/dist/katex.min.css'
15
15
import 'katex/dist/contrib/mhchem'
16
16
import CopyToClipboardButton from '../Chat/CopyToClipboardButton'
17
17
import { t } from 'i18next'
18
- import { OutlineButtonBlue } from './generics/Buttons'
18
+ import { OutlineButtonBlack , } from './generics/Buttons'
19
+ import FormatQuoteIcon from '@mui/icons-material/FormatQuote' ;
19
20
20
21
const UserMessage = ( {
21
22
content,
@@ -73,17 +74,15 @@ const AssistantMessage = ({
73
74
error,
74
75
isLastAssistantNode,
75
76
expandedNodeHeight,
76
- fileSearchStatus,
77
- ragDisplay,
78
- toggleRagDisplay,
77
+ fileSearchResult,
78
+ setActiveFileSearchResult
79
79
} : {
80
80
content : string
81
81
error ?: string
82
82
isLastAssistantNode : boolean
83
83
expandedNodeHeight : number
84
- fileSearchStatus : boolean
85
- ragDisplay : boolean
86
- toggleRagDisplay : ( ) => void
84
+ fileSearchResult ?: FileSearchCompletedData
85
+ setActiveFileSearchResult : ( data : FileSearchCompletedData ) => void
87
86
} ) => {
88
87
const processedContent = preprocessMath ( content )
89
88
const katexOptions = {
@@ -209,11 +208,12 @@ const AssistantMessage = ({
209
208
< Typography variant = "body1" fontStyle = "italic" color = "#cc0000" > { `\n\n ${ error } ` } </ Typography >
210
209
</ Box >
211
210
) }
212
- { isLastAssistantNode && fileSearchStatus && (
213
- < OutlineButtonBlue sx = { { padding : '0.4rem 0.8rem' , fontSize : '14px' } } onClick = { ( ) => toggleRagDisplay ( ) } >
214
- { ragDisplay ? t ( 'chat:hideSources' ) : t ( 'chat:displaySources' ) }
215
- </ OutlineButtonBlue >
216
- ) }
211
+ { /* {ragDisplay ? t('chat:hideSources') : t('chat:displaySources')} */ }
212
+ { fileSearchResult ?. status === "completed" &&
213
+ < OutlineButtonBlack sx = { { mt : 3 } } startIcon = { < FormatQuoteIcon /> } onClick = { ( ) => setActiveFileSearchResult ( fileSearchResult ) } >
214
+ < Typography variant = 'body2' > Lähteet: < em > { fileSearchResult . id } </ em > </ Typography >
215
+ </ OutlineButtonBlack >
216
+ }
217
217
</ Box >
218
218
</ Box >
219
219
)
@@ -223,14 +223,12 @@ const MessageItem = ({
223
223
message,
224
224
isLastAssistantNode,
225
225
expandedNodeHeight,
226
- ragDisplay,
227
- toggleRagDisplay,
226
+ setActiveFileSearchResult
228
227
} : {
229
228
message : Message
230
229
isLastAssistantNode : boolean
231
230
expandedNodeHeight : number
232
- ragDisplay : boolean
233
- toggleRagDisplay : ( ) => void
231
+ setActiveFileSearchResult : ( data : FileSearchCompletedData ) => void
234
232
} ) => {
235
233
236
234
if ( message . role === 'assistant' ) {
@@ -240,9 +238,8 @@ const MessageItem = ({
240
238
error = { message . error }
241
239
isLastAssistantNode = { isLastAssistantNode }
242
240
expandedNodeHeight = { expandedNodeHeight }
243
- fileSearchStatus = { message . fileSearchResult ?. status == 'completed' }
244
- ragDisplay = { ragDisplay }
245
- toggleRagDisplay = { toggleRagDisplay }
241
+ fileSearchResult = { message . fileSearchResult }
242
+ setActiveFileSearchResult = { setActiveFileSearchResult }
246
243
/>
247
244
)
248
245
} else {
@@ -265,9 +262,7 @@ export const Conversation = ({
265
262
messages,
266
263
completion,
267
264
isCompletionDone,
268
- fileSearchResult,
269
- ragDisplay,
270
- toggleRagDisplay,
265
+ setActiveFileSearchResult
271
266
} : {
272
267
courseName ?: string
273
268
courseDate ?: ActivityPeriod
@@ -276,9 +271,7 @@ export const Conversation = ({
276
271
messages : Message [ ]
277
272
completion : string
278
273
isCompletionDone : boolean
279
- fileSearchResult ?: FileSearchCompletedData
280
- ragDisplay : boolean
281
- toggleRagDisplay : ( ) => void
274
+ setActiveFileSearchResult : ( data : FileSearchCompletedData ) => void
282
275
} ) => (
283
276
< Box
284
277
style = { {
@@ -300,20 +293,18 @@ export const Conversation = ({
300
293
message = { message }
301
294
isLastAssistantNode = { isLastAssistantNode }
302
295
expandedNodeHeight = { expandedNodeHeight }
303
- ragDisplay = { ragDisplay }
304
- toggleRagDisplay = { toggleRagDisplay }
296
+ setActiveFileSearchResult = { setActiveFileSearchResult }
305
297
/>
306
298
)
307
299
} ) }
308
300
{ ! isCompletionDone &&
309
301
messages . length > 0 &&
310
302
( completion . length > 0 ? (
311
303
< MessageItem
312
- message = { { role : 'assistant' , content : completion , fileSearchResult } }
304
+ message = { { role : 'assistant' , content : completion } }
313
305
isLastAssistantNode = { true }
314
306
expandedNodeHeight = { expandedNodeHeight }
315
- ragDisplay = { ragDisplay }
316
- toggleRagDisplay = { toggleRagDisplay }
307
+ setActiveFileSearchResult = { setActiveFileSearchResult }
317
308
/>
318
309
) : (
319
310
< LoadingMessage expandedNodeHeight = { expandedNodeHeight } />
0 commit comments