ratandeep commited on
Commit
097dfd6
·
verified ·
1 Parent(s): 2e8c86f

SP3 generative song cards

Browse files
Files changed (1) hide show
  1. server.py +13 -0
server.py CHANGED
@@ -59,6 +59,10 @@ class LocaleReq(BaseModel):
59
  lon: float
60
 
61
 
 
 
 
 
62
  # ---------------------------------------------------------------------------
63
  # Graceful fallbacks (never let the radio go silent)
64
  # ---------------------------------------------------------------------------
@@ -165,6 +169,15 @@ def create_api() -> FastAPI:
165
  except Exception:
166
  return JSONResponse({"resolved": False})
167
 
 
 
 
 
 
 
 
 
 
168
  @api.get("/api/stalls")
169
  def api_stalls():
170
  # Pre-synthesized filler clips the radio plays instantly while a real
 
59
  lon: float
60
 
61
 
62
+ class SongCardReq(BaseModel):
63
+ ctx: Optional[Dict[str, Any]] = None
64
+
65
+
66
  # ---------------------------------------------------------------------------
67
  # Graceful fallbacks (never let the radio go silent)
68
  # ---------------------------------------------------------------------------
 
169
  except Exception:
170
  return JSONResponse({"resolved": False})
171
 
172
+ @api.post("/api/song_card")
173
+ def api_song_card(req: SongCardReq):
174
+ # AI invents a fictional record (validated musical params). On any failure,
175
+ # return {card: None} so the client simply skips it.
176
+ try:
177
+ return {"card": proxy.make_song_card(req.ctx)}
178
+ except Exception:
179
+ return JSONResponse({"card": None})
180
+
181
  @api.get("/api/stalls")
182
  def api_stalls():
183
  # Pre-synthesized filler clips the radio plays instantly while a real