UI Updates
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
from fastapi import APIRouter, BackgroundTasks, HTTPException, Query
|
||||
from fastapi import APIRouter, BackgroundTasks, HTTPException, Query, Depends
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
from app.internal import firestore as fstore
|
||||
from app.internal.auth import require_admin_token
|
||||
|
||||
|
||||
class TranscriptUpdate(BaseModel):
|
||||
transcript: str
|
||||
|
||||
router = APIRouter(prefix="/calls", tags=["calls"])
|
||||
|
||||
@@ -51,3 +57,41 @@ async def reprocess_call(call_id: str, background_tasks: BackgroundTasks):
|
||||
gcs_uri=gcs_uri,
|
||||
)
|
||||
return {"ok": True, "call_id": call_id}
|
||||
|
||||
|
||||
@router.patch("/{call_id}/transcript")
|
||||
async def patch_transcript(
|
||||
call_id: str,
|
||||
body: TranscriptUpdate,
|
||||
background_tasks: BackgroundTasks,
|
||||
_: dict = Depends(require_admin_token),
|
||||
):
|
||||
"""Overwrite a call's transcript and re-run intelligence extraction."""
|
||||
call = await fstore.doc_get("calls", call_id)
|
||||
if not call:
|
||||
raise HTTPException(404, f"Call '{call_id}' not found.")
|
||||
|
||||
# Save new transcript, clear stale intelligence fields
|
||||
await fstore.doc_set("calls", call_id, {
|
||||
"transcript": body.transcript,
|
||||
"transcript_corrected": None,
|
||||
"tags": [],
|
||||
"severity": "unknown",
|
||||
"location": None,
|
||||
"units": [],
|
||||
"vehicles": [],
|
||||
"embedding": None,
|
||||
})
|
||||
|
||||
from app.routers.upload import _run_extraction_pipeline
|
||||
background_tasks.add_task(
|
||||
_run_extraction_pipeline,
|
||||
call_id=call_id,
|
||||
node_id=call.get("node_id"),
|
||||
system_id=call.get("system_id"),
|
||||
talkgroup_id=call.get("talkgroup_id"),
|
||||
talkgroup_name=call.get("talkgroup_name"),
|
||||
transcript=body.transcript,
|
||||
segments=call.get("segments"),
|
||||
)
|
||||
return {"ok": True, "call_id": call_id}
|
||||
|
||||
Reference in New Issue
Block a user