Skip to content

Add opt-in TwelveLabs Pegasus connector for chat-with-clip - #6

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

Add opt-in TwelveLabs Pegasus connector for chat-with-clip#6
mohit-twelvelabs wants to merge 1 commit into
roboflow: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 way to chat with a whole webcam clip using the TwelveLabs Pegasus video understanding model, alongside the existing OpenAI single-frame path.

What it adds

  • webcamgpt.TwelveLabsConnector — mirrors the existing OpanAIConnector API (simple_prompt(...)), but takes a video clip (local file or public URL) instead of a single frame. It accepts a local path (sent as base64) or an http(s) URL.
  • webcamgpt.utils.encode_video_to_base64 helper, in the same style as encode_image_to_base64.
  • examples/webcam_twelvelabs.py — a gradio demo mirroring examples/webcam.py, but recording a short clip and asking Pegasus about it.
  • twelvelabs>=1.2.8 added to requirements.txt; README section documenting the option.
  • test/test_twelvelabs_connector.py — no-network unit tests for input routing + key validation, plus a live Pegasus test that is skipped unless TWELVELABS_API_KEY is set.

Why it helps this project

The webcam stream is inherently temporal — a single frame loses motion and actions. Pegasus reasons over the whole clip server-side, so users can ask "what just happened?" rather than "what's in this frame?".

Opt-in / non-breaking

Default behavior is unchanged. The OpenAI connector and example are untouched; the new connector is only used if you explicitly construct TwelveLabsConnector (or run the new example) with a TWELVELABS_API_KEY.

How it was tested

  • The 3 no-network unit tests pass.
  • The live Pegasus test passes end-to-end against a public sample clip, returning a real description. I also verified the local-file (base64) path against a recorded clip.

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

Adds an opt-in TwelveLabsConnector that chats with a whole video clip
using the Pegasus video understanding model, as an alternative to
single-frame OpenAI inference. Includes a gradio example, README docs,
and tests. Default OpenAI behavior is unchanged.
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedpypi/​twelvelabs@​1.2.8100100100100100

View full report

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