1
1
import { Divider , Select , Sheet , Slider , Typography , Option , Box , Chip , Tooltip , IconButton , selectClasses } from "@mui/joy" ;
2
- import { useEffect , useState } from "react" ;
2
+ import { useEffect , useState , useMemo } from "react" ;
3
3
import { setOpenAiParams } from "../lib/OpenAi.jsx" ;
4
4
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined' ;
5
5
import KeyboardArrowDown from '@mui/icons-material/KeyboardArrowDown'
@@ -11,18 +11,20 @@ const Sidebar = () => {
11
11
const [ frequencyPenalty , setFrequencyPenalty ] = useState ( 0 ) ;
12
12
const [ topP , setTopP ] = useState ( 1 ) ;
13
13
14
+ const params = useMemo ( ( ) => ( {
15
+ model : model ,
16
+ temperature : temperature ,
17
+ max_tokens : maxTokens ,
18
+ frequency_penalty : frequencyPenalty ,
19
+ top_p : topP ,
20
+ } ) , [ model , temperature , maxTokens , frequencyPenalty , topP ] ) ;
21
+
14
22
useEffect ( ( ) => {
15
23
const timeout = setTimeout ( ( ) => {
16
- setOpenAiParams ( {
17
- model : model ,
18
- temperature : temperature ,
19
- max_tokens : maxTokens ,
20
- frequency_penalty : frequencyPenalty ,
21
- top_p : topP ,
22
- } ) ;
24
+ setOpenAiParams ( params ) ;
23
25
} , 400 ) ;
24
26
return ( ) => clearTimeout ( timeout ) ;
25
- } , [ model , temperature , maxTokens , frequencyPenalty , topP ] )
27
+ } , [ params ] )
26
28
27
29
return < Sheet sx = { { display : { xs : "none" , md : "flow" } , borderRight : '1px solid' , borderColor : 'divider' , overflowY : 'scroll' , width : "25rem" , p : 3 } } >
28
30
< Divider sx = { { mb : 2 } } > < Chip variant = "outlined" > Settings</ Chip > </ Divider >
0 commit comments