mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-09-16 05:10:42 -07:00
Routes were calling model_dump(exclude_none=True), which drops every client-sent null before it reaches the service. The service then layered on its own `if value is not None` guard. Net effect: setting a nullable column back to null was a no-op — the MCPPage default-voice picker sends null when the user picks "no default" and the row was silently keeping whatever was there before. Switched the routes to exclude_unset=True so absent fields stay absent but explicit nulls survive the dump, and centralised the per-field nullability check in the service. The check inspects the SQLAlchemy column metadata so non-nullable columns (stt_model, llm_model, the chord key lists) still drop nulls instead of crashing the request, while default_playback_voice_id can finally be cleared.
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
"""User settings endpoints — capture/refine and generation defaults."""
|
|
|
|
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
|
|
from .. import models
|
|
from ..database import get_db
|
|
from ..services import settings as settings_service
|
|
|
|
router = APIRouter(prefix="/settings", tags=["settings"])
|
|
|
|
|
|
@router.get("/captures", response_model=models.CaptureSettingsResponse)
|
|
async def get_capture_settings_endpoint(db: Session = Depends(get_db)):
|
|
return settings_service.get_capture_settings(db)
|
|
|
|
|
|
@router.put("/captures", response_model=models.CaptureSettingsResponse)
|
|
async def update_capture_settings_endpoint(
|
|
patch: models.CaptureSettingsUpdate,
|
|
db: Session = Depends(get_db),
|
|
):
|
|
return settings_service.update_capture_settings(db, patch.model_dump(exclude_unset=True))
|
|
|
|
|
|
@router.get("/generation", response_model=models.GenerationSettingsResponse)
|
|
async def get_generation_settings_endpoint(db: Session = Depends(get_db)):
|
|
return settings_service.get_generation_settings(db)
|
|
|
|
|
|
@router.put("/generation", response_model=models.GenerationSettingsResponse)
|
|
async def update_generation_settings_endpoint(
|
|
patch: models.GenerationSettingsUpdate,
|
|
db: Session = Depends(get_db),
|
|
):
|
|
return settings_service.update_generation_settings(db, patch.model_dump(exclude_unset=True))
|