26 lines
762 B
Python
26 lines
762 B
Python
#!/usr/bin/env python3
|
|
"""
|
|
Cron script: generate daily AI financial insight via Groq.
|
|
Run by systemd timer pfm-aiinsight.timer at midnight daily.
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
from app import create_app
|
|
from app.services.ai_service import generate_daily_insight
|
|
|
|
app = create_app()
|
|
|
|
if __name__ == '__main__':
|
|
with app.app_context():
|
|
print('[ai_insight] Generating daily insight...')
|
|
content = generate_daily_insight()
|
|
if content:
|
|
preview = content[:200].replace('\n', ' ')
|
|
print(f'[ai_insight] Done: {preview}...')
|
|
else:
|
|
print('[ai_insight] Failed or skipped (already generated today).')
|
|
sys.exit(1)
|