feat(bloomberg): enrich article content for summaries (#36)

This commit is contained in:
2026-11-24 13:44:52 +01:00
parent 686f66a437
commit a53aec7947
22 changed files with 1148 additions and 127 deletions

View File

@ -126,7 +126,7 @@ func TestTicket28LargeWatchlistExhaustiveIdentityCoverageAndBestArticleRank(t *t
}
}
func TestTicket28LaterGroupFailureDiscardsAllScoresAndDoesNotShortenLongArticle(t *testing.T) {
func TestTicket28LaterGroupFailureDiscardsAllScoresWithExplicitBudgetedExcerpt(t *testing.T) {
for _, failure := range []string{"http", "truncated", "dropped", "question", "missing_usage", "count", "confidence"} {
t.Run(failure, func(t *testing.T) {
calls := 0
@ -135,15 +135,16 @@ func TestTicket28LaterGroupFailureDiscardsAllScoresAndDoesNotShortenLongArticle(
calls++
var payload struct {
States []struct {
Indices []map[string]string
Content string
Indices []map[string]string
Content string
ContentTruncated bool `json:"content_truncated"`
}
}
if err := json.NewDecoder(r.Body).Decode(&payload); err != nil {
t.Error(err)
}
if len(payload.States) != 1 || len(payload.States[0].Indices) != 1 || payload.States[0].Content != longContent {
t.Error("article shortened or asset omitted")
if len(payload.States) != 1 || len(payload.States[0].Indices) != 1 || !strings.HasPrefix(longContent, payload.States[0].Content) || payload.States[0].Content == "" || !payload.States[0].ContentTruncated {
t.Error("invalid excerpt flag or asset association")
}
usage := map[string]any{"truncated": false}
score := 0.1
@ -173,7 +174,7 @@ func TestTicket28LaterGroupFailureDiscardsAllScoresAndDoesNotShortenLongArticle(
}))
defer srv.Close()
ranker, _ := NewLayaHTTPRanker(LayaHTTPConfig{BaseURL: srv.URL, BatchSize: 1})
got, err := ranker.Rank(context.Background(), "title_content", []models.UserAsset{{Name: "first", Symbol: "ONE"}, {Name: "second", Symbol: "TWO"}, {Name: "not attempted", Symbol: "THREE"}}, []generation.Candidate{{ID: "c", Article: scraper.Article{Title: "private title", Content: longContent}}})
got, err := ranker.Rank(context.Background(), "title_content", []models.UserAsset{{Name: strings.Repeat("a", 400), Symbol: "ONE"}, {Name: strings.Repeat("b", 400), Symbol: "TWO"}, {Name: strings.Repeat("c", 400), Symbol: "THREE"}}, []generation.Candidate{{ID: "c", Article: scraper.Article{Title: "private title", Content: longContent}}})
if err == nil || got != nil || calls != 2 {
t.Fatalf("partial ranking/fallback: calls=%d err=%v", calls, err)
}