feat(generation): select articles in three passes

This commit is contained in:
2026-11-24 00:38:02 +01:00
parent d22f84529f
commit 8022ee0547
27 changed files with 916 additions and 68 deletions

View File

@ -37,7 +37,7 @@ func TestTicket29CompactGroupsIntegrateBeforeSelectionAndFailureIsGlobal(t *test
states++
score := 0.8
if state.Title == "first" {
score = 0.2
score = 0.9
}
if state.Title == "second" && state.Indices[len(state.Indices)-1]["symbol"] == "T29" {
score = 0.05
@ -47,9 +47,9 @@ func TestTicket29CompactGroupsIntegrateBeforeSelectionAndFailureIsGlobal(t *test
usage["state_tokens_dropped"] = 1
}
if posts == 2 && failure == "question" {
usage["truncated_questions"] = []string{"relevance"}
usage["truncated_questions"] = []string{"direct_mention"}
}
results = append(results, map[string]any{"answers": map[string]any{"relevance": map[string]any{"type": "score", "score": score, "answer_confidence": 0.99}}, "usage": usage})
results = append(results, map[string]any{"answers": map[string]any{"direct_mention": map[string]any{"type": "noul", "noul": 1 - score, "answer_confidence": 0.99}}, "usage": usage})
}
_ = json.NewEncoder(w).Encode(map[string]any{"results": results})
}))
@ -62,7 +62,7 @@ func TestTicket29CompactGroupsIntegrateBeforeSelectionAndFailureIsGlobal(t *test
model, key := "selected-model", models.SourceYahooFinance
feed := &ticket17HTTPScraper{articles: []scraper.Article{{Title: "first", URL: "https://fixture.invalid/1"}, {Title: "second", URL: "https://fixture.invalid/2"}}}
summary := &ticket17HTTPSummary{}
repo := &ticket17HTTPRepo{input: generation.UserInput{SummaryModelID: &model, Language: "en", RankingMode: "title", GlobalLimit: 1, Assets: assets, Sources: []models.Source{{ID: "source", SourceKey: &key, Enabled: true, ArticleLimit: 1}}}}
repo := &ticket17HTTPRepo{input: generation.UserInput{SummaryModelID: &model, Language: "en", RankingMode: "title", GlobalLimit: 1, Assets: assets, Sources: []models.Source{{ID: "source", SourceKey: &key, Enabled: true, ArticleLimit: 2}}}}
uc := generation.NewUseCase(generation.Dependencies{Repository: repo, SummaryResolver: &ticket17HTTPResolver{provider: summary}, LayaRanker: ranker, Scrapers: map[string]scraper.Scraper{key: feed}})
result, err := uc.Generate(context.Background(), "owner")
if err != nil || posts != 2 || feed.calls != 1 {