feat: add TwelveLabs Pegasus for full-video summaries (opt-in)#12
Open
mohit-twelvelabs wants to merge 1 commit into
Open
feat: add TwelveLabs Pegasus for full-video summaries (opt-in)#12mohit-twelvelabs wants to merge 1 commit into
mohit-twelvelabs wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 mirroringlib/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 fieldsource: "video". When set (and a TwelveLabs key is configured), the route summarizes the full video with Pegasus. Defaultsource: "transcript"is unchanged.twelvelabswired into key validation (/api/setup/test-key), save, delete, and listing, exactly like the existingsupadata/zaiproviders. It shows up in the Settings > API Keys list automatically.lib/llmChain.ts— Pegasus surfaced viagetAvailableModels; 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 returnhasTimestamps: falseand 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.eslintclean on all changed files.indexes.listcall 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.