Skip to content

Add TwelveLabs Pegasus as a hosted captioning backend - #4

Open
mohit-twelvelabs wants to merge 1 commit into
filliptm:masterfrom
mohit-twelvelabs:feat/twelvelabs-integration
Open

Add TwelveLabs Pegasus as a hosted captioning backend#4
mohit-twelvelabs wants to merge 1 commit into
filliptm:masterfrom
mohit-twelvelabs:feat/twelvelabs-integration

Conversation

@mohit-twelvelabs

Copy link
Copy Markdown

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

What this adds

An opt-in pegasus-1.5 model preset that uses TwelveLabs Pegasus to caption videos server-side, as an alternative to the local VLM presets (Qwen3-VL, Gemma 4).

The model loader already dispatches on a preset's loader field, so this slots in cleanly as a third strategy:

  • backend/twelvelabs_provider.pyload_pegasus (validates the API key, builds the SDK client) and generate_pegasus (uploads the source video as a TwelveLabs asset, waits for it to be ready, then calls client.analyze(...) with the user's prompt).
  • backend/model_presets.py — new pegasus-1.5 preset (loader: "pegasus", is_hosted, requires_api_key).
  • backend/model_loader.pyload_model/generate_caption dispatch to the hosted strategy; generate_caption gains an optional video_path (local strategies ignore it, Pegasus needs the file).
  • backend/processing.py — threads the source video_path through to generate_caption in both the sequential and parallel paths.
  • backend/config.py / backend/schemas.py / frontend/src/types/settings.ts — env-only API key + preset metadata fields.

Why it helps

Pegasus needs no GPU and no local weights — it analyses the whole video server-side. That lets the suite run on machines without a capable GPU and offloads captioning for large batches, while the local presets remain the default and are completely untouched.

Opt-in / non-breaking

  • Default preset is still qwen3-vl-8b; nothing changes unless you explicitly select Pegasus.
  • The API key is read from TWELVELABS_API_KEY in the environment and is never written to settings.json/user_config.json.
  • twelvelabs>=1.2.8 is added to requirements as an optional dep (only imported when the Pegasus preset is loaded).

How it was tested

  • New backend/tests/test_twelvelabs_provider.py: no-network unit tests (preset registration, meta-shape parity, guard rails) plus a live test gated on TWELVELABS_API_KEY (skipped without it). All pass; the 13 pre-existing test_api.py errors are unrelated (a MagicMock f-string issue present on master).
  • End-to-end: ran generate_pegasus against a public sample video — upload → poll-until-ready → analyze returned a real caption ("The video shows a street with cars and a bus moving from left to right, bordered by a park...").
  • python -m py_compile clean on all changed backend modules.

Docs updated: documentation/CONFIGURATION.md, documentation/ARCHITECTURE.md, and the README.

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

Adds an opt-in pegasus-1.5 model preset that uses TwelveLabs Pegasus to
caption videos server-side instead of a local VLM. The model loader gains
a third 'pegasus' strategy (backend/twelvelabs_provider.py) that uploads
the source video as a TwelveLabs asset, waits for it to be ready, and calls
analyze() with the user's prompt. No GPU or local weights are required.

The key is read from TWELVELABS_API_KEY in the environment and is never
persisted. Defaults are unchanged (Qwen3-VL stays the default preset) and
the local strategies are untouched. Docs and the frontend preset type are
updated to match.
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