34 lines
962 B
Go
34 lines
962 B
Go
package summarybudget
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
)
|
|
|
|
func TestTicket39CapacityAndCounting(t *testing.T) {
|
|
p := Profile{ContextWindowTokens: 100, InputLimitTokens: 90, OutputReserveTokens: 20, Counter: UTF8UpperBound, FramingTokens: 5}
|
|
for _, tc := range []struct{ budget, want int }{{50, 50}, {250000, 80}} {
|
|
if n, err := p.Effective(tc.budget); err != nil || n != tc.want {
|
|
t.Fatalf("capacity %d %v", n, err)
|
|
}
|
|
}
|
|
u, err := p.Measure("é🙂", 11)
|
|
if err != nil || u.PromptTokens != 11 {
|
|
t.Fatalf("tokens %+v %v", u, err)
|
|
}
|
|
_, err = p.Measure("é🙂", 10)
|
|
if !errors.Is(err, ErrExceeded) {
|
|
t.Fatal("overflow accepted")
|
|
}
|
|
p.Counter = "unknown"
|
|
if _, err = p.Measure("x", 50); !errors.Is(err, ErrUnknown) {
|
|
t.Fatal("unknown counter accepted")
|
|
}
|
|
if _, ok := Lookup("openai", "invented"); ok {
|
|
t.Fatal("invented model accepted")
|
|
}
|
|
if _, ok := Lookup("ollama", "gpt-4o-mini"); ok {
|
|
t.Fatal("cross-provider capacity inferred")
|
|
}
|
|
}
|