Tool

Index and Query Semantic Search Data

Query and index documents into a Moss real-time semantic search engine from a LlamaIndex agent.

Works with moss

75
Spark score
out of 100
Updated 2 days ago
Version 0.14.23
Models

Add to Favorites

Why it matters

Integrate with Moss, a real-time semantic search engine, to index documents and perform semantic queries. This enables efficient retrieval of information based on meaning rather than just keywords.

Outcomes

What it gets done

01

Initialize and configure the Moss client and tool.

02

Index documents with associated metadata into a Moss index.

03

Query the Moss index using customizable search options.

04

Utilize hybrid search for improved retrieval accuracy.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-tool-tools-moss | bash

Overview

Moss Tool

A LlamaIndex tool for the Moss real-time semantic search engine, supporting tunable hybrid search queries and direct document indexing. Use moss-minilm for speed/edge use and moss-mediumlm when search quality matters more; use index_docs to add content directly.

What it does

The Moss Tool integrates a LlamaIndex agent with Moss, a real-time semantic search engine. MossToolSpec wraps a MossClient (itself initialized with a Moss project ID and project key) and is configured with an index_name and optional QueryOptions, then converted to a tool list for an agent via to_tool_list().

QueryOptions controls how queries run: top_k (default 5) sets how many results come back, alpha (default 0.5) weights hybrid search between pure keyword (0.0) and pure semantic (1.0) matching, and model_id (default moss-minilm) picks the embedding model. Two model IDs are documented: moss-minilm, fast and lightweight, best for speed-first or edge/offline use, and moss-mediumlm, higher accuracy with reasonable performance, best when search quality matters more than speed.

Beyond querying, the tool can index documents directly into the Moss index via the async index_docs method, passing a list of DocumentInfo objects (each with text and a metadata dictionary) - so the same tool spec handles both writing new content into Moss and querying it back out through the agent.

When to use - and when NOT to

Use it when you need a LlamaIndex agent to query a real-time semantic search index with tunable hybrid search weighting, and choose moss-minilm when speed matters more (edge or offline scenarios) versus moss-mediumlm when search quality is the priority. Use index_docs when you need to add or update content in the Moss index programmatically rather than through Moss's own ingestion path. Do not use it without an existing Moss project (project ID and project key) already set up.

Capabilities

Queries a Moss index with configurable top_k, hybrid-search alpha weighting, and a choice of embedding model (moss-minilm or moss-mediumlm). index_docs indexes new DocumentInfo objects into Moss directly from the same tool.

How to install

pip install llama-index-tools-moss

Requires a Moss project ID and project key to initialize the underlying MossClient.

Who it's for

Developers building LlamaIndex agents that need real-time semantic or hybrid search over a Moss index, with the ability to both query and index documents from the same tool.

Source README

Moss Tool

This tool provides integration with Moss, a real-time semantic search engine.

Installation

pip install llama-index-tools-moss

Usage

You can use the MossToolSpec to interact with your Moss index.

Initialization

import os
from llama_index.tools.moss import MossToolSpec, QueryOptions
from inferedge_moss import MossClient

### Initialize the client
### The client requires a Moss project key and a project ID
MOSS_PROJECT_KEY = os.getenv("MOSS_PROJECT_KEY")
MOSS_PROJECT_ID = os.getenv("MOSS_PROJECT_ID")
client = MossClient(project_id=MOSS_PROJECT_ID, project_key=MOSS_PROJECT_KEY)

### Initialize the tool
### Note: You can customize top_k and alpha through query_options (hybrid search weight)
options = QueryOptions(alpha=0.6, top_k=9, model_id="moss-minilm")
tool = MossToolSpec(
    client=client, index_name="my_index", query_options=options
)

### Convert to tool list for agents
tools = tool.to_tool_list()

Indexing Documents

You can index documents into your Moss index using the index_docs method:

from inferedge_moss import DocumentInfo

docs = [
    DocumentInfo(
        text="LlamaIndex is great!", metadata={"source": "review.txt"}
    ),
    DocumentInfo(text="Moss is fast!", metadata={"source": "specs.txt"}),
]

### Index the documents
await tool.index_docs(docs)

Parameters

  • client (MossClient): The initialized Moss client.
  • index_name (str): The name of the index to query.
  • query_options (QueryOptions): Configuration options for the tool (optional).
    • top_k (int, default=5): Number of results to return.
    • alpha (float, default=0.5): Weight for hybrid search (0.0=keyword, 1.0=semantic).
    • model_id (str, default="moss-minilm"): The model ID to use for embeddings.

MODEL IDs

  • moss-minilm: Fast, lightweight (default). Best for speed-first, edge/offline use.
  • moss-mediumlm: Higher accuracy with reasonable performance. Best when search quality is important.

Examples

The examples/ directory contains:

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.