feat(insights): allow AI observations to link directly to devices

The LLM can now copy device_id from the snapshot into its observation
output. The worker wires it into the insight's device_id FK so the UI
can link directly to the referenced device.
This commit is contained in:
Graham McIntire 2026-05-11 10:40:59 -05:00
parent f0058a4d77
commit e6e1326689
2 changed files with 4 additions and 2 deletions

View file

@ -53,7 +53,8 @@ defmodule Towerops.LLM.NetworkInsightPrompt do
Respond ONLY with JSON of this shape:
{"observations": [
{"title": "...", "description": "...", "urgency": "critical"|"warning"|"info",
"recommended_action": "..."}
"recommended_action": "...",
"device_id": "..." (optional copy the exact device_id from the snapshot for any device you reference)}
]}
Aim for 05 observations. Quality over quantity.

View file

@ -91,7 +91,8 @@ defmodule Towerops.Workers.AiNetworkInsightWorker do
llm_summary: obs.description,
llm_model: model,
llm_enriched_at: now,
metadata: metadata
metadata: metadata,
device_id: Map.get(obs.metadata, "device_id")
}
case Insights.insert_insight_if_new(attrs) do