feat: add Langflow custom component for Moss retrieval - #356
Merged
HarshaNalluru merged 7 commits intoJul 15, 2026
Conversation
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Add drag-and-drop Moss retriever components for Langflow's visual builder. Components: - MossRetrieverComponent: returns structured Data objects (text, score, metadata) - MossSearchComponent: returns formatted text Message for LLM prompt injection Both support env var fallback for credentials, configurable top_k/alpha hybrid search, and optional JSON metadata filtering. New files: - examples/cookbook/langflow/moss_langflow.py - examples/cookbook/langflow/pyproject.toml - examples/cookbook/langflow/README.md - examples/cookbook/langflow/test_integration.py - examples/cookbook/langflow/.env.example Updated docs: - AGENTS.md: added to repo layout and cookbook table - README.md: added to integrations table and examples tree Closes usemoss#343
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Langflow cookbook integration that exposes Moss retrieval as drag-and-drop Langflow custom components, expanding Moss’s “framework integrations” beyond code-first SDK usage into visual flow builder workflows.
Changes:
- Introduces
MossRetrieverComponent(structuredData[]) andMossSearchComponent(formattedMessage) for Langflow. - Adds a Langflow cookbook package scaffold (README, pyproject, env template) plus integration tests.
- Updates top-level repo docs (
AGENTS.md, rootREADME.md) to list the new Langflow cookbook.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Adds Langflow to the integrations list and examples tree. |
| AGENTS.md | Adds Langflow to the repo layout + cookbook table. |
| examples/cookbook/langflow/moss_langflow.py | Implements two Langflow custom components + helper functions. |
| examples/cookbook/langflow/pyproject.toml | Defines the cookbook package metadata/deps. |
| examples/cookbook/langflow/README.md | Documents installation, component usage, and metadata filtering. |
| examples/cookbook/langflow/test_integration.py | Adds unit/integration-style tests with dependency-based skipping. |
| examples/cookbook/langflow/.env.example | Adds env var template for credentials. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
Author
|
@HarshaNalluru Sir I have updated the pr according to suggestion , I think we are good to go for a merge |
HarshaNalluru
approved these changes
Jul 15, 2026
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.
Adds drag-and-drop Moss retriever components for Langflow's visual flow builder, allowing users to add sub-10 ms Moss semantic search to their flows without writing code.
Closes #343
Components
MossRetrieverComponent
Returns structured Data objects for downstream pipeline use (e.g., feeding a prompt builder or vector store). Each Data object contains:
text: Document content (string)
score: Relevance score (float)
id: Document ID (string)
metadata: Document metadata (dictionary)
MossSearchComponent
Returns a formatted Message with numbered search results, ready for direct LLM prompt injection (e.g., "Result 1 (score: 0.923): ...").
Shared Features
Env var fallback: Credentials can be set in the UI or via MOSS_PROJECT_ID / MOSS_PROJECT_KEY.
Hybrid search: Configurable alpha (0.0 = keyword, 1.0 = semantic, 0.5 = balanced).
Metadata filtering: Optional JSON filter input supporting Moss operators ($eq, $and, $in, $near).
Async bridge: Wraps the async Moss SDK for Langflow's synchronous component execution.
Example Flow
[Chat Input] -> [Moss Retriever] -> [Prompt Builder] -> [OpenAI LLM] -> [Chat Output]
Files Changed
New Files
examples/cookbook/langflow/moss_langflow.py: Core component module (2 components + helpers)
examples/cookbook/langflow/pyproject.toml: Package config (langflow-moss)
examples/cookbook/langflow/README.md: Installation, component reference, example flow, metadata filtering docs
examples/cookbook/langflow/test_integration.py: 12 unit tests (5 always-run + 7 auto-skip without langflow)
examples/cookbook/langflow/.env.example: Credential template
Modified Files
AGENTS.md: Added langflow/ to repo layout tree and Framework Cookbooks table
README.md: Added Langflow to integrations table and examples directory tree
Usage
Option A: Paste into Langflow (quickest)
Open Langflow -> add a Custom Component node.
Paste contents of moss_langflow.py into the code editor.
Configure credentials + index name on the canvas.
Option B: Install as a package
Run: pip install -e examples/cookbook/langflow Restart Langflow — components will appear in the sidebar.
Testing
Run: python -m pytest test_integration.py -v
5 tests passed: TestParseFilter (validates JSON filter parsing logic).
7 tests skipped: Component tests require langflow + moss packages (auto-skip gracefully, will pass in CI environment with dependencies installed).
Checklist
Follows existing cookbook pattern (examples/cookbook//)
Matches conventions from LangChain and Haystack cookbooks
pyproject.toml with proper metadata and dependencies
README with install instructions, component reference, and example flow
Unit tests with mocked MossClient (no live credentials needed)
AGENTS.md updated (repo layout + cookbook table)
README.md updated (integrations table + examples tree)
.env.example included