Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -203,16 +203,34 @@ def generate_storyboard_with_llm(user_prompt: str, n_shots: int, default_fps: in
|
|
| 203 |
raise ValueError(f"LLM did not return parseable JSON.\nPreview:\n{preview}")
|
| 204 |
|
| 205 |
# Parse & normalize
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
try:
|
| 207 |
shots_raw = json.loads(json_text)
|
| 208 |
-
except Exception
|
| 209 |
-
# Attempt a tiny cleanup: remove trailing commas
|
| 210 |
json_text_clean = re.sub(r",\s*([\]\}])", r"\1", json_text)
|
| 211 |
shots_raw = json.loads(json_text_clean)
|
| 212 |
|
| 213 |
return _normalize_shots(shots_raw, default_fps, default_len)
|
| 214 |
|
| 215 |
|
|
|
|
| 216 |
# =========================
|
| 217 |
# Gradio UI
|
| 218 |
# =========================
|
|
|
|
| 203 |
raise ValueError(f"LLM did not return parseable JSON.\nPreview:\n{preview}")
|
| 204 |
|
| 205 |
# Parse & normalize
|
| 206 |
+
if not json_text.strip():
|
| 207 |
+
# Fallback: model returned nothing. Return a single stub shot.
|
| 208 |
+
print("⚠️ LLM returned empty output. Using fallback storyboard.")
|
| 209 |
+
fallback = [{
|
| 210 |
+
"id": 1,
|
| 211 |
+
"title": "Shot 1",
|
| 212 |
+
"description": f"Fallback shot for: {user_prompt[:50]}",
|
| 213 |
+
"duration": default_len,
|
| 214 |
+
"fps": default_fps,
|
| 215 |
+
"video_length": default_len,
|
| 216 |
+
"steps": 30,
|
| 217 |
+
"seed": None,
|
| 218 |
+
"negative": "",
|
| 219 |
+
"keyframe_path": None
|
| 220 |
+
}]
|
| 221 |
+
return fallback
|
| 222 |
+
|
| 223 |
try:
|
| 224 |
shots_raw = json.loads(json_text)
|
| 225 |
+
except Exception:
|
| 226 |
+
# Attempt a tiny cleanup: remove trailing commas and try again
|
| 227 |
json_text_clean = re.sub(r",\s*([\]\}])", r"\1", json_text)
|
| 228 |
shots_raw = json.loads(json_text_clean)
|
| 229 |
|
| 230 |
return _normalize_shots(shots_raw, default_fps, default_len)
|
| 231 |
|
| 232 |
|
| 233 |
+
|
| 234 |
# =========================
|
| 235 |
# Gradio UI
|
| 236 |
# =========================
|