Skip to main content

Data model

Each document has an id and text (plus optional metadata). Use moss-minilm as the default model.

Examples

import { MossClient } from '@inferedge/moss'
const client = new MossClient(process.env.MOSS_PROJECT_ID!, process.env.MOSS_PROJECT_KEY!)
await client.createIndex('my-index', [
  { id: 'doc-1', text: '...', metadata: { category: 'faq', tags: 'returns,shipping', lang: 'en' } },
  { id: 'doc-2', text: '...' }
], 'moss-minilm')

// Upsert more docs later
await client.addDocs('my-index', [
  { id: 'doc-2', text: 'updated text' }, // will be updated
  { id: 'doc-3', text: 'new text' }
], { upsert: true })

// Fetch specific docs
const subset = await client.getDocs('my-index', { docIds: ['doc-1', 'doc-3'] })

// Delete docs or the index when done
await client.deleteDocs('my-index', ['doc-3'])
await client.deleteIndex('my-index')

Notes

  • createIndex / create_index will sync indexes to cloud (if enabled) while remaining usable locally
  • Supports multiple indexes per project; pick the model per index:
    • moss-minilm: fast, lightweight (default)
    • moss-mediumlm: higher accuracy, still efficient
    • Use moss-minilm for speed-first, edge/offline use; use moss-mediumlm when you need higher recall/precision

Chunking tips

  • Aim for ~200–500 tokens per chunk
  • Overlap 10–20% to preserve context
  • Normalize whitespace and strip boilerplate