Commit graph osint-dashboard/news/summerizer/summarizer.py
Author SHA1 Message Date
Sirius DevOps
653e02b09f fix(summarizer): stamp ticker and map urls from the article, not the model
The reduce model returns url="" and save_batch was persisting that blank.
Match each headline to a selected article title and store that article's
url. A null article url or an ambiguous match stores "" — never a guessed
or model-supplied URL.
2026-11-14 00:32:43 -05:00
Sirius DevOps
d40244900e feat(summarizer): collapse syndicated wire copies before selection
The map phase grades every article, but a single wire story arrives from
many station domains with an identical headline (the measured run selected
12 blocks that were only two stories, then produced a ticker with five
summit rows and one FAA row). Dedupe now runs before the threshold/cap, so
SUMMARY_TOP_N buys distinct stories.

- intel.py: pure `dedupe_blocks(blocks, *, similarity, enabled)` plus
  `normalize_title` / `title_similarity`. Titles are lowercased, punctuation
  flattened and a short digit-free trailing source suffix (" - KCCI",
  " | CNN", " — AP") dropped; blocks match on equal normalised titles or
  word-set Jaccard / word-sequence difflib ratio >= similarity (default
  0.85). Best score wins the group (ties -> earliest), matching is against
  the representative only (no transitive chaining), and differing categories
  or differing numbers never merge. Blocks now carry their article title.
- summarizer.py: dedupe graded blocks before select_graded() and log
  `dedupe 21 -> 9 (kept 9, duplicates 12)`; SUMMARY_DEDUPE=0 skips it,
  SUMMARY_DEDUPE_SIMILARITY tunes it. persist_article_scores() still writes
  one row per graded article, with duplicates selected=false and
  duplicate_of pointing at the surviving article id.
- article_scores.duplicate_of INTEGER NULL in ensure_tables() and alembic
  013 (upgrade/downgrade verified against Postgres 16).
- docs/news.md + .env.example document both knobs.

Replaying the observed summary id=6 (21 graded, 9 distinct titles) now keeps
9 and, at min_score=60/top_n=12, selects 2 — the 11 dropped copies that
scored >= 60 are stored selected=false with a duplicate_of pointer.
2026-11-13 22:14:44 -05:00
backend
57c0444a69 fix(summarizer): ignore future-dated rows; require a score floor for the fallback
Two leaks let low-value items reach the operator brief:

- get_recent_news() only bounded the window from below, so event
  listings dated days ahead (wiseye.org, +3d/+6d) were re-fetched,
  re-graded and re-billed every interval for a week. The window is now
  (now - N, now]; NULL timestamps stay excluded as before.
- select_graded() returned ordered[:fallback_top] with no floor, so a
  15/100 event listing entered the brief as 'low'. New
  SUMMARY_FALLBACK_MIN_SCORE (default 40, clamped 0-100) filters the
  fallback set; when nothing clears it the reduce phase gets empty DATA
  and writes the empty-brief response. The fallback WARNING now logs the
  floor.

Docs: .env.example and docs/news.md document the new knob and window.
2026-11-13 21:56:46 -05:00
hermes-backend
853e87b7c5 feat(summarizer): score articles in the map phase, brief only the important ones
The map prompt now grades every article 0-100 against an explicit rubric as
the first line of its block; the summarizer parses Score:, falls back to the
Importance: label when the line is missing, ranks blocks best-first and passes
only score >= SUMMARY_MIN_SCORE (capped at SUMMARY_TOP_N) to the reduce phase.

- new pure helpers in intel.py: parse_map_scores(), select_graded(), join_blocks()
- reduce prompts drop the 'fill the brief with minor incidents and crime'
  filler instructions and the 'fill ticker with medium then low' clause
- new article_scores table (ensure_tables + alembic 012) persists every grade
  with selected/summary_id/model so thresholds can be tuned from data
- SUMMARY_MIN_SCORE (60), SUMMARY_TOP_N (12), SUMMARY_FALLBACK_TOP (3) env knobs
2026-11-13 21:47:30 -05:00
Sirius DevOps
c48788d4b6
fix(map): geofence delete, vessel snapshots, sentinel cache, news briefs
Geofences could be drawn but not removed. VesselAPI Hormuz dots vanished
on restart and DVR skipped between the 5 daily polls. Sentinel-1 re-hit
STAC on every pan and often painted a neighbouring swath. Executive
briefs truncated; ticker stayed empty unless something was critical.

