We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f220097 commit eff6633Copy full SHA for eff6633
pkg/openai/count.go
@@ -15,8 +15,17 @@ func decreaseTenPercent(maxTokens int) int {
15
}
16
17
func getBudget(maxTokens int) int {
18
- if maxTokens <= 0 {
+ if maxTokens == 0 {
19
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
29
30
return maxTokens
31
0 commit comments