feat: optional TwelveLabs content-aware video search & analysis (Marengo + Pegasus) - #10
Open
mohit-twelvelabs wants to merge 1 commit into
Open
Conversation
Adds an opt-in agent tool that searches the actual video content (visual + audio) via TwelveLabs Marengo, complementing the existing transcript-based semantic/BM25 search, plus a Pegasus-backed video analysis helper. Disabled unless TWELVELABS_API_KEY is set, so default behaviour is unchanged.
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).
What this adds
An opt-in agent tool that searches the actual video content of a channel — what is shown and said on screen (objects, scenes, actions, on-screen text, spoken audio) — using TwelveLabs' Marengo model, plus a Pegasus-backed helper for grounded single-video analysis.
Today the chat agent searches video transcripts (PGVector semantic + BM25). That's great for what was said, but misses purely-visual moments and anything the transcript drops. This new
twelvelabs_video_searchtool complements the existing search so the agent can answer questions like "find the part where they show the dashboard" or "when do they demo the product".Why it helps this project
video_id,start,end,score,thumbnail_url) that map cleanly onto the existing timestamped-results UI.Opt-in / non-breaking
TWELVELABS_API_KEYis set. With no key,TwelveLabsService.is_enabled()isFalse, the tool is not registered in the agent, and the transcript-only pipeline runs exactly as before.pip install -e ".[twelvelabs]") and is imported lazily, so nothing changes for existing installs.Tools.tool()classmethod returning aStructuredToolwith a Pydanticargs_schema, mirroringVectorDatabaseTools/SQLTools.How it was tested
tests/test_twelvelabs.py(the repo's first tests — also on the roadmap):TwelveLabsNotConfiguredErrorwhen unconfigured, enabled with a key;langchain/langgraph.twelvelabs_video_searchis appended to the tool list with a singlequeryarg.search.queryrequest shape end-to-end against the live API (the server accepts and validates the call; full search results require a Marengo-enabled index of the channel's videos).ruff,black,isort) on all changed files — clean.You can grab a free API key at https://twelvelabs.io — there's a generous free tier.