feat: add MuAPI video generation tool#196
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughA new ChangesMuApi Video Generation Tool
Sequence DiagramsequenceDiagram
participant Caller
participant MuApiVideoGenerationTool
participant muapi_ai as muapi.ai API
Caller->>MuApiVideoGenerationTool: text_to_video(prompt, save_at, duration, config)
MuApiVideoGenerationTool->>muapi_ai: POST generation request via _submit()
muapi_ai-->>MuApiVideoGenerationTool: request_id
loop _poll until completed or timeout
MuApiVideoGenerationTool->>muapi_ai: GET prediction status
muapi_ai-->>MuApiVideoGenerationTool: status + output URL
end
MuApiVideoGenerationTool->>muapi_ai: GET output URL
muapi_ai-->>MuApiVideoGenerationTool: video bytes
MuApiVideoGenerationTool-->>Caller: {"status": "success", "video_path": save_at}
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/director/tools/muapi_video.py`:
- Around line 123-127: The _submit method directly accesses
resp.json()["request_id"] which will raise a raw KeyError if the key is missing
from the API response. Wrap the resp.json()["request_id"] access in a try-except
block to catch KeyError, and when caught, raise a more informative exception
that includes the actual response content to aid debugging. This will provide
clear context about what the API returned instead of the expected request_id.
- Around line 162-172: The exception handling in the video generation code is
losing the original traceback by re-raising a new Exception without preserving
the exception chain. Modify the raise statement in the except block (where the
message "Error generating video" is constructed) to use the `from e` syntax to
preserve the original exception context. Apply the same fix to the
`image_to_video` method (mentioned at line 202) where this issue also exists.
This ensures the full traceback is retained for better debugging.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: fda5b229-148f-4b43-aa38-9f0d6164ad14
📒 Files selected for processing (1)
backend/director/tools/muapi_video.py
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/director/tools/muapi_video.py`:
- Around line 129-132: The _submit error handling in muapi_video.py currently
catches KeyError but loses the original exception context. Update the KeyError
handler in the _submit flow to bind the exception as a variable and re-raise the
new Exception with explicit chaining from that caught KeyError so the traceback
and source failure are preserved.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bba1f1e4-06b4-4aab-8ea8-b65f62b0d6f3
📒 Files selected for processing (1)
backend/director/tools/muapi_video.py
raise ... from e preserves the original KeyError so callers get a complete stack trace instead of losing context at the re-raise point
|
Thanks for the review. Fixed exception chaining in # Before
except KeyError:
raise Exception(f"MuAPI did not return a request_id. Response: {resp.text}")
# After
except KeyError as e:
raise Exception(f"MuAPI did not return a request_id. Response: {resp.text}") from eThe |
Summary
Adds a new video generation tool backed by muapi.ai — a generative media API aggregator that provides unified access to 400+ models across multiple providers.
What this adds
backend/director/tools/muapi_video.py—MuApiVideoGenerationToolclass withtext_to_video()andimage_to_video()methodsfal_video.py,kling.py, etc.)Usage
Get an API key at muapi.ai/dashboard/api-keys.
Summary by CodeRabbit