JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 912
  • Score
    100M100P100Q121378F
  • License SEE LICENSE IN LICENSE

Ollama

Package Exports

  • @agentic-kit/ollama

Readme

@agentic-kit/ollama

A JavaScript/TypeScript client and provider adapter for the Ollama API, supporting model listing, structured streaming text generation, embeddings, and model management.

Installation

npm install @agentic-kit/ollama

Usage

import OllamaClient, { GenerateInput } from '@agentic-kit/ollama';

// Create a client (default port 11434)
const client = new OllamaClient('http://localhost:11434');

// List available models
const models = await client.listModels();
console.log('Available models:', models);

// Non-streaming text generation
const output = await client.generate({ model: 'mistral', prompt: 'Hello, Ollama!' });
console.log(output);

// Streaming generation
await client.generate(
  { model: 'mistral', prompt: 'Hello, streaming!', stream: true },
  (chunk) => {
    console.log('Received chunk:', chunk);
  }
);

// Pull a model to local cache
await client.pullModel('mistral');

// Generate embeddings
const embedding = await client.generateEmbedding('Compute embeddings');
console.log('Embedding vector length:', embedding.length);

// Delete a pulled model when done
await client.deleteModel('mistral');

API Reference

  • new OllamaClient(baseUrl?: string) โ€“ defaults to http://localhost:11434
  • .listModels(): Promise<string[]>
  • .showModel(model: string): Promise<{ capabilities?: string[] } | null>
  • .generate(input: GenerateInput, onChunk?: (chunk: string) => void): Promise<string | void>
  • .generateEmbedding(text: string, model?: string): Promise<number[]> โ€” defaults to nomic-embed-text
  • .pullModel(model: string): Promise<void>
  • .deleteModel(model: string): Promise<void>

Provider Adapter

import { OllamaAdapter } from '@agentic-kit/ollama';

const provider = new OllamaAdapter('http://localhost:11434');
const model = provider.createModel('llama3');

Local Live Tests

The package includes a local-only live lane that never talks to hosted providers.

OLLAMA_LIVE_MODEL=qwen3.5:4b pnpm --filter @agentic-kit/ollama test:live

That default command runs the fast smoke tier. Run the broader suite explicitly when you want slower behavioral coverage:

OLLAMA_LIVE_MODEL=qwen3.5:4b pnpm --filter @agentic-kit/ollama test:live:extended

Notes:

  • The preflight checks OLLAMA_BASE_URL first and defaults to http://127.0.0.1:11434.
  • The default live model is qwen3.5:4b; override OLLAMA_LIVE_MODEL only if you want a different local model.
  • If nomic-embed-text:latest is installed, the live lane also covers local embeddings. Override it with OLLAMA_LIVE_EMBED_MODEL if needed.
  • smoke covers fast adapter invariants; extended runs the smoke tier plus slower behavioral checks such as reasoning metadata, legacy generate, short multi-turn context, and embeddings.
  • If Ollama is not running, or the configured model is not installed, the live script exits cleanly with a skip message.
  • Normal pnpm test runs do not include the live lane.

GenerateInput type

interface GenerateInput {
  model: string;
  prompt?: string;
  messages?: ChatMessage[];
  system?: string;
  stream?: boolean;
  temperature?: number;
  maxTokens?: number;
}

Either prompt (single-turn) or messages (multi-turn) must be set.

Contributing

Please open issues or pull requests on GitHub.


๐Ÿค– AI & Agent Development

  • agentic-kit: ๐Ÿงฐ Provider-agnostic LLM adapter with streaming and multi-turn support. Swap between Anthropic, OpenAI, Ollama, and any OpenAI-compatible endpoint.

๐Ÿ“ฆ Package Management

  • pgpm: ๐Ÿ–ฅ๏ธ PostgreSQL Package Manager for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.

๐Ÿงช Testing

  • pgsql-test: ๐Ÿ“Š Isolated testing environments with per-test transaction rollbacksโ€”ideal for integration tests, complex migrations, and RLS simulation.
  • pgsql-seed: ๐ŸŒฑ PostgreSQL seeding utilities for CSV, JSON, SQL data loading, and pgpm deployment.
  • supabase-test: ๐Ÿงช Supabase-native test harness preconfigured for the local Supabase stackโ€”per-test rollbacks, JWT/role context helpers, and CI/GitHub Actions ready.

๐Ÿง  Parsing & AST

  • pgsql-parser: ๐Ÿ”„ SQL conversion engine that interprets and converts PostgreSQL syntax.
  • libpg-query-node: ๐ŸŒ‰ Node.js bindings for libpg_query, converting SQL into parse trees.
  • @pgsql/types: ๐Ÿ“ Type definitions for PostgreSQL AST nodes in TypeScript.
  • @pgsql/utils: ๐Ÿ› ๏ธ AST utilities for constructing and transforming PostgreSQL syntax trees.

Credits

๐Ÿ›  Built by the Constructive team โ€” creators of modular Postgres tooling for secure, composable backends. If you like our work, contribute on GitHub.

Disclaimer

AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.

No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.