File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ export abstract class BaseProvider implements ApiHandler {
9797 return apiCount
9898 } catch ( error ) {
9999 const localEstimate = await localCountTokens ( content , { useWorker : true } )
100- return localEstimate
100+ return Math . ceil ( localEstimate * this . tokenComparator . getSafetyFactor ( ) )
101101 }
102102 }
103103
@@ -106,7 +106,7 @@ export abstract class BaseProvider implements ApiHandler {
106106 const { info } = this . getModel ( )
107107 const contextWindow = info . contextWindow
108108 const allowedTokens = getAllowedTokens ( contextWindow , options . maxTokens )
109- const projectedTokens = options . totalTokens + localEstimate * this . tokenComparator . getSafetyFactor ( )
109+ const projectedTokens = options . totalTokens + Math . ceil ( localEstimate * this . tokenComparator . getSafetyFactor ( ) )
110110
111111 // Checking if we're at 90% of effective threshold for earlier API-based counting
112112 const effectiveThreshold = options . effectiveThreshold ?? 100
@@ -131,6 +131,6 @@ export abstract class BaseProvider implements ApiHandler {
131131 }
132132 }
133133
134- return localEstimate
134+ return Math . ceil ( localEstimate * this . tokenComparator . getSafetyFactor ( ) )
135135 }
136136}
You can’t perform that action at this time.
0 commit comments