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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ddse/acm-llm

v0.5.0

Published

ACM v0.5 LLM - Provider-agnostic LLM client

Readme

@ddse/acm-llm

OpenAI-compatible LLM client with streaming support for Ollama and vLLM.

Overview

The LLM package provides a unified client interface for local LLM providers using the OpenAI-compatible API format. It supports both standard request/response and streaming modes.

Installation

pnpm add @ddse/acm-llm @ddse/acm-sdk

Features

  • ✅ OpenAI-compatible API interface
  • ✅ Streaming support
  • ✅ Works with Ollama and vLLM out of the box
  • ✅ Configurable base URLs
  • ✅ Optional API key support
  • ✅ Zero external dependencies

Usage

Basic Usage with Ollama

import { createOllamaClient } from '@ddse/acm-llm';

const client = createOllamaClient('llama3.1');

const response = await client.generate([
  { role: 'user', content: 'What is 2+2?' }
], {
  temperature: 0.7,
  maxTokens: 100,
});

console.log(response.text);

Streaming

import { createOllamaClient } from '@ddse/acm-llm';

const client = createOllamaClient('llama3.1');

for await (const chunk of client.generateStream([
  { role: 'user', content: 'Count to 10' }
])) {
  if (!chunk.done) {
    process.stdout.write(chunk.delta);
  }
}

Using vLLM

import { createVLLMClient } from '@ddse/acm-llm';

const client = createVLLMClient('qwen2.5:7b');

const response = await client.generate([
  { role: 'system', content: 'You are a helpful assistant.' },
  { role: 'user', content: 'Hello!' }
]);

Custom Configuration

import { OpenAICompatClient } from '@ddse/acm-llm';

const client = new OpenAICompatClient({
  baseUrl: 'http://localhost:8000/v1',
  apiKey: 'optional-key',
  model: 'my-model',
  name: 'my-provider',
});

With ACM Planner

import { createOllamaClient } from '@ddse/acm-llm';
import { StructuredLLMPlanner } from '@ddse/acm-planner';

const llm = createOllamaClient('llama3.1');
const planner = new StructuredLLMPlanner();

const { plans } = await planner.plan({
  goal: { id: 'g1', intent: 'Process order' },
  context: { id: 'ctx1', facts: { orderId: 'O123' } },
  capabilities: [{ name: 'search' }, { name: 'process' }],
  llm,
});

API Reference

OpenAICompatClient

Constructor:

new OpenAICompatClient({
  baseUrl: string;
  apiKey?: string;
  model: string;
  name: string;
})

Methods:

name(): string

Returns the provider name.

generate(messages, opts?): Promise

Generate a completion.

Parameters:

  • messages: ChatMessage[] - Array of chat messages
  • opts?: { temperature?, seed?, maxTokens? } - Optional generation options

Returns: Promise<LLMResponse>

{
  text: string;
  tokens?: number;
  raw?: any;
}

generateStream(messages, opts?): AsyncIterableIterator

Generate a streaming completion.

Parameters:

  • Same as generate()

Yields: LLMStreamChunk

{
  delta: string;
  done: boolean;
}

Helper Functions

createOllamaClient(model, baseUrl?)

Create a client for Ollama.

Defaults:

  • baseUrl: http://localhost:11434/v1

createVLLMClient(model, baseUrl?)

Create a client for vLLM.

Defaults:

  • baseUrl: http://localhost:8000/v1

Types

ChatMessage

type ChatMessage = {
  role: 'system' | 'user' | 'assistant';
  content: string;
};

LLMResponse

type LLMResponse = {
  text: string;
  tokens?: number;
  raw?: any;
};

LLMStreamChunk

type LLMStreamChunk = {
  delta: string;
  done: boolean;
};

Provider Setup

Ollama

  1. Install Ollama from https://ollama.ai
  2. Pull a model: ollama pull llama3.1
  3. Start server: ollama serve
  4. Default endpoint: http://localhost:11434/v1

vLLM

  1. Install vLLM: pip install vllm
  2. Start server: vllm serve <model-name> --port 8000
  3. Default endpoint: http://localhost:8000/v1

Error Handling

The client throws errors for:

  • Network failures
  • Invalid responses
  • Non-2xx status codes
try {
  const response = await client.generate([...]);
} catch (error) {
  console.error('LLM error:', error.message);
}

Performance Tips

  • Use streaming for long responses to improve UX
  • Set appropriate maxTokens limits
  • Use temperature: 0 for deterministic outputs
  • Set seed for reproducible generation

License

Apache-2.0