Skip to content

feat: add TwelveLabs Pegasus for full-video summaries (opt-in)#12

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

feat: add TwelveLabs Pegasus for full-video summaries (opt-in)#12
mohit-twelvelabs wants to merge 1 commit into
DevRico003: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 summary source that summarizes a video from the video itself — visual frames and audio — using TwelveLabs' Pegasus video-understanding model, instead of only the caption transcript.

Why this helps

The current pipeline summarizes the Supadata caption transcript. That misses everything the captions don't carry: on-screen text and code in tutorials, product demos, sports, music videos, or any clip with sparse/auto-generated captions. Pegasus reads the actual video, so the summary reflects what's shown, not just what's said. The README already noted "more providers planned" — this slots in alongside that.

What it adds

  • lib/twelvelabs.ts — a per-user client factory mirroring lib/glm.ts, plus the index → upload → analyze flow. Reuses (or creates) a single Pegasus-enabled index per user.
  • POST /api/summarize — a new optional request field source: "video". When set (and a TwelveLabs key is configured), the route summarizes the full video with Pegasus. Default source: "transcript" is unchanged.
  • Setup/Settings — twelvelabs wired into key validation (/api/setup/test-key), save, delete, and listing, exactly like the existing supadata/zai providers. It shows up in the Settings > API Keys list automatically.
  • lib/llmChain.ts — Pegasus surfaced via getAvailableModels; the text fallback chain is untouched (Pegasus is a video path, not a text LLM).

Opt-in and non-breaking

Nothing changes unless a client passes source: "video" and the user has added a TwelveLabs key. The transcript pipeline, defaults, and existing tests are unaffected. Pegasus summaries return hasTimestamps: false and no timeline topics — the same shape the transcript path already produces when timestamps aren't available.

How it was tested

  • npx jest __tests__/lib/twelvelabs.test.ts — 6 passing no-network unit tests (SDK mocked) covering configured/unconfigured, index reuse vs. creation, the analyze call shape, and indexing failure.
  • npm run build — compiles + passes TypeScript + generates all pages.
  • eslint clean on all changed files.
  • Live wiring check against the TwelveLabs API with a real key (the same indexes.list call the test-key route uses) returned 200. Full end-to-end index+analyze on a real video is slow (a few minutes to index), so that part is wiring-verified rather than run in CI.

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

Add an opt-in summary source that analyzes the full video (visual + audio)
with TwelveLabs' Pegasus model instead of the Supadata caption transcript.
Useful for demos, on-screen-text tutorials, sports, music videos, or any
video where captions don't capture everything.

- lib/twelvelabs.ts: client factory + index/upload/analyze flow (mirrors lib/glm.ts)
- POST /api/summarize: opt-in source: "video" path; default transcript path unchanged
- Setup/Settings: "twelvelabs" provider wired into key validation, save, delete, and listing
- llmChain: surface Pegasus in getAvailableModels; text fallback chain unchanged
- Tests: no-network unit test for the Pegasus flow (mocks the SDK)
- Docs: README, docs/configuration.md, docs/api.md
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