From ca6b174b5125aca0dce9785188409f3dac61dc9f Mon Sep 17 00:00:00 2001 From: Giorgio Gilestro Date: Mon, 25 May 2026 22:57:29 +0200 Subject: [PATCH] digest: daily + weekly prompt builders (NOVICE/INTERMEDIATE) --- app/services/openrouter.py | 96 +++++++++++++++++++++++++++++++++++- tests/test_digest_prompts.py | 48 ++++++++++++++++++ 2 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 tests/test_digest_prompts.py diff --git a/app/services/openrouter.py b/app/services/openrouter.py index 759e9f5..539c553 100644 --- a/app/services/openrouter.py +++ b/app/services/openrouter.py @@ -30,7 +30,8 @@ OPENROUTER_URL = "https://openrouter.ai/api/v1/chat/completions" # v7 (2026-05-18): Forbid "(Updated HH:MM UTC)" clauses in the date header — # the model was hallucinating future times. The user prompt now carries the # actual current UTC time so the model has accurate temporal context. -PROMPT_VERSION = 8 +# v9 (2026-05-25): Adds daily + weekly digest prompt builders for email. +PROMPT_VERSION = 9 # --- Core: invariant across tone/analysis settings ---------------------------- @@ -507,6 +508,99 @@ def build_user_prompt( return "\n".join(parts) +def build_daily_digest_prompt( + *, + tone: str, + today, + quotes_by_group: dict, + headlines_by_bucket: dict, + reference_line: str, +) -> tuple[str, str]: + """System + user prompt for the once-a-day editorial digest. + + Different from the hourly log: the daily digest reflects on the past + 24h and looks forward to the upcoming session. Longer, less + 'live-blogging,' more contextual. Target ~600 words.""" + tone_clause = ( + "Use plain English. Define any jargon on first use." + if tone.upper() == "NOVICE" + else "Write for a reader who already speaks markets fluently." + ) + system = ( + "You write the daily editorial digest for Read the Markets. " + f"Audience tone: {tone.upper()}. {tone_clause} " + "Cover: (1) what mattered yesterday, (2) what to watch in today's " + "EU and US sessions, (3) one cross-asset thread connecting them. " + "No predictions of price level, no buy/sell language. Target ~600 " + "words. Output HTML using only

,

,