fix: 3 bugs from system logs — timedelta, scoring IndexError, lxml

- database.py: add timedelta to datetime import (used in
  get_recent_economic_surprises, was raising NameError)
- ai_analyzer.py: scoring split was searching French string
  'Retourne UNIQUEMENT ce JSON valide:' but prompt is now in English
  'Return ONLY this valid JSON:' — caused IndexError crashing every cycle
- requirements.txt: add lxml>=5.0.0 (yfinance earnings_dates dependency,
  was silently failing all 23 ticker fetches every hour)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OpenSquared
2026-06-22 17:11:23 +02:00
parent 1cc192a221
commit 9b98594c07
3 changed files with 5 additions and 2 deletions

View File

@@ -738,7 +738,9 @@ Return ONLY this valid JSON:
# Extract the return-schema portion from `user` so batches use the identical full schema
# (includes bucket id/label/max definitions that GPT-4o needs to populate correctly)
_return_schema = user.split("Retourne UNIQUEMENT ce JSON valide:\n", 1)[1]
_split_key = "Return ONLY this valid JSON:\n"
_parts = user.split(_split_key, 1)
_return_schema = _parts[1] if len(_parts) == 2 else user
# Build lessons feedback block for the scorer
lessons_header = ""