feat: improve error handling for video generation and update duration selection to dropdown
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""Generate router: text, image, video, and image-to-video generation."""
|
||||
from datetime import datetime, timezone
|
||||
|
||||
import httpx
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
|
||||
from ..db import get_conn, get_write_lock
|
||||
@@ -199,9 +200,16 @@ async def generate_video(
|
||||
aspect_ratio=body.aspect_ratio,
|
||||
resolution=body.resolution,
|
||||
)
|
||||
except httpx.HTTPStatusError as exc:
|
||||
detail = (
|
||||
f"OpenRouter API error: {exc.response.status_code} - {exc.response.text}"
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_502_BAD_GATEWAY, detail=detail)
|
||||
except Exception as exc:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_502_BAD_GATEWAY, detail=f"OpenRouter error: {exc}")
|
||||
status_code=status.HTTP_502_BAD_GATEWAY, detail=f"OpenRouter error: {exc}"
|
||||
)
|
||||
|
||||
user_id = current_user.get("id") or current_user.get("sub")
|
||||
job_id = result.get("id", "")
|
||||
@@ -245,9 +253,16 @@ async def generate_video_from_image(
|
||||
aspect_ratio=body.aspect_ratio,
|
||||
resolution=body.resolution,
|
||||
)
|
||||
except httpx.HTTPStatusError as exc:
|
||||
detail = (
|
||||
f"OpenRouter API error: {exc.response.status_code} - {exc.response.text}"
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_502_BAD_GATEWAY, detail=detail)
|
||||
except Exception as exc:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_502_BAD_GATEWAY, detail=f"OpenRouter error: {exc}")
|
||||
status_code=status.HTTP_502_BAD_GATEWAY, detail=f"OpenRouter error: {exc}"
|
||||
)
|
||||
|
||||
user_id = current_user.get("id") or current_user.get("sub")
|
||||
job_id = result.get("id", "")
|
||||
|
||||
@@ -63,21 +63,14 @@ AI{% endblock %} {% block content %}
|
||||
<option value="1080p">1080p</option>
|
||||
</select>
|
||||
|
||||
<label for="duration-t"
|
||||
>Duration: <span id="duration-t-val">5</span>s</label
|
||||
>
|
||||
<input
|
||||
type="range"
|
||||
id="duration-t"
|
||||
name="duration_seconds"
|
||||
min="5"
|
||||
max="60"
|
||||
step="1"
|
||||
value="5"
|
||||
oninput="
|
||||
document.getElementById('duration-t-val').textContent = this.value
|
||||
"
|
||||
/>
|
||||
<label for="duration-t">Duration (seconds)</label>
|
||||
<select id="duration-t" name="duration_seconds">
|
||||
<option value="4">4s</option>
|
||||
<option value="8">8s</option>
|
||||
<option value="12" selected>12s</option>
|
||||
<option value="16">16s</option>
|
||||
<option value="20">20s</option>
|
||||
</select>
|
||||
|
||||
<button type="submit">Generate video</button>
|
||||
</form>
|
||||
@@ -143,21 +136,14 @@ AI{% endblock %} {% block content %}
|
||||
<option value="1080p">1080p</option>
|
||||
</select>
|
||||
|
||||
<label for="duration-i"
|
||||
>Duration: <span id="duration-i-val">5</span>s</label
|
||||
>
|
||||
<input
|
||||
type="range"
|
||||
id="duration-i"
|
||||
name="duration_seconds"
|
||||
min="5"
|
||||
max="60"
|
||||
step="1"
|
||||
value="5"
|
||||
oninput="
|
||||
document.getElementById('duration-i-val').textContent = this.value
|
||||
"
|
||||
/>
|
||||
<label for="duration-i">Duration (seconds)</label>
|
||||
<select id="duration-i" name="duration_seconds">
|
||||
<option value="4">4s</option>
|
||||
<option value="8">8s</option>
|
||||
<option value="12" selected>12s</option>
|
||||
<option value="16">16s</option>
|
||||
<option value="20">20s</option>
|
||||
</select>
|
||||
|
||||
<button type="submit">Generate video from image</button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user