feat: add TwelveLabs ModelClient (Marengo embedder + Pegasus analyze)#494
feat: add TwelveLabs ModelClient (Marengo embedder + Pegasus analyze)#494mohit-twelvelabs wants to merge 3 commits intoSylphAI-Inc:mainSylphAI-Inc/AdalFlow:mainfrom mohit-twelvelabs:feat/twelvelabs-integrationmohit-twelvelabs/AdalFlow:feat/twelvelabs-integrationCopy head branch name to clipboard
Conversation
Adds an opt-in TwelveLabsClient that wraps the official twelvelabs SDK: - ModelType.EMBEDDER -> Marengo multimodal embeddings (512-dim) - ModelType.LLM -> Pegasus video understanding via analyze() Registered as a lazy/optional provider (extras: twelvelabs), with a no-network unit test and a TWELVELABS_API_KEY-gated live test.
|
Regenerated — Mohit (@mohit-twelvelabs, TwelveLabs) |
|
Follow-up: with the lock regenerated, Fixed in commit 4336bba by wrapping that import in — Mohit (@mohit-twelvelabs, TwelveLabs) |
Hi! I'm Mohit, I work at TwelveLabs (@mohit-twelvelabs).
What does this PR do?
Adds an opt-in
TwelveLabsClientmodel client that wraps the officialtwelvelabsPython SDK, following the same convention as the existing provider clients (groq_client,cohere_client, etc.):marengo3.0) as anEmbedderbackend (ModelType.EMBEDDER) — multimodal embeddings, 512-dim. Plugs straight intoadalflow.core.Embedder.pegasus1.5) as aGeneratorbackend (ModelType.LLM) — video understanding viaclient.analyze(), given a prompt plus avideo_url/video_id/video_asset_id.Why it helps AdalFlow
It gives AdalFlow native, video-first embeddings and video understanding — a modality the current providers don't cover — usable in RAG/retrieval and generation pipelines without any new abstractions.
Opt-in / non-breaking
twelvelabsextra (pip install adalflow[twelvelabs]), lazily imported via the existingOptionalPackages/LazyImportmechanism.components/model_client/__init__.py,ModelClientType, and the API docs autosummary the same way as other providers.twelvelabsunless the client is used.How it was tested
adalflow/tests/test_twelvelabs_client.py: 11 no-network unit tests (input mapping for both model types, response parsing, sync/async call paths) mocking the SDK, mirroringtest_groq_client.py.TWELVELABS_API_KEY-gated live test that calls Marengo and asserts a 512-dim embedding (verified passing against the real API). Pegasus wiring is unit-tested; a full analyze run is skipped in CI as it requires an uploaded/served video.black+ruffclean on changed files.Note: per the PR template, this wasn't pre-discussed in an issue — happy to open one or adjust naming/placement to your preference.
You can grab a free API key at https://twelvelabs.io — there's a generous free tier.