Skip to main content

LangChain integration for Moss semantic search

Project description

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:

  1. MossRetriever: A LangChain-compatible retriever for semantic search.
  2. 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_moss-0.1.0.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_moss-0.1.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file langchain_moss-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_moss-0.1.0.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for langchain_moss-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3815fae401aa31c0711864e11c6f81e590ae02960d355003b08d6403e16742cb
MD5 03d1f951fd9a7d2bb9bcf4fee76ee32f
BLAKE2b-256 b0ce4b277aff2e22f6e2faadbc947617f2d36dbc818ff0910517d655ce665cd5

See more details on using hashes here.

File details

Details for the file langchain_moss-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: langchain_moss-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for langchain_moss-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7336d32e30b6bb0b1cc84861aa1634f1d573c3d41a8e6a0b10338afdc9720b8b
MD5 a04258623acc3a60fe8373bd620d363b
BLAKE2b-256 9ba592106569cb70205229e9beed9318e04765ed9f6c9a91067ab39159d64753

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page