feat: desk ia

This commit is contained in:
OpenSquared
2026-06-29 20:21:52 +02:00
parent 551ebc3ef4
commit f4a55a8009
2 changed files with 160 additions and 5 deletions

View File

@@ -1658,17 +1658,30 @@ def check_new_market_events(
# Auto-assign or auto-create causal templates for eco events
if "eco" in sources and bool(eco_cfg.get("auto_template", False)):
eco_events = results.get("eco", [])
logger.info(f"[check_events/auto_template] auto_template=ON, {len(eco_events)} new eco events to process")
if eco_events:
try:
from routers.causal_lab import auto_assign_template
for ev in eco_events:
eid = ev.get("event_id")
eid = ev.get("event_id")
ename = ev.get("name", "?")
logger.info(f"[check_events/auto_template] processing event #{eid} '{ename}'")
if eid:
res = auto_assign_template(eid)
action = res.get("action", "error")
name = res.get("name", "")
logger.info(f"[check_events/auto_template] event #{eid}{action}: '{name}'")
if "error" in res:
logger.warning(f"[check_events/auto_template] event #{eid} error: {res['error']}")
else:
action = res.get("action", "?")
name = res.get("name", "")
tmpl_id = res.get("template_id")
confidence = res.get("confidence", 0)
logger.info(
f"[check_events/auto_template] event #{eid}{action}: "
f"'{name}' (tmpl #{tmpl_id}, conf={confidence:.2f})"
)
except Exception as e:
logger.warning(f"[check_events/auto_template] failed: {e}")
logger.warning(f"[check_events/auto_template] failed: {e}", exc_info=True)
else:
logger.info("[check_events/auto_template] no new eco events this cycle")
return results