news-digest: fixes from first deploy on ana-docker
Three iterations to get end-to-end:
1. Dockerfile missed COPY run-digest.sh — cron's exec target wasn't
in the image, every fire failed. Added COPY + chmod.
2. Jinja template used {{ list|sum(attribute='items') }} which
sum()s lists with start=0 → TypeError int+list. Switched to
computing reddit_total / tech_total in Python and passing as
template args.
3. LLM defaulted to qwen3.5-35-a3b which (a) is broken in
llama-swap (model process exits on launch), (b) when working,
defaults to extended-thinking mode that eats the entire token
budget without producing any visible content. Same pattern with
qwen3.6-35-a3b. Switched default to granite-4-small — small (4B),
fast (~1s/call), no thinking-mode pathology, returns clean JSON.
Whole pipeline now runs in ~35s total across 8 sources.
Also hardened the LLM response parser to fall back to
reasoning_content when content is empty — catches the thinking-mode
case if anyone ever points the digest at one of those models. Plus
the deploy playbook gained DOCKER_BUILDKIT=0 because ana-docker is
on docker 20.10 which doesn't carry the buildx driver versions our
newer client expects ("client version 1.52 is too new"). Real fix is
upgrading docker on the fleet — separate workstream.
This commit is contained in:
@@ -275,7 +275,11 @@ def summarize_source(src: Source) -> None:
|
||||
timeout=LLAMA_SWAP_TIMEOUT,
|
||||
)
|
||||
r.raise_for_status()
|
||||
content = r.json()["choices"][0]["message"]["content"].strip()
|
||||
msg = r.json()["choices"][0]["message"]
|
||||
# Models in extended-thinking mode (e.g. Qwen3.x defaults) put
|
||||
# output in reasoning_content and leave content empty until they
|
||||
# exit thinking — fall back so we get *something* to parse.
|
||||
content = (msg.get("content") or msg.get("reasoning_content") or "").strip()
|
||||
# Some models wrap JSON in ```...``` even when told not to.
|
||||
content = re.sub(r"^```(?:json)?\s*|\s*```$", "", content, flags=re.M).strip()
|
||||
mapped = {x.get("id"): x for x in json.loads(content)}
|
||||
@@ -306,9 +310,13 @@ def render(reddit_sources: list[Source], tech_sources: list[Source],
|
||||
env.filters["domain"] = _domain
|
||||
template = env.get_template("digest.html.j2")
|
||||
edition = "morning" if generated_at.hour < 14 else "evening"
|
||||
reddit_kept = [s for s in reddit_sources if s.items]
|
||||
tech_kept = [s for s in tech_sources if s.items]
|
||||
return template.render(
|
||||
reddit_sources=[s for s in reddit_sources if s.items],
|
||||
tech_sources=[s for s in tech_sources if s.items],
|
||||
reddit_sources=reddit_kept,
|
||||
tech_sources=tech_kept,
|
||||
reddit_total=sum(len(s.items) for s in reddit_kept),
|
||||
tech_total=sum(len(s.items) for s in tech_kept),
|
||||
generated_at=generated_at,
|
||||
edition=edition,
|
||||
edition_short="AM" if edition == "morning" else "PM",
|
||||
|
||||
Reference in New Issue
Block a user