1- import { FC } from 'react'
21import styles from './ContextUtilisation.module.scss'
32import cn from 'classnames'
43
@@ -7,27 +6,16 @@ type Props = {
76 context_size_warning_threshold : number
87}
98
10- const format_number = ( num : number ) : string => {
11- if ( num < 1000 ) {
12- return num . toLocaleString ( )
13- }
14- return `${ Math . floor ( num / 1000 ) } k`
15- }
16-
17- export const ContextUtilisation : FC < Props > = ( props ) => {
18- const { current_context_size, context_size_warning_threshold } = props
9+ export const ContextUtilisation : React . FC < Props > = ( props ) => {
1910 const is_above_threshold =
20- current_context_size > context_size_warning_threshold
11+ props . current_context_size > props . context_size_warning_threshold
2112 const progress = Math . min (
22- ( current_context_size / context_size_warning_threshold ) * 100 ,
13+ ( props . current_context_size / props . context_size_warning_threshold ) * 100 ,
2314 100
2415 )
2516
2617 return (
2718 < div className = { styles . container } >
28- < span className = { styles . label } >
29- { format_number ( current_context_size ) }
30- </ span >
3119 < div className = { styles . bar } >
3220 < div
3321 className = { cn ( styles . bar__progress , {
@@ -36,8 +24,14 @@ export const ContextUtilisation: FC<Props> = (props) => {
3624 style = { { width : `${ progress } %` } }
3725 />
3826 </ div >
39- < span className = { styles . label } >
40- { format_number ( context_size_warning_threshold ) }
27+ < span
28+ className = { styles . label }
29+ title = "Selecting more than set threshold will show warning"
30+ >
31+ { props . current_context_size > 0
32+ ? `~${ props . current_context_size } `
33+ : '0' }
34+ /{ props . context_size_warning_threshold } tokens in context
4135 </ span >
4236 </ div >
4337 )
0 commit comments