mirror of
https://github.com/sst/opencode.git
synced 2025-08-03 21:28:14 +00:00
fix: Prevent division by zero in context percentage calculation (#1055)
This commit is contained in:
parent
5d67e13df5
commit
88b58fd6a0
1 changed files with 4 additions and 1 deletions
|
@ -451,7 +451,10 @@ func formatTokensAndCost(
|
|||
formattedTokens = strings.Replace(formattedTokens, ".0M", "M", 1)
|
||||
}
|
||||
|
||||
percentage := (float64(tokens) / float64(contextWindow)) * 100
|
||||
percentage := 0.0
|
||||
if contextWindow > 0 {
|
||||
percentage = (float64(tokens) / float64(contextWindow)) * 100
|
||||
}
|
||||
|
||||
if isSubscriptionModel {
|
||||
return fmt.Sprintf(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue