feat: restore roast-of-the-day with 14-day prompt history

Separate roast generation from motivation again and pass cached roasts
from the last 14 days into the OpenRouter prompt to reduce repetition.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Frank Schwenk
2026-06-17 08:45:09 +02:00
parent c59c3069c4
commit 24ac7f2f48
4 changed files with 104 additions and 11 deletions
+5 -4
View File
@@ -11,7 +11,7 @@ from fastapi import Depends, FastAPI, HTTPException, Request
from fastapi.responses import FileResponse, JSONResponse
from fastapi.staticfiles import StaticFiles
from server.ai import generate_daily_motivation, get_roast_of_the_day
from server.ai import generate_daily_motivation, generate_roast_of_the_day, get_roast_of_the_day
from server.auth import create_token, require_auth, verify_pin
from server.config_loader import load_meds_config, slot_to_dict, today_str
from server.db import ensure_schema, get_db, new_id, utc_now_iso
@@ -40,13 +40,14 @@ _configure_logging()
logger = logging.getLogger(__name__)
async def _ensure_today_motivation() -> None:
async def _ensure_today_ai_texts() -> None:
config = load_meds_config()
db = await get_db()
try:
await generate_daily_motivation(db, config.timezone)
await generate_roast_of_the_day(db, config.timezone)
except Exception:
logger.exception("Startup motivation generation failed")
logger.exception("Startup AI text generation failed")
finally:
await db.close()
@@ -57,7 +58,7 @@ async def lifespan(app: FastAPI):
await ensure_schema(db)
await db.close()
start_scheduler()
asyncio.create_task(_ensure_today_motivation())
asyncio.create_task(_ensure_today_ai_texts())
yield