File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,9 +78,23 @@ function describeRateLimit(
7878 maxTokens : number
7979) : { sustained : string ; burst : string } | null {
8080 if ( refillRate <= 0 || intervalMs <= 0 || maxTokens <= 0 ) return null ;
81- const perMin = Math . round ( ( refillRate * 60_000 ) / intervalMs ) ;
81+ const perMin = ( refillRate * 60_000 ) / intervalMs ;
82+ let sustained : string ;
83+ if ( perMin >= 1 ) {
84+ sustained = `${ Math . round ( perMin ) . toLocaleString ( ) } requests per minute` ;
85+ } else {
86+ const perHour = perMin * 60 ;
87+ if ( perHour >= 1 ) {
88+ sustained = `${ Math . round ( perHour ) . toLocaleString ( ) } requests per hour` ;
89+ } else {
90+ const perDay = perHour * 24 ;
91+ const formatted =
92+ perDay >= 10 ? Math . round ( perDay ) . toLocaleString ( ) : perDay . toFixed ( 1 ) ;
93+ sustained = `${ formatted } requests per day` ;
94+ }
95+ }
8296 return {
83- sustained : ` ${ perMin . toLocaleString ( ) } requests per minute` ,
97+ sustained,
8498 burst : `${ maxTokens . toLocaleString ( ) } request burst allowance` ,
8599 } ;
86100}
You can’t perform that action at this time.
0 commit comments