feat(llm): Promote TwelveLabs video RAG components into xpacks core#256
Open
iapoorv01 wants to merge 2 commits into
Open
feat(llm): Promote TwelveLabs video RAG components into xpacks core#256iapoorv01 wants to merge 2 commits into
iapoorv01 wants to merge 2 commits into
Conversation
a526624 to
f60073e
Compare
zxqfd555
reviewed
Jul 3, 2026
zxqfd555
reviewed
Jul 3, 2026
zxqfd555
reviewed
Jul 3, 2026
zxqfd555
requested changes
Jul 3, 2026
8dce7b9 to
bb3e6c0
Compare
This commit promotes the TwelveLabs integration from the template directory into the native pathway.xpacks.llm core library, as proposed in pathwaycom#255. Key changes: - pyproject.toml: Introduced a new [twelvelabs] optional dependency extra. - embedders.py: Promoted MarengoEmbedder into pathway.xpacks.llm.embedders. It inherits from BaseEmbedder and leverages an async pathway (_aembed_one) via asyncio.gather for concurrent embedding generation, preventing thread blocking. It implements the lazy ImportError pattern. - parsers.py: Promoted TwelveLabsVideoParser into pathway.xpacks.llm.parsers. Implemented proper resource cleanup logic using try/finally blocks to explicitly delete TwelveLabs assets (when delete_assets=True) preventing asset flooding on the API. Also implements the lazy ImportError pattern. - test_twelvelabs.py: Ported the unit tests into python/pathway/xpacks/llm/tests/. Contains no-network test coverage via stubbed SDK mocks. The live smoke test is maintained but securely gated behind the TWELVELABS_API_KEY existence check. - CHANGELOG.md: Added an entry under [Unreleased] -> Added documenting the promotion. This effectively extends Pathway's live-sync multimodal indexing capabilities to handle full video ingestion over the TwelveLabs network natively.
bb3e6c0 to
e863cdd
Compare
Contributor
Author
|
Thanks for the detailed review @zxqfd555 . I've pushed an update addressing all your points:
|
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.
Introduction
This PR resolves #255 by officially promoting the
TwelveLabsVideoParserandMarengoEmbedderout of thellm-appexamples template and integrating them natively into thepathway.xpacks.llmcore library.This enables native, first-class Video RAG capabilities (parsing raw video bytes into Pegasus text descriptions and retrieving them using a shared multimodal embedding space) directly out of the box in Pathway.
Context
Currently, Pathway's core LLM xpack handles PDFs, DOCX, and slides exceptionally well, but has lacked native multimodal video handling. Previously introduced as an app template in PR #129, the TwelveLabs components proved stable and highly valuable. Promoting them to the core
xpackslibrary eliminates the need for developers to maintain boilerplate API scaffolding when building multimodal search applications.Design Decisions & Approach:
twelvelabs.pyfile, we strictly adhered to Pathway's architectural patterns by natively integratingMarengoEmbedderintoembedders.pyandTwelveLabsVideoParserintoparsers.py.twelvelabsSDK is not a hard dependency. It sits securely in a new[twelvelabs]optional extra block inpyproject.toml. The components leverage a robusttry/except ImportErrorguidance pattern to safely prompt users to runpip install pathway[twelvelabs]only if they attempt to instantiate the classes without the SDK.asyncio.gatherpipeline for the Embedder to prevent thread-blocking under load. Furthermore, the Parser correctly utilizes atry/finallyblock to proactively delete TwelveLabs assets (delete_assets=Trueby default) so users do not accidentally flood their cloud workspace with zombie assets during repeated pipeline runs.How has this been tested?
All tests have been ported from the template environment into the native test suite at
python/pathway/xpacks/llm/tests/test_twelvelabs.py.__wrapped__async concurrency behaviors, asset cleanup lifecycle, and fallback failure modes using the strict_FakeClientstubbing pattern.sys.modulesstubs) to align cleanly with the core[tests]environment runtime guarantees.@pytest.mark.skipif(not os.environ.get("TWELVELABS_API_KEY"))to guarantee zero disruptions to the standard CI pipeline.isortandblackhooks.Types of changes
Related issue(s):
TwelveLabsVideoParserandMarengoEmbedderfrom the Video RAG template intopathway.xpacks.llm#255Checklist: