Skip to content

feat: add Langflow custom component for Moss retrieval - #356

Merged
HarshaNalluru merged 7 commits into
usemoss:mainfrom
Sravan1011:feat/langflow-custom-component
Jul 15, 2026
Merged

feat: add Langflow custom component for Moss retrieval#356
HarshaNalluru merged 7 commits into
usemoss:mainfrom
Sravan1011:feat/langflow-custom-component

Conversation

@Sravan1011

Copy link
Copy Markdown
Contributor

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

Sravan1011 and others added 6 commits June 26, 2026 08:20
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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (structured Data[]) and MossSearchComponent (formatted Message) for Langflow.
  • Adds a Langflow cookbook package scaffold (README, pyproject, env template) plus integration tests.
  • Updates top-level repo docs (AGENTS.md, root README.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.

Comment thread examples/cookbook/langflow/moss_langflow.py
Comment thread examples/cookbook/langflow/moss_langflow.py
Comment thread examples/cookbook/langflow/test_integration.py
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Sravan1011

Copy link
Copy Markdown
Contributor Author

@HarshaNalluru Sir I have updated the pr according to suggestion , I think we are good to go for a merge

@HarshaNalluru
HarshaNalluru merged commit bf44f6e into usemoss:main Jul 15, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Langflow custom component

3 participants