1
1
import { Close } from '@mui/icons-material'
2
- import { Box , IconButton , Modal , TextField , Typography } from '@mui/material'
2
+ import { Box , IconButton , Modal , Slider , TextField , Typography } from '@mui/material'
3
3
import ModelSelector from './ModelSelector'
4
4
import { validModels } from '../../../config'
5
5
import React from 'react'
6
6
import RagSelector from './RagSelector'
7
7
import { RagIndexAttributes } from '../../../shared/types'
8
+ import SettingsButton from './generics/SettingsButton'
8
9
9
10
interface SettingsModalProps {
10
11
open : boolean
11
12
setOpen : ( open : boolean ) => void
12
13
assistantInstructions : string
13
14
setAssistantInstructions : ( instructions : string ) => void
15
+ modelTemperature : number
16
+ setModelTemperature : ( value : number ) => void
14
17
model : string
15
18
setModel : ( model : string ) => void
16
19
setRagIndex : ( ragIndex : number ) => void
@@ -23,12 +26,18 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({
23
26
setOpen,
24
27
assistantInstructions,
25
28
setAssistantInstructions,
29
+ modelTemperature,
30
+ setModelTemperature,
26
31
model,
27
32
setModel,
28
33
setRagIndex,
29
34
ragIndices,
30
35
currentRagIndex,
31
36
} ) => {
37
+ const resetSettings = ( ) => {
38
+ alert ( 'resetting' )
39
+ }
40
+
32
41
return (
33
42
< Modal open = { open } onClose = { ( ) => setOpen ( false ) } >
34
43
< Box
@@ -39,38 +48,78 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({
39
48
transform : 'translate(-50%, -50%)' ,
40
49
display : 'flex' ,
41
50
flexDirection : 'column' ,
42
- gap : '1.2rem ' ,
51
+ justifyContent : 'space-between ' ,
43
52
minWidth : 600 ,
44
53
width : '85vw' ,
45
54
maxWidth : 1000 ,
46
- minHeight : '70vh' ,
55
+ minHeight : '80vh' ,
56
+ maxHeight : '80vh' ,
47
57
bgcolor : 'background.paper' ,
48
58
boxShadow : 24 ,
49
- p : '2.5rem' ,
50
59
borderRadius : '0.3rem' ,
60
+ overflow : 'hidden' ,
51
61
} }
52
62
>
53
- < IconButton onClick = { ( ) => setOpen ( false ) } sx = { { position : 'absolute' , top : 8 , right : 8 , color : 'grey.500' } } >
63
+ < IconButton onClick = { ( ) => setOpen ( false ) } sx = { { position : 'absolute' , top : 10 , right : 20 , color : 'grey.500' } } >
54
64
< Close />
55
65
</ IconButton >
56
- < Typography variant = "h6" fontWeight = { 600 } >
57
- Alustus
58
- </ Typography >
59
- < Typography variant = "body1" >
60
- Alustuksella tarkoitetaan yleistason ohjeistusta keskustelulle. Kielimallia voi esimerkiksi pyytää käyttämään akateemista kieltä tai esittämään puutarhuria jota
61
- haastatellaan kaktusten hoidosta.
62
- </ Typography >
63
- { /* <ModelSelector currentModel={model} setModel={setModel} models={validModels.map((m) => m.name)} /> */ }
64
- { /* Disabled for now due to RAG not functioning cirreclty */ }
65
- { /* <RagSelector currentRagIndex={currentRagIndex} setRagIndex={setRagIndex} ragIndices={ragIndices} /> */ }
66
- < TextField
67
- multiline
68
- minRows = { 6 }
69
- maxRows = { 10 }
70
- label = "Alustuksen sisältö"
71
- value = { assistantInstructions }
72
- onChange = { ( e ) => setAssistantInstructions ( e . target . value ) }
73
- />
66
+
67
+ < Box
68
+ sx = { {
69
+ flex : 1 ,
70
+ display : 'flex' ,
71
+ flexDirection : 'column' ,
72
+ gap : '1.2rem' ,
73
+ overflowY : 'auto' ,
74
+ p : '3rem' ,
75
+ } }
76
+ >
77
+ < Typography variant = "h6" fontWeight = { 600 } >
78
+ Keskustelun alustus
79
+ </ Typography >
80
+ < Typography variant = "body1" >
81
+ Alustuksella tarkoitetaan yleistason ohjeistusta keskustelulle. Kielimallia voi esimerkiksi pyytää käyttämään akateemista kieltä tai esittämään puutarhuria
82
+ jota haastatellaan kaktusten hoidosta.
83
+ </ Typography >
84
+ < TextField
85
+ multiline
86
+ minRows = { 6 }
87
+ maxRows = { 10 }
88
+ label = "Alustuksen sisältö"
89
+ value = { assistantInstructions }
90
+ onChange = { ( e ) => setAssistantInstructions ( e . target . value ) }
91
+ />
92
+
93
+ < Typography variant = "h6" fontWeight = { 600 } mt = "2rem" >
94
+ Säädä kielimallin tarkkuutta
95
+ </ Typography >
96
+ < Typography variant = "body1" >
97
+ Suuremmat arvot, kuten 0.8, tekevät tulosteesta satunnaisemman, kun taas pienemmät arvot, kuten 0.2, tekevät siitä tarkemman ja deterministisemmän.
98
+ </ Typography >
99
+ < Box sx = { { border : '1px solid rgba(0,0,0,0.25)' , borderRadius : '6px' , maxWidth : 500 , padding : '2rem' } } >
100
+ < Slider
101
+ min = { 0.0 }
102
+ max = { 1.0 }
103
+ step = { 0.1 }
104
+ value = { modelTemperature }
105
+ marks
106
+ valueLabelDisplay = "auto"
107
+ onChange = { ( _event , value ) => setModelTemperature ( typeof value === 'number' ? value : modelTemperature ) }
108
+ />
109
+ < Box sx = { { display : 'flex' , justifyContent : 'space-between' } } >
110
+ < Typography > Tarkempi</ Typography >
111
+ < Typography > Satunnainen</ Typography >
112
+ </ Box >
113
+ </ Box >
114
+
115
+ { /* <ModelSelector currentModel={model} setModel={setModel} models={validModels.map((m) => m.name)} /> */ }
116
+ { /* Disabled for now due to RAG not functioning cirreclty */ }
117
+ { /* <RagSelector currentRagIndex={currentRagIndex} setRagIndex={setRagIndex} ragIndices={ragIndices} /> */ }
118
+ </ Box >
119
+
120
+ < Box sx = { { padding : '2rem 3rem' , display : 'flex' , borderTop : '1px solid rgba(0,0,0,0.25)' , justifyContent : 'flex-end' } } >
121
+ < SettingsButton onClick = { resetSettings } > Palauta oletusasetukset</ SettingsButton >
122
+ </ Box >
74
123
</ Box >
75
124
</ Modal >
76
125
)
0 commit comments