This cookbook provides drag-and-drop Moss retrieval components for Langflow.
Moss is a sub-10 ms semantic search runtime. These Langflow custom components let visual-builder users add Moss retrieval to their flows without writing code.
Two components are included:
- Moss Retriever — returns structured
Dataobjects (text, score, metadata) for downstream pipeline use. - Moss Search — returns formatted text ready for direct LLM prompt injection.
- Open Langflow and create a new flow.
- Add a Custom Component node to the canvas.
- Open the code editor and paste the contents of
moss_langflow.py. - The component will appear with configurable inputs.
pip install langflow-mossOr install from source:
cd examples/cookbook/langflow
pip install -e .The components will be available in Langflow's component sidebar after restart.
You need a Moss project. Sign up at moss.dev to get your credentials (free tier available).
Configure credentials either:
- In the component UI: Fill in the Moss Project ID and Moss Project Key fields directly.
- Via environment variables: Set
MOSS_PROJECT_IDandMOSS_PROJECT_KEYbefore starting Langflow.
cp .env.example .env
# Edit .env with your credentialsReturns a list of Data objects, each containing:
| Field | Type | Description |
|---|---|---|
text |
str |
Document content |
score |
float |
Relevance score (0–1) |
id |
str |
Document ID |
metadata |
dict |
Document metadata |
Inputs:
| Input | Type | Default | Description |
|---|---|---|---|
| Moss Project ID | Text | $MOSS_PROJECT_ID |
Your Moss project ID |
| Moss Project Key | Secret | $MOSS_PROJECT_KEY |
Your Moss project key (masked in UI) |
| Index Name | Text | (required) | Name of the Moss index to query |
| Search Query | Text | (required) | The search query text |
| Top K | Integer | 5 |
Number of results to return |
| Alpha (Hybrid Search) | Float | 0.5 |
0.0 = keyword, 1.0 = semantic, 0.5 = balanced |
| Metadata Filter (JSON) | Text | (empty) | Advanced: Moss filter as JSON |
Returns a Message with formatted text like:
Result 1 (score: 0.923):
Refunds are processed within 3-5 business days.
Result 2 (score: 0.847):
You can track your order on the dashboard.
Same inputs as the Moss Retriever.
A typical RAG flow in Langflow:
[Chat Input] → [Moss Retriever] → [Prompt Builder] → [OpenAI LLM] → [Chat Output]
- Chat Input: User asks a question.
- Moss Retriever: Searches your knowledge base with sub-10 ms latency.
- Prompt Builder: Combines the retrieved documents with the user's question.
- OpenAI LLM: Generates an answer grounded in the retrieved context.
- Chat Output: Returns the answer to the user.
Alternatively, use the Moss Search component to get pre-formatted text and wire it directly into a prompt template.
Use the Metadata Filter (JSON) input to narrow results:
{"$eq": {"category": "faq"}}{"$and": [{"$eq": {"department": "support"}}, {"$eq": {"language": "en"}}]}See Moss metadata filtering docs for the full filter syntax.
- Moss Documentation
- Moss Python SDK
- Langflow Documentation
- LangChain Cookbook — if you prefer code-first LangChain integration