feat: desk ia
This commit is contained in:
@@ -1146,11 +1146,13 @@ def init_db():
|
|||||||
]
|
]
|
||||||
for _desk in _AI_DESK_DEFAULTS:
|
for _desk in _AI_DESK_DEFAULTS:
|
||||||
try:
|
try:
|
||||||
|
# Guard by type, not name — so renaming a desk doesn't trigger a re-seed
|
||||||
c.execute(
|
c.execute(
|
||||||
"INSERT OR IGNORE INTO ai_desks (name, type, active, system_prompt, instruments, config) "
|
"INSERT INTO ai_desks (name, type, active, system_prompt, instruments, config) "
|
||||||
"VALUES (?,?,?,?,?,?)",
|
"SELECT ?,?,?,?,?,? WHERE NOT EXISTS (SELECT 1 FROM ai_desks WHERE type = ?)",
|
||||||
(_desk["name"], _desk["type"], _desk["active"],
|
(_desk["name"], _desk["type"], _desk["active"],
|
||||||
_desk["system_prompt"], _desk["instruments"], _desk["config"])
|
_desk["system_prompt"], _desk["instruments"], _desk["config"],
|
||||||
|
_desk["type"])
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -544,13 +544,18 @@ def _get_relevant_events(
|
|||||||
(SELECT GROUP_CONCAT(DISTINCT a.instrument)
|
(SELECT GROUP_CONCAT(DISTINCT a.instrument)
|
||||||
FROM causal_event_analyses a
|
FROM causal_event_analyses a
|
||||||
WHERE a.market_event_id = e.id) AS analyzed_instruments,
|
WHERE a.market_event_id = e.id) AS analyzed_instruments,
|
||||||
(SELECT a.template_id FROM causal_event_analyses a WHERE a.market_event_id = e.id ORDER BY a.id DESC LIMIT 1) AS template_id,
|
(SELECT a.template_id FROM causal_event_analyses a WHERE a.market_event_id = e.id ORDER BY a.id DESC LIMIT 1) AS cea_template_id,
|
||||||
(SELECT a.id FROM causal_event_analyses a WHERE a.market_event_id = e.id ORDER BY a.id DESC LIMIT 1) AS analysis_id
|
(SELECT a.id FROM causal_event_analyses a WHERE a.market_event_id = e.id ORDER BY a.id DESC LIMIT 1) AS analysis_id
|
||||||
FROM market_events e
|
FROM market_events e
|
||||||
ORDER BY e.start_date DESC
|
ORDER BY e.start_date DESC
|
||||||
""").fetchall()
|
""").fetchall()
|
||||||
conn.close()
|
conn.close()
|
||||||
all_events = [dict(r) for r in rows]
|
# Use cea_template_id (from causal_event_analyses) explicitly to avoid
|
||||||
|
# any collision with an e.* column named template_id
|
||||||
|
all_events = [
|
||||||
|
{**dict(r), "template_id": r["cea_template_id"]}
|
||||||
|
for r in rows
|
||||||
|
]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"[instrument_service] Could not load market events: {e}")
|
logger.warning(f"[instrument_service] Could not load market events: {e}")
|
||||||
return []
|
return []
|
||||||
|
|||||||
Reference in New Issue
Block a user