add TwelveLabs video understanding and embedding tool - #254
add TwelveLabs video understanding and embedding tool#254mohit-twelvelabs wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughA new ChangesTwelveLabs Video Tool
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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: 3
🤖 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 `@docs/concepts/tool_system/twelvelabs_video.md`:
- Around line 79-93: The quickstart examples for TwelveLabsVideo are incorrectly
using the protected _run() method instead of the public run() method provided by
BaseTool. Replace both calls to tool._run() (the Marengo embedding example and
the Pegasus video understanding example) with tool.run() and convert the keyword
arguments into a dictionary passed as the input parameter, ensuring all task
parameters like task, text, video_url, and prompt are properly formatted as
dictionary keys and values.
In
`@omagent-core/src/omagent_core/tool_system/tools/twelvelabs_video/twelvelabs_video.py`:
- Around line 134-147: The embed method in the twelvelabs_video class currently
accepts both text and image_url parameters but silently prioritizes text when
both are provided, creating ambiguous behavior. After the existing validation
check that ensures at least one of text or image_url is provided, add an
additional validation to reject the case where both parameters are provided
simultaneously. Raise a ValueError with a clear message indicating that exactly
one of text or image_url must be provided (not both).
- Around line 74-85: The api_key field in the class has a default value of None,
which bypasses the Pydantic v2 validator when the field is omitted during
instantiation. Remove the default value assignment (= None) from the api_key
field definition to make it required, changing it from Optional[str] = None to
just str. This ensures the api_key_validator will execute and fail at
construction time when the API key is not provided, rather than deferring the
failure to runtime.
🪄 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: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 64da1db1-0ec2-4a6d-b4e7-6cf9d4076b73
📒 Files selected for processing (4)
docs/concepts/tool_system/twelvelabs_video.mdomagent-core/pyproject.tomlomagent-core/src/omagent_core/tool_system/tools/twelvelabs_video/__init__.pyomagent-core/src/omagent_core/tool_system/tools/twelvelabs_video/twelvelabs_video.py
…blic run() in docs
- Make api_key a required field so the validator runs at construction
instead of being bypassed for the default and deferring failure to runtime.
- Reject embed calls that supply both text and image_url for deterministic behavior.
- Update quickstart docs to call the public run({...}) API instead of _run().
Hi! I'm Mohit, I work at TwelveLabs (@mohit-twelvelabs).
What this adds
A new opt-in agent tool,
TwelveLabsVideo, that gives OmAgent's multimodal agents access to the TwelveLabs video AI models:task: "analyze") — video understanding. Answer a natural language prompt about a video by URL (summarize, list objects, describe events, etc.).task: "embed") — multimodal embeddings. Produce a 512-dim embedding vector from text or an image, in a shared text/image/video embedding space (useful for video retrieval).It follows the existing tool convention exactly (
@registry.register_tool()on aBaseToolsubclass with anARGSCHEMA, mirroringTavilyWebSearch), so it is auto-discovered byregistry.import_module()and usable from any tool config.Why it helps
OmAgent already targets multimodal/video agents. This lets an agent reason about videos by URL without standing up a local video model — the heavy lifting runs server-side at TwelveLabs.
Opt-in / non-breaking
Nothing is wired into defaults. The tool only activates when added to a tool config and given an API key:
The
twelvelabsSDK import is lazy (inside__init__), so it is only required when the tool is actually instantiated.How it was tested
embedcall returns a 512-dim vector. The Pegasusanalyzerequest wiring was verified end-to-end (the request reaches and is validated by the backend, which then fetches the video server-side).twelvelabs ^1.2.8inomagent-core/pyproject.toml; docs added atdocs/concepts/tool_system/twelvelabs_video.mdmirroring the Tavily tool doc.You can grab a free API key at https://twelvelabs.io — there's a generous free tier.
Summary by CodeRabbit