Implement per-system AI flags

This commit is contained in:
Logan
2026-04-27 00:50:01 -04:00
parent 5f83194420
commit 640667c9f9
4 changed files with 146 additions and 4 deletions
+18 -4
View File
@@ -161,21 +161,34 @@ async def _run_intelligence_pipeline(
flags = await get_flags()
# Resolve per-system overrides: system flag=False beats global flag=True,
# but global flag=False beats everything (master switch).
system_ai_flags: dict = {}
if system_id:
sys_doc = await fstore.doc_get("systems", system_id)
system_ai_flags = (sys_doc or {}).get("ai_flags") or {}
def _flag(name: str) -> bool:
if not flags[name]: # global master off
return False
return system_ai_flags.get(name, True) # system override, default inherit
transcript: Optional[str] = None
segments: list[dict] = []
# Step 1: Transcription
if gcs_uri:
if flags["stt_enabled"]:
if _flag("stt_enabled"):
transcript, segments = await transcription.transcribe_call(
call_id, gcs_uri, talkgroup_name, system_id=system_id
)
else:
logger.info(f"STT disabled — skipping transcription for call {call_id}")
scope = "globally" if not flags["stt_enabled"] else f"system {system_id}"
logger.info(f"STT disabled ({scope}) — skipping transcription for call {call_id}")
# Step 2: Scene detection + intelligence extraction
scenes: list[dict] = []
if flags["correlation_enabled"]:
if _flag("correlation_enabled"):
if transcript:
scenes = await intelligence.extract_scenes(
call_id, transcript, talkgroup_name,
@@ -183,7 +196,8 @@ async def _run_intelligence_pipeline(
node_id=node_id,
)
else:
logger.info(f"Correlation disabled — skipping scene extraction and correlation for call {call_id}")
scope = "globally" if not flags["correlation_enabled"] else f"system {system_id}"
logger.info(f"Correlation disabled ({scope}) — skipping scene extraction and correlation for call {call_id}")
# Step 3: Correlate each scene independently.
# A single recording can produce multiple incidents on a busy channel.