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

smoltalk-llama-cpp

v0.1.1

Published

node-llama-cpp provider for smoltalk

Readme

smoltalk-llama-cpp

node-llama-cpp provider plugin for smoltalk.

Install

pnpm add smoltalk smoltalk-llama-cpp

Downloading models

This package depends on node-llama-cpp, which ships a CLI with a pull command for downloading .gguf model files. Because node-llama-cpp is already installed as a dependency of smoltalk-llama-cpp, you can run its CLI through npx without installing anything else:

# Download a model into ./models
npx --no node-llama-cpp pull --dir ./models <model-file-url>

The --no flag tells npx to use the already-installed copy rather than fetching one. Pass a direct URL to a .gguf file (e.g. a Hugging Face download link). The --dir flag controls where the file is saved — point it at the same directory you pass as metadata.llamaCppModelDir below.

Not sure which model to grab? Run the interactive picker, which lists recommended models:

npx --no node-llama-cpp chat

See the node-llama-cpp getting-a-model guide for more.

Usage

Register the provider before your first call, then use smoltalk normally:

import { registerProvider, text, userMessage } from "smoltalk";
import { LlamaCPP } from "smoltalk-llama-cpp";

registerProvider("llama-cpp", LlamaCPP);

const result = await text({
  model: "your-local-model.gguf",
  provider: "llama-cpp",
  metadata: { llamaCppModelDir: "./models" },
  messages: [userMessage("Hello")],
});

metadata.llamaCppModelDir points to a directory containing your .gguf model files.

Lifecycle & concurrency

Native model state is expensive to allocate and cannot be safely torn down mid-request, so this plugin keeps it alive and reuses it:

  • Each model is loaded once per process and cached (keyed by its resolved path). The context and sequence are created once and reused across every text() / textStream() call — smoltalk constructs a fresh client per call, but the heavy native state is shared behind the scenes.

  • Requests to the same model are serialized (one generation at a time on the shared sequence). Concurrent text() calls are safe but run one after another; different models run independently.

  • Native state is retained until process exit. For long-lived embedders (and tests), call disposeAll() when nothing is in flight to free every loaded model, or disposeModel(modelKey(dir, file)) for a single one:

    import { disposeAll } from "smoltalk-llama-cpp";
    await disposeAll();

Why reuse instead of a fresh context per call: disposing a LlamaContext immediately after generation races node-llama-cpp's internal checkpoint worker on SWA/hybrid models (Qwen3, Gemma), causing a native use-after-free crash (SIGSEGV). Reusing the context removes that crash class entirely.