feat(06-03): add AI sync backend — heuristic mapper, LLM generator, API endpoint

- Create lightsync/api/sync.py with POST /api/sync/generate and GET /api/sync/llm-available
- heuristic_generate: intensity-to-animation mapping, chroma-to-color, beat-snapped block placement
- llm_generate: Anthropic claude-3-haiku with lazy init, JSON parse + validation
- section_range filtering for per-section generation (D-11)
- Register sync.router with prefix /api/sync in main.py
This commit is contained in:
Claude
2026-04-07 11:45:49 +00:00
parent 2fef43dcc3
commit b6aacad9ce
2 changed files with 345 additions and 1 deletions

View File

@@ -44,12 +44,13 @@ def create_app() -> FastAPI:
app = FastAPI(title="LightSync", lifespan=lifespan, redirect_slashes=False)
# API routes (registered before static mount — see Pattern 7)
from lightsync.api import shows, devices, ws, audio, timeline
from lightsync.api import shows, devices, ws, audio, timeline, sync
app.include_router(shows.router, prefix="/api/shows")
app.include_router(devices.router, prefix="/api/devices")
app.include_router(ws.router)
app.include_router(audio.router, prefix="/api/audio")
app.include_router(timeline.router, prefix="/api")
app.include_router(sync.router, prefix="/api/sync")
# Serve uploaded audio files so <audio src=...> can load them
shows_dir = Path("/app/shows")