From dab4f07b07e58b0dea076aa1aa8de754acd0c9f3 Mon Sep 17 00:00:00 2001 From: Paul Booth Date: Wed, 1 Jul 2026 16:40:34 -0400 Subject: [PATCH] Another alignment fix to the CSS for desktop rendering --- inbrief.py | 13 ++++++++++--- tests/test_inbrief.py | 19 +++++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/inbrief.py b/inbrief.py index 629cf9c..c0bad12 100644 --- a/inbrief.py +++ b/inbrief.py @@ -654,7 +654,7 @@ def render_email_html( .content ol li { position:relative; margin:0 0 22px; padding-left:28px; color:#1c1a16; font:400 18px/1.5 Newsreader,Georgia,'Times New Roman',serif; } -.content .story-number { position:absolute; left:0; top:3px; color:#9a2d27; +.content .story-number { position:absolute; left:0; top:2px; color:#9a2d27; font:400 .85em 'IBM Plex Mono','Courier New',monospace; } .content hr { border:0; border-top:1px solid #d8d2c6; margin:38px 0; } .content strong { font-weight:600; } @@ -824,12 +824,19 @@ def generate_anthropic_digest( cfg, "anthropic", "api_key", "INBRIEF_ANTHROPIC_API_KEY" ) client = anthropic.Anthropic(api_key=api_key, timeout=timeout) - message = client.messages.create( + with client.messages.stream( model=model, max_tokens=max_tokens, system=instructions, messages=[{"role": "user", "content": prompt}], - ) + ) as stream: + message = stream.get_final_message() + if message.stop_reason == "max_tokens": + log.warning( + "Anthropic digest was truncated at the [ai] max_tokens limit " + "(%d); consider raising it.", + max_tokens, + ) text_blocks = [ block.text for block in message.content if getattr(block, "type", "") == "text" ] diff --git a/tests/test_inbrief.py b/tests/test_inbrief.py index 97e4cb7..effc19e 100644 --- a/tests/test_inbrief.py +++ b/tests/test_inbrief.py @@ -345,13 +345,24 @@ def test_anthropic_digest_supports_opus_without_temperature(monkeypatch): calls = [] clients = [] - class FakeMessages: - def create(self, **kwargs): - calls.append(kwargs) + class FakeStream: + def __enter__(self): + return self + + def __exit__(self, *exc_info): + return False + + def get_final_message(self): return SimpleNamespace( - content=[SimpleNamespace(type="text", text="Claude digest")] + content=[SimpleNamespace(type="text", text="Claude digest")], + stop_reason="end_turn", ) + class FakeMessages: + def stream(self, **kwargs): + calls.append(kwargs) + return FakeStream() + class FakeAnthropic: def __init__(self, **kwargs): clients.append(kwargs)