feat: API routes — speakers, rooms, search, RAG
Full implementations replacing stubs: speakers CRUD with utterance count, rooms list + mute/unmute via pipeline, FTS5-based search, RAG /ask and /summary endpoints. 15 route tests (8 new) all passing; 35 total. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+32
-2
@@ -1,6 +1,36 @@
|
||||
from fastapi import APIRouter
|
||||
import sqlite3
|
||||
import httpx
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from app.shared.config import Settings
|
||||
|
||||
|
||||
def make_router(settings, db_factory):
|
||||
def make_router(settings: Settings, db_factory):
|
||||
router = APIRouter(prefix="/api/rooms")
|
||||
|
||||
@router.get("")
|
||||
def list_rooms():
|
||||
db: sqlite3.Connection = db_factory()
|
||||
rows = db.execute(
|
||||
"SELECT id, name, device_label, is_active, last_seen, created_at FROM rooms ORDER BY name"
|
||||
).fetchall()
|
||||
return [dict(r) for r in rows]
|
||||
|
||||
@router.post("/{room_id}/mute")
|
||||
def mute_room(room_id: int):
|
||||
db: sqlite3.Connection = db_factory()
|
||||
row = db.execute("SELECT name FROM rooms WHERE id=?", (room_id,)).fetchone()
|
||||
if not row:
|
||||
raise HTTPException(404, "Room not found")
|
||||
httpx.post(f"{settings.pipeline_internal_url}/internal/rooms/{row['name']}/mute")
|
||||
return {"ok": True, "room": row["name"]}
|
||||
|
||||
@router.post("/{room_id}/unmute")
|
||||
def unmute_room(room_id: int):
|
||||
db: sqlite3.Connection = db_factory()
|
||||
row = db.execute("SELECT name FROM rooms WHERE id=?", (room_id,)).fetchone()
|
||||
if not row:
|
||||
raise HTTPException(404, "Room not found")
|
||||
httpx.post(f"{settings.pipeline_internal_url}/internal/rooms/{row['name']}/unmute")
|
||||
return {"ok": True, "room": row["name"]}
|
||||
|
||||
return router
|
||||
|
||||
Reference in New Issue
Block a user