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

@streetjs/ai

v1.1.0

Published

Official Street Framework AI module: provider-agnostic chat, embeddings, RAG, and tool-calling with OpenAI/Anthropic/Ollama adapters and a deterministic in-memory provider for tests.

Readme

@streetjs/ai

Official StreetJS Framework AI module: a provider-agnostic surface for LLM chat, embeddings, retrieval-augmented generation (RAG), and tool calling.

  • One AiProvider contract; swap implementations freely
  • Adapters: OpenAiProvider, AnthropicProvider, OllamaProvider
  • FakeAiProvider — deterministic, network-free; default for tests/offline dev
  • RagPipeline — embed → store → retrieve → answer (with InMemoryVectorStore)
  • ChatSession — a tool-calling loop (model requests tools, you run handlers)

Install

npm install @streetjs/ai

Chat

import { OpenAiProvider } from '@streetjs/ai';

const ai = new OpenAiProvider({ apiKey: process.env.OPENAI_API_KEY });
const res = await ai.chat({ messages: [{ role: 'user', content: 'Hello!' }] });
console.log(res.message.content, res.usage);

Swap providers without touching call sites:

import { AnthropicProvider, OllamaProvider } from '@streetjs/ai';
const claude = new AnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY });
const local  = new OllamaProvider({ baseUrl: 'http://127.0.0.1:11434' });

Embeddings + RAG

import { RagPipeline, OpenAiProvider } from '@streetjs/ai';

const rag = new RagPipeline({ provider: new OpenAiProvider({ apiKey }), topK: 4 });
await rag.index([
  { id: 'd1', text: 'The Eiffel Tower is in Paris.' },
  { id: 'd2', text: 'Mount Everest is the tallest mountain.' },
]);
const { answer, context } = await rag.answer('Where is the Eiffel Tower?');

Tool calling

import { ChatSession, OpenAiProvider } from '@streetjs/ai';

const session = new ChatSession({
  provider: new OpenAiProvider({ apiKey }),
  system: 'You can do arithmetic.',
  tools: [{
    name: 'add',
    description: 'Add two numbers',
    parameters: { type: 'object', properties: { a: { type: 'number' }, b: { type: 'number' } } },
    handler: ({ a, b }) => Number(a) + Number(b),
  }],
});

const { message, toolCallsExecuted } = await session.send('what is 2 + 3?');
// session runs the tool, feeds the result back, and returns the final answer

Testing without network

FakeAiProvider is deterministic and offline. Its embeddings are hashed bag-of-words vectors, so lexically similar text scores higher — enough to exercise RAG end-to-end in tests. The HTTP adapters accept an injectable fetch, so request/response handling is unit-tested without real API calls.

import { FakeAiProvider, RagPipeline } from '@streetjs/ai';
const rag = new RagPipeline({ provider: new FakeAiProvider() });

API

  • Providers: OpenAiProvider, AnthropicProvider, OllamaProvider, FakeAiProvider
  • RagPipeline (index, retrieve, answer), InMemoryVectorStore, cosineSimilarity, hashEmbedding
  • ChatSession (send, messages)
  • Types: AiProvider, ChatRequest/Response, ChatMessage, ToolCall, ToolDefinition, EmbedRequest/Response

Notes

  • AnthropicProvider does not support embeddings (use OpenAI or Ollama).
  • Tool-call wiring is implemented for the OpenAI adapter; Anthropic/Ollama adapters cover chat + (Ollama) embeddings. Function-calling for those is a tracked follow-up.

Testing

npm run test -w packages/ai     # unit + property tests, fully offline

License

MIT