Skip to content

Commit eff6633

Browse files
committed
fix
Signed-off-by: Grant Linville <[email protected]>
1 parent f220097 commit eff6633

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pkg/openai/count.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,17 @@ func decreaseTenPercent(maxTokens int) int {
1515
}
1616

1717
func getBudget(maxTokens int) int {
18-
if maxTokens <= 0 {
18+
if maxTokens == 0 {
1919
return DefaultMaxTokens
20+
} else if maxTokens <= 0 {
21+
// maxTokens was 0 (or some very small number), the tool count pushed it negative
22+
// so we can just add that negative number to the default max tokens, to get something lower
23+
if DefaultMaxTokens+maxTokens >= 0 {
24+
return DefaultMaxTokens + maxTokens
25+
}
26+
27+
// If max tokens was so negative that it was below 128k, then we just return 0 I guess
28+
return 0
2029
}
2130
return maxTokens
2231
}

0 commit comments

Comments
 (0)