Files
takeyourmeds/tools/regenerate_ai.py
T
2026-06-10 10:03:35 +02:00

40 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""Regenerate cached AI texts (motivation + oracle)."""
from __future__ import annotations
import argparse
import asyncio
from server.ai import generate_daily_motivation, generate_oracle
from server.config_loader import load_meds_config
from server.db import get_db
async def main() -> None:
parser = argparse.ArgumentParser(description="Regenerate cached AI texts")
parser.add_argument("--motivation", action="store_true", help="Regenerate today's motivation")
parser.add_argument("--oracle", action="store_true", help="Regenerate this week's oracle")
parser.add_argument("--force", action="store_true", help="Regenerate even if cache exists")
args = parser.parse_args()
if not args.motivation and not args.oracle:
args.motivation = True
args.oracle = True
config = load_meds_config()
db = await get_db()
try:
if args.motivation:
result = await generate_daily_motivation(db, config.timezone, force=args.force)
print("motivation:", result)
if args.oracle:
result = await generate_oracle(db, config.timezone, force=args.force)
print("oracle:", result)
finally:
await db.close()
if __name__ == "__main__":
asyncio.run(main())