feat(summary): send complete articles within user budget (#39)
This commit is contained in:
30
backend/internal/ai/fixture_capacity_ticket39_test.go
Normal file
30
backend/internal/ai/fixture_capacity_ticket39_test.go
Normal file
@ -0,0 +1,30 @@
|
||||
package ai
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/tradarr/backend/internal/generation"
|
||||
"github.com/tradarr/backend/internal/summarybudget"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTicket39FixtureCapacityStillEnforcesAdmission(t *testing.T) {
|
||||
provider := &incident37Provider{}
|
||||
lookup := func(source, model string) (summarybudget.Profile, bool) {
|
||||
return summarybudget.Profile{ContextWindowTokens: 8192, InputLimitTokens: 8192, OutputReserveTokens: 1024, Counter: summarybudget.UTF8UpperBound, FramingTokens: 1024}, source == "ollama" && model == "fake-summary"
|
||||
}
|
||||
a := fullGenerationSummarizer{provider: provider, providerName: "ollama", model: "fake-summary", profileLookup: lookup}
|
||||
req := generation.SummaryRequest{Language: "en", Budget: 250000}
|
||||
_, usage, err := a.SummarizeWithBudget(context.Background(), req)
|
||||
if err != nil || provider.calls != 1 || usage.EffectiveTokens != 7168 {
|
||||
t.Fatal("explicit fixture capacity not used", err)
|
||||
}
|
||||
req.Budget = 1
|
||||
if _, _, err = a.SummarizeWithBudget(context.Background(), req); !errors.Is(err, summarybudget.ErrExceeded) || provider.calls != 1 {
|
||||
t.Fatal("fixture bypassed budget admission")
|
||||
}
|
||||
a.model = "unrecognized"
|
||||
if _, _, err = a.SummarizeWithBudget(context.Background(), req); !errors.Is(err, summarybudget.ErrUnknown) || provider.calls != 1 {
|
||||
t.Fatal("fixture bypassed unknown-capacity guard")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user