npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@localmode/langchain

v2.1.1

Published

LangChain.js adapters for @localmode — drop-in local inference for existing LangChain apps

Readme

@localmode/langchain

npm license

Docs UI Components Blocks & Apps

LangChain.js adapters for LocalMode — drop-in local inference for existing LangChain applications. Swap 3 imports and go fully local.

See it live: the RAG Chat block at localmode.ai has a LangChain engine toggle that runs LocalModeEmbeddings, LocalModeVectorStore, and ChatLocalMode end-to-end in the browser — ingest, semantic search, and grounded answers through the real adapters, behind the same UI as the core pipeline.

Installation

pnpm install @localmode/langchain @localmode/core @localmode/transformers

Adapters

| LangChain Class | LocalMode Adapter | Wraps | |----------------|-------------------|-------| | Embeddings | LocalModeEmbeddings | EmbeddingModel | | BaseChatModel | ChatLocalMode | LanguageModel | | VectorStore | LocalModeVectorStore | VectorDB | | BaseDocumentCompressor | LocalModeReranker | RerankerModel |

Quick Start

Full RAG Chain

import { LocalModeEmbeddings, ChatLocalMode, LocalModeVectorStore } from '@localmode/langchain';
import { transformers } from '@localmode/transformers';
import { webllm } from '@localmode/webllm';
import { createVectorDB } from '@localmode/core';
import { RetrievalQAChain } from 'langchain/chains';

const embeddings = new LocalModeEmbeddings({
  model: transformers.embedding('Xenova/bge-small-en-v1.5'),
});
const llm = new ChatLocalMode({
  model: webllm.languageModel('Qwen3-1.7B-q4f16_1-MLC'),
});
const db = await createVectorDB({ name: 'docs', dimensions: 384 });
const store = new LocalModeVectorStore(embeddings, { db });

// Add documents
await store.addDocuments([
  { pageContent: 'LocalMode runs AI in the browser', metadata: { source: 'docs' } },
]);

// Query
const chain = RetrievalQAChain.fromLLM(llm, store.asRetriever());
const result = await chain.call({ query: 'What is LocalMode?' });

Reranker

import { LocalModeReranker } from '@localmode/langchain';
import { transformers } from '@localmode/transformers';

const reranker = new LocalModeReranker({
  model: transformers.reranker('Xenova/ms-marco-MiniLM-L-6-v2'),
  topK: 5,
});

const reranked = await reranker.compressDocuments(documents, 'search query');

Knowledge Base Engine

createLangChainKnowledgeBaseEngine() returns a kind: 'langchain' engine implementing the frozen KnowledgeBaseEngine contract from @localmode/core (chunk → embed → store, vector search, grounded ask) through the LocalModeEmbeddings / LocalModeVectorStore / ChatLocalMode adapters. It is result-equivalent to @localmode/core's createKnowledgeBaseEngine, so a knowledge base UI can toggle engines over one shared corpus. Because the models are injected, apps that never toggle the LangChain engine never pull this package.

import { createLangChainKnowledgeBaseEngine, ChatLocalMode } from '@localmode/langchain';
import { transformers } from '@localmode/transformers';

const engine = createLangChainKnowledgeBaseEngine({
  embeddingModel: transformers.embedding('Xenova/bge-small-en-v1.5'),
  getChatModel: () =>
    new ChatLocalMode({
      model: transformers.languageModel('onnx-community/granite-4.0-350m-ONNX-web'),
      maxTokens: 512,
    }),
});

await engine.ingest(docs, { chunking: 'recursive', chunkSize: 500 });
const hits = await engine.search('privacy and encryption', { topK: 10 });
const { answer, sources } = await engine.ask('How is data encrypted?');

Migration from Cloud

- import { ChatOpenAI, OpenAIEmbeddings } from '@langchain/openai';
- import { PineconeStore } from '@langchain/pinecone';
+ import { ChatLocalMode, LocalModeEmbeddings, LocalModeVectorStore } from '@localmode/langchain';
+ import { transformers } from '@localmode/transformers';
+ import { webllm } from '@localmode/webllm';

- const llm = new ChatOpenAI({ modelName: 'gpt-4o-mini' });
- const embeddings = new OpenAIEmbeddings();
- const store = await PineconeStore.fromExistingIndex(embeddings, { pineconeIndex });
+ const llm = new ChatLocalMode({ model: webllm.languageModel('Qwen3-1.7B-q4f16_1-MLC') });
+ const embeddings = new LocalModeEmbeddings({ model: transformers.embedding('Xenova/bge-small-en-v1.5') });
+ const db = await createVectorDB({ name: 'docs', dimensions: 384 });
+ const store = new LocalModeVectorStore(embeddings, { db });

The chain code (RetrievalQAChain.fromLLM) is identical. Only provider instantiation changes.

Documentation

Full documentation at localmode.dev/docs/langchain.

Acknowledgments

This package is built on LangChain.js by LangChain — a framework for building applications powered by language models.

License

MIT