- Layer-panel list + polygon popup DELETE /api/geofences/{id}
- Persist VesselAPI polls to vessels (UTC-day purge, DVR as-of, boot hydrate)
- Cache Sentinel-1 by 2° cell; pick covering scene; clip Leaflet tiles
- Retry truncated LLM JSON; ticker falls back to medium/low; 3-min HUD poll
2026-08-29 20:40:27 -04:00
Sirius DevOps
7822d45f37 fix: stop summarizer from bailing to a canned empty brief
The reduce/recap prompts told the model to AND STOP with "No qualifying…"
whenever nothing looked breaking enough, so full article batches became
one sentence. Always write summary_en from the provided stories; ticker
and map may still be empty. Futures/market tape stay ignored.
2026-08-28 23:20:40 -04:00
Sirius DevOps
49ee5fe7a3 feat: 23:00 daily news recap; prompts drop futures
Summarizer still runs the 15-min analyst, plus a 24h breaking-news recap
at 23:00 America/New_York. HUD pins kind=daily_recap. Prompts ignore
futures/market tape.
2026-08-28 22:53:31 -04:00
Sirius DevOps
8643153954 feat: continuous news scrape + 15-min analyst, expand urls.txt
Scraper loops with NEWS_SCRAPE_INTERVAL_S (default 10s after each
crawl). Summarizer runs every NEWS_SUMMARIZE_INTERVAL_S (default 900)
over the last 15 minutes of articles. Feed list replaced from the
k8s scrapy-urls configmap (334 sources).
2026-08-28 20:53:32 -04:00
Sirius DevOps
8f3699f133 feat: summarize hourly news via Nous portal into brief/ticker/map 2026-08-28 17:06:55 -04:00
Sirius DevOps
5849d72299 Fix news scraper feed discovery + summarizer startup race
Some checks failed
build-and-deploy / build (push) Failing after 4s
The vendored spider only started on urls.txt lines containing '/rss' or
'/feed' — but the curated urls.txt holds 200 homepages, so the crawler
matched ZERO feeds and silently did nothing (2ms, 0 items). Rewrite the
spider with feed autodiscovery: fetch each homepage, find its
<link rel="alternate" type="application/rss+xml"> (or /feed|/rss link),
parse the feed, then follow each item to extract the article. Bump
DEPTH_LIMIT 1->3 (homepage -> feed -> article).

Also make the summarizer resilient to booting before the app container has
run alembic (docker-compose only guarantees `db` is up): add idempotent
ensure_tables() mirroring the scraper's CREATE TABLE IF NOT EXISTS.
2026-08-24 17:42:06 -04:00
Sirius DevOps
91f436390b Add news pipeline: hourly scraper + Gemini summarizer in compose
Some checks failed
build-and-deploy / build (push) Failing after 4s
Vendor the newsPipeline scraper + summarizer into the repo and wire them into
docker-compose against the EXISTING osint-db (no second Postgres), replacing
the upstream k8s CronJobs with in-compose wall-clock loops (:00 scrape, :05
summarize).

- news/scraper: vendored Scrapy project (257 RSS feeds) + hourly loop
  scheduler (run_news_scraper.py)
- news/summerizer: vendored Gemini map-reduce summarizer, cleaned:
  * fix broken google-genai response handling (_extract_text, defensive)
  * fix malformed INSERT/GRANT query in save_summary_to_db
  * OSINT-neutral default MAP_PROMPT; futures/markets language gated behind
    INCLUDE_FUTURES=0 (yfinance lazy-imported)
  * env-configurable model, batch size, lookback window
  + hourly loop scheduler (run_news_summarizer.py, :05)
- alembic 003_news: idempotent articles + article_summaries tables
- API: GET /api/news and GET /api/news/summaries (+ models, schemas)
- tests/test_api_news.py: 5 DB-backed contract tests (all pass vs real PG)
- docs/news.md + .env.example updates

Both services run under the `ingest` compose profile (matching the
ingester/camera-scraper pattern) and build arm64 on the Pi via the existing
Forgejo CI workflow. telebot left out of scope (reserved env only).
2026-08-24 17:28:46 -04:00