@@ -8,6 +8,7 @@ const MLSettingsPage: React.FC = () => {
88 confidence_threshold : 0.5
99 } ) ;
1010 const [ isLoading , setIsLoading ] = useState ( true ) ;
11+ const [ localThreshold , setLocalThreshold ] = useState < number > ( 0.5 ) ;
1112
1213 useEffect ( ( ) => {
1314 fetchConfig ( ) ;
@@ -17,6 +18,7 @@ const MLSettingsPage: React.FC = () => {
1718 try {
1819 const data = await getConfig ( ) ;
1920 setConfig ( data ) ;
21+ setLocalThreshold ( data . confidence_threshold ) ;
2022 } catch ( error ) {
2123 console . error ( 'Error fetching config:' , error ) ;
2224 } finally {
@@ -27,7 +29,7 @@ const MLSettingsPage: React.FC = () => {
2729 const handleThresholdChange = async ( value : number ) => {
2830 try {
2931 setConfig ( prev => ( { ...prev , confidence_threshold : value } ) ) ;
30- await updateConfig ( config ) ;
32+ await updateConfig ( { ... config , confidence_threshold : value } ) ;
3133 } catch ( error ) {
3234 console . error ( 'Error updating config:' , error ) ;
3335 }
@@ -53,7 +55,7 @@ const MLSettingsPage: React.FC = () => {
5355 < div className = "bg-white rounded-lg shadow-sm border border-gray-200 p-6" >
5456 < div className = "space-y-6" >
5557 < div >
56- < h2 className = "text-lg font-medium text-gray-800 mb-4" > Tune ML </ h2 >
58+ < h2 className = "text-lg font-medium text-gray-800 mb-4" > Intent Classification </ h2 >
5759 < div className = "space-y-4" >
5860 < div >
5961 < label className = "block text-sm font-medium text-gray-700 mb-2" >
@@ -65,12 +67,14 @@ const MLSettingsPage: React.FC = () => {
6567 min = "0.1"
6668 max = "1.0"
6769 step = "0.05"
68- value = { config . confidence_threshold }
69- onChange = { ( e ) => handleThresholdChange ( parseFloat ( e . target . value ) ) }
70+ value = { localThreshold }
71+ onChange = { ( e ) => setLocalThreshold ( parseFloat ( e . target . value ) ) }
72+ onMouseUp = { ( ) => handleThresholdChange ( localThreshold ) }
73+ onTouchEnd = { ( ) => handleThresholdChange ( localThreshold ) }
7074 className = "w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-green-500"
7175 />
7276 < span className = "text-sm font-medium text-gray-900 min-w-[4rem]" >
73- { ( config . confidence_threshold * 100 ) . toFixed ( 0 ) } %
77+ { ( localThreshold * 100 ) . toFixed ( 0 ) } %
7478 </ span >
7579 </ div >
7680 < p className = "mt-2 text-sm text-gray-500" >
@@ -79,15 +83,6 @@ const MLSettingsPage: React.FC = () => {
7983 </ div >
8084 </ div >
8185 </ div >
82-
83- < div className = "border-t border-gray-200 pt-6" >
84- < h3 className = "text-sm font-medium text-gray-700 mb-2" > About ML Settings</ h3 >
85- < p className = "text-sm text-gray-500" >
86- The confidence threshold determines how certain the model needs to be before matching an intent.
87- A higher threshold means fewer false positives but might miss some valid intents.
88- A lower threshold means more matches but might include some incorrect ones.
89- </ p >
90- </ div >
9186 </ div >
9287 </ div >
9388 </ div >
0 commit comments