Moss LangChain Cookbook
This cookbook demonstrates how to integrate Moss with LangChain.
Overview
Moss is a semantic search platform that allows you to build and query high-performance vector indices without managing infrastructure. This integration provides:
- MossRetriever: A LangChain-compatible retriever for semantic search.
- MossSearchTool: A tool for LangChain agents to search your knowledge base.
Installation
Ensure you have the required packages installed:
pip install inferedge-moss langchain langchain-openai python-dotenv
Setup
Create a .env file with your Moss credentials:
MOSS_PROJECT_ID=your_project_id
MOSS_PROJECT_KEY=your_project_key
MOSS_INDEX_NAME=your_index_name
OPENAI_API_KEY=your_openai_api_key
Usage
Using the Retriever
The MossRetriever can be used in any LangChain chain.
from moss_langchain import MossRetriever
retriever = MossRetriever(
project_id="your_id",
project_key="your_key",
index_name="your_index",
top_k=3,
alpha=0
)
docs = retriever.invoke("What is the refund policy?")
Using the Agent Tool
You can also use Moss as a tool for an agent.
from moss_langchain import get_moss_tool
tool = get_moss_tool(
project_id="your_id",
project_key="your_key",
index_name="your_index"
)
# Add to agent tools
tools = [tool]
Examples
Check out the moss_langchain.ipynb notebook for complete examples including:
- Direct index querying
- Retrieval-Augmented Generation (RAG)
- ReAct Agent with Moss search
Metadata
Release files for langchain-moss 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langchain_moss-0.1.0.tar.gz | 2.9 kB | Without provenance | Details for langchain_moss-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_moss-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for langchain_moss-0.1.0-py3-none-any.whl |
Total release size: 6.2 kB
Release files / langchain_moss-0.1.0.tar.gz
| Download URL | langchain_moss-0.1.0.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3815fae401aa31c0711864e11c6f81e590ae02960d355003b08d6403e16742cb
|
|
BLAKE2b-256 checksum How to use checksums |
b0ce4b277aff2e22f6e2faadbc947617f2d36dbc818ff0910517d655ce665cd5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / langchain_moss-0.1.0-py3-none-any.whl
| Download URL | langchain_moss-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7336d32e30b6bb0b1cc84861aa1634f1d573c3d41a8e6a0b10338afdc9720b8b
|
|
BLAKE2b-256 checksum How to use checksums |
9ba592106569cb70205229e9beed9318e04765ed9f6c9a91067ab39159d64753
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for langchain-moss 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.