root 3a9881d36f feat: Profile-System für unterschiedliche Use-Cases (Sitzungsprotokoll, später Arzt-Diktat etc.)
Mac-Worker:
- profiles/meeting.yaml — extrahiert die bisherigen Prompts + DOCX-Layout
- core/profiles.py — YAML-Loader mit Cache und Fallback
- ollama_client.summarize/make_protocol nehmen profile_name
- docx_export: generischer Renderer aus profile.docx (meta + sections mit
  Typ text/list/tasks/transcript)
- /api/profiles listet verfügbare Profile
- pyyaml als Dependency

LXC:
- Job.profile + User.default_profile (Migration: ALTER TABLE)
- /api/profiles proxy mit 60s-Cache und Fallback
- Upload-Form akzeptiert profile (Server-Default: user.default_profile)
- Pipeline gibt Profile bei summarize/protocol/docx an Mac weiter
- PATCH /api/auth/me — User kann Standard-Profil ändern

Frontend:
- Profile-Dropdown im Upload (nur sichtbar wenn ≥2 Profile)
- Settings-Karte "Mein Standard-Profil" (nur wenn ≥2 Profile)
- Job-Zeile zeigt grünes Profile-Tag (nur wenn relevant)

Neue Profile = neue YAML-Datei in mac-worker/profiles/ — kein Code-Deploy
nötig, der Mac-Worker liest sie beim Start ein.
2026-05-14 03:11:30 +00:00

39 lines
1.2 KiB
Python

"""Liefert die im Mac-Worker verfügbaren Verarbeitungs-Profile aus.
Cached die Liste 60 s, damit der Mac nicht bei jedem Reload getroffen wird.
"""
from __future__ import annotations
import logging
import time
from fastapi import APIRouter, Depends
from app.core.auth import current_user
from app.core.mac_client import MacClient
from app.models.user import User
router = APIRouter(prefix="/api", tags=["profiles"])
log = logging.getLogger("voice-agent.profiles")
_CACHE: dict = {"profiles": None, "ts": 0.0}
_TTL = 60.0
_FALLBACK = [{"name": "meeting", "display_name": "Sitzungsprotokoll", "language": "de"}]
@router.get("/profiles")
async def list_profiles(_: User = Depends(current_user)):
now = time.time()
if _CACHE["profiles"] is not None and now - _CACHE["ts"] < _TTL:
return {"profiles": _CACHE["profiles"]}
try:
profiles = await MacClient().list_profiles()
if not profiles:
profiles = _FALLBACK
except Exception as e: # noqa: BLE001
log.warning("Konnte Profile vom Mac nicht laden: %s — Fallback wird genutzt", e)
profiles = _FALLBACK
_CACHE["profiles"] = profiles
_CACHE["ts"] = now
return {"profiles": profiles}