fix: report 504 — cap triase LLM 5 artikel, narasi_awam persist ke payload; report FE bahasa awam
CI / go test + web typecheck (push) Canceled after 0s
CI / build + deploy (Nix) — flowsight (push) Canceled after 0s

This commit is contained in:
asepharyana
2026-09-15 21:15:49 +07:00
parent 7db077c2e6
commit 5c953289b1
3 changed files with 16 additions and 8 deletions
+6 -1
View File
@@ -52,12 +52,17 @@ func AnalyzeSentiment(ctx context.Context, d Deps, ticker string) model.AgentRes
pos, neg, neu := 0, 0, 0
var keyEvents []string
useLLM := d.LLM != nil && d.LLM.Available()
// Cap LLM triage calls: each is one HTTP round-trip to OmniRoute
// (~5-15s). More than 5 articles and report generation exceeds the
// 60s reverse-proxy read timeout -> 504 with a persisted-but-stale
// report. Rules path covers the rest via keywordSentiment.
const maxLLMTriage = 5
for i, a := range news.Results {
if i >= 20 {
break
}
label, conf := "neutral", 0.5
if useLLM {
if useLLM && i < maxLLMTriage {
label, conf = d.LLM.SentimentTriage(ctx, d.TriageModel, a.Title, a.Body)
} else {
label, conf = keywordSentiment(a.Title + " " + a.Body)
+3 -2
View File
@@ -76,7 +76,8 @@ func (b *Builder) Build(ctx context.Context, ticker, profile string) (Report, in
all = append(all, s.Citations...)
}
all = model.MarkStale(all, model.StaleSession(time.Now()))
raw, _ := json.Marshal(map[string]any{"ticker": ticker, "sections": sections, "synthesis": synth})
narasi := b.narasiAwam(ctx, ticker, synth, sections)
raw, _ := json.Marshal(map[string]any{"ticker": ticker, "sections": sections, "synthesis": synth, "narasi_awam": narasi})
citesRaw, _ := json.Marshal(all)
id, err := b.DB.SaveReport(ticker, string(raw), string(citesRaw))
if err != nil {
@@ -86,7 +87,7 @@ func (b *Builder) Build(ctx context.Context, ticker, profile string) (Report, in
Ticker: ticker, GeneratedAt: todayStr(),
Sections: sections, Synthesis: synth,
AgentScores: results, AllCitations: all,
NarasiAwam: b.narasiAwam(ctx, ticker, synth, sections),
NarasiAwam: narasi,
}, id, nil
}