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-embedding

v0.1.0

Published

Embedding provider abstraction with OpenAI, Cohere, and HuggingFace adapters

Readme

@reaatech/agent-memory-embedding

npm version License: MIT CI

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

Embedding provider abstraction for semantic memory search. Ships with OpenAI, Cohere, and HuggingFace adapters, plus an in-memory caching layer with TTL support.

Installation

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

Feature Overview

  • 3 embedding providers — OpenAI (text-embedding-3-small, text-embedding-3-large), Cohere, HuggingFace Inference API
  • Pluggable cachingInMemoryEmbeddingCache with configurable max size and TTL
  • Cached provider wrapperCachedEmbeddingProvider decorates any provider with transparent caching
  • Batch embeddingembedBatch() for efficiently vectorizing multiple texts
  • Implements shared interface — all providers conform to EmbeddingProvider
  • Dual ESM/CJS output — works with import and require

Quick Start

import {
  OpenAIEmbeddingProvider,
  CachedEmbeddingProvider,
  InMemoryEmbeddingCache,
} from '@reaatech/agent-memory-embedding';

// Base provider
const base = new OpenAIEmbeddingProvider({
  apiKey: process.env.OPENAI_API_KEY,
  model: 'text-embedding-3-small',
  dimensions: 1536,
});

// Wrap with caching (recommended)
const embedder = new CachedEmbeddingProvider(
  base,
  new InMemoryEmbeddingCache({ maxSize: 1000, ttlMs: 60000 }),
);

// Single text embedding
const vector = await embedder.embed('What does the user like?');

// Batch embedding
const vectors = await embedder.embedBatch([
  'User prefers dark mode',
  'User lives in Seattle',
  'User is a software engineer',
]);

API Reference

EmbeddingProvider Interface

The contract all providers implement:

interface EmbeddingProvider {
  embed(text: string): Promise<number[]>;
  embedBatch(texts: string[]): Promise<number[][]>;
  getModelInfo(): ModelInfo;
}

ModelInfo

interface ModelInfo {
  name: string;
  dimensions: number;
  maxInputLength: number;
}

OpenAIEmbeddingProvider (class)

const provider = new OpenAIEmbeddingProvider({
  apiKey: process.env.OPENAI_API_KEY,
  model: 'text-embedding-3-small',
  dimensions: 1536,            // optional — max 3072 for large model
  baseUrl: 'https://api.openai.com/v1',  // optional
});

| Option | Type | Default | Description | |--------|------|---------|-------------| | apiKey | string | (required) | OpenAI API key | | model | string | (required) | Model name | | dimensions | number | (model default) | Output vector dimensions | | baseUrl | string | https://api.openai.com/v1 | Custom API endpoint |

CohereEmbeddingProvider (class)

const provider = new CohereEmbeddingProvider({
  apiKey: process.env.COHERE_API_KEY,
  model: 'embed-english-v3.0',
  dimensions: 1024,
});

HuggingFaceEmbeddingProvider (class)

const provider = new HuggingFaceEmbeddingProvider({
  apiKey: process.env.HF_API_KEY,
  model: 'sentence-transformers/all-MiniLM-L6-v2',
});

EmbeddingCache Interface

interface EmbeddingCache {
  get(key: string): Promise<number[] | null>;
  set(key: string, vector: number[]): Promise<void>;
}

InMemoryEmbeddingCache (class)

LRU cache with TTL eviction:

const cache = new InMemoryEmbeddingCache({
  maxSize: 1000,   // max entries (default: 1000)
  ttlMs: 60000,    // entry TTL in ms (default: 5 min)
});

cache.set('text-to-cache', [0.1, 0.2, 0.3]);
const vector = await cache.get('text-to-cache');

cache.clear();     // remove all entries
cache.size();      // current entry count

CachedEmbeddingProvider (class)

Decorates any EmbeddingProvider with caching:

const cached = new CachedEmbeddingProvider(
  baseProvider,
  new InMemoryEmbeddingCache(),
);

// First call hits the API; subsequent calls return cached
const v1 = await cached.embed('User prefers dark mode');
const v2 = await cached.embed('User prefers dark mode'); // cached

Usage Patterns

Cohere Provider

import { CohereEmbeddingProvider } from '@reaatech/agent-memory-embedding';

const cohere = new CohereEmbeddingProvider({
  apiKey: process.env.COHERE_API_KEY,
  model: 'embed-english-v3.0',
});

const vector = await cohere.embed('User prefers dark mode');

HuggingFace Inference API

import { HuggingFaceEmbeddingProvider } from '@reaatech/agent-memory-embedding';

const hf = new HuggingFaceEmbeddingProvider({
  apiKey: process.env.HF_API_KEY,
  model: 'BAAI/bge-small-en-v1.5',
});

const vectors = await hf.embedBatch([
  'User prefers dark mode',
  'User lives in Seattle',
]);

Related Packages

License

MIT