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

@reaatech/agent-memory-llm

v0.1.0

Published

LLM provider abstraction for agent-memory extraction and reasoning

Readme

@reaatech/agent-memory-llm

npm version License: MIT CI

Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.

LLM provider abstraction for memory extraction, classification, and structured reasoning. Ships with an OpenAI provider; implement the LLMProvider interface to integrate any model (Anthropic, local models via Ollama, etc.).

Installation

npm install @reaatech/agent-memory-llm
# or
pnpm add @reaatech/agent-memory-llm

Feature Overview

  • Single-method completion interfacecomplete() for freeform and completeStructured() for JSON schema output
  • OpenAI provider — pre-built for any OpenAI-compatible API (GPT-4o, GPT-4o-mini, local Ollama)
  • Fetch with timeout — 30-second default timeout with custom abort signals
  • Zero dependencies beyond core — lightweight and tree-shakeable
  • Dual ESM/CJS output — works with import and require

Quick Start

import { OpenAILLMProvider } from '@reaatech/agent-memory-llm';

const llm = new OpenAILLMProvider({
  apiKey: process.env.OPENAI_API_KEY,
  model: 'gpt-4o-mini',
});

// Free-form completion
const result = await llm.complete(
  'Extract any facts or preferences from: "I prefer dark mode and live in Seattle."',
);

// Structured output with JSON schema
const extraction = await llm.completeStructured<{ facts: string[] }>(
  'Extract user facts from the conversation.',
  {
    type: 'object',
    properties: {
      facts: { type: 'array', items: { type: 'string' } },
    },
    required: ['facts'],
  },
);

API Reference

LLMProvider Interface

The contract all providers must implement:

interface LLMProvider {
  complete(prompt: string): Promise<string>;
  completeStructured<T>(prompt: string, schema: object): Promise<T>;
}

OpenAILLMProvider (class)

OpenAI-compatible provider supporting any OpenAI API endpoint.

import { OpenAILLMProvider } from '@reaatech/agent-memory-llm';

const llm = new OpenAILLMProvider({
  apiKey: process.env.OPENAI_API_KEY,
  model: 'gpt-4o-mini',
  baseUrl: 'https://api.openai.com/v1',  // optional, for custom endpoints
  temperature: 0.3,                       // optional, defaults to 0.1
});

OpenAILLMConfig

| Property | Type | Default | Description | |----------|------|---------|-------------| | apiKey | string | (required) | OpenAI API key | | model | string | (required) | Model name (gpt-4o, gpt-4o-mini, etc.) | | baseUrl | string | https://api.openai.com/v1 | API base URL for compatible endpoints | | temperature | number | 0.1 | Sampling temperature (0–2) |

complete(prompt: string): Promise<string>

Makes a chat completion request and returns the message content as a string.

const text = await llm.complete('Summarize this conversation in 3 bullet points.');

completeStructured<T>(prompt: string, schema: object): Promise<T>

Makes a chat completion with structured output parsing. Pass a JSON schema object; the response is parsed and validated as type T.

interface Preferences {
  likes: string[];
  dislikes: string[];
}

const prefs = await llm.completeStructured<Preferences>(
  'Extract user preferences.',
  {
    type: 'object',
    properties: {
      likes: { type: 'array', items: { type: 'string' } },
      dislikes: { type: 'array', items: { type: 'string' } },
    },
  },
);

Usage Patterns

Using with Ollama (Local Models)

Any OpenAI-compatible endpoint works:

const localLlm = new OpenAILLMProvider({
  apiKey: 'ollama',
  model: 'llama3.2',
  baseUrl: 'http://localhost:11434/v1',
});

Creating a Custom Provider

Implement LLMProvider:

import type { LLMProvider } from '@reaatech/agent-memory-llm';

class AnthropicProvider implements LLMProvider {
  constructor(private config: { apiKey: string; model: string }) {}

  async complete(prompt: string): Promise<string> {
    const response = await fetch('https://api.anthropic.com/v1/messages', {
      method: 'POST',
      headers: {
        'x-api-key': this.config.apiKey,
        'anthropic-version': '2023-06-01',
        'content-type': 'application/json',
      },
      body: JSON.stringify({
        model: this.config.model,
        max_tokens: 1024,
        messages: [{ role: 'user', content: prompt }],
      }),
    });
    const data = await response.json();
    return data.content[0].text;
  }

  async completeStructured<T>(prompt: string, schema: object): Promise<T> {
    // Implement with tool-use or prompt-engineering
    const text = await this.complete(prompt);
    return JSON.parse(text) as T;
  }
}

Related Packages

License

MIT