Skip to content

Add TwelveLabs Pegasus video understanding agent (opt-in)#12

Open
mohit-twelvelabs wants to merge 1 commit into
HKUDS:mainfrom
mohit-twelvelabs:feat/twelvelabs-integration
Open

Add TwelveLabs Pegasus video understanding agent (opt-in)#12
mohit-twelvelabs wants to merge 1 commit into
HKUDS:mainfrom
mohit-twelvelabs:feat/twelvelabs-integration

Conversation

@mohit-twelvelabs

Copy link
Copy Markdown

Hi! I'm Mohit, I work at TwelveLabs (@mohit-twelvelabs).

This PR adds an opt-in TwelveLabs Pegasus video-understanding agent to VideoAgent's multi-agent toolkit.

What it adds

  • A new PegasusVideoUnderstanding role (environment/roles/vid_qa/pegasus_understanding.py) that answers questions about videos using TwelveLabs Pegasus. It accepts a local video file, a directory of videos, or a public video URL (local files are uploaded as TwelveLabs assets).
  • A pegasus() / twelvelabs_client() helper in environment/config/llm.py, mirroring the existing gpt/claude/gemini provider helpers.
  • Registration in environment/config/registry.json so the framework auto-discovers it like every other role.
  • Config keys (twelvelabs_api_key, twelvelabs_base_url) in config.yml, the twelvelabs dependency in pyproject.toml, README docs, and tests.

Why it helps this project

The existing VideoContentQA agent answers questions from a Whisper transcript — it only sees speech and needs a local GPU model. Pegasus understands the video natively (visuals and audio), so it can reason about on-screen actions, scenes, and objects with no local transcription step. It's a complementary video-understanding backend in the agentic loop.

Opt-in / non-breaking

The agent only activates when twelvelabs_api_key is set in config.yml. The twelvelabs SDK is imported lazily, defaults are untouched, and the existing transcript-based flow is unchanged.

How it was tested

  • No-network unit tests for URL routing, the execute() happy path (mocked Pegasus), and the missing-path error path.
  • A live test gated on TWELVELABS_API_KEY that confirms the SDK + credentials reach the backend via a Marengo text embedding (verified 512-dim).
  • Pegasus analyze request wiring verified against the live API (parameters accepted server-side); a full end-to-end Pegasus run on a long sample video is server-side and slow, so that path is wiring-verified.
  • isort --profile black run on changed files; all files compile; pytest tests/test_pegasus_understanding.py → 4 passed.

You can grab a free API key at https://twelvelabs.io — there's a generous free tier.

Add an opt-in PegasusVideoUnderstanding role that answers questions about
videos using TwelveLabs Pegasus. Unlike the transcript-based Q&A agent, it
understands video natively (visuals + audio), so it needs no local Whisper
transcription and can reason about on-screen actions, scenes, and objects.

Accepts a local file, a directory of videos, or a public URL (local files
are uploaded as TwelveLabs assets). Wired through a new pegasus() helper in
environment/config/llm.py and registered in registry.json. Activates only
when twelvelabs_api_key is set in config.yml, so existing behavior is
unchanged. Adds twelvelabs dependency, README docs, and tests (a live test
gated on TWELVELABS_API_KEY plus no-network unit tests).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant