JSPM

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

Ollama

Package Exports

  • @agentic-kit/ollama
  • @agentic-kit/ollama/esm/index.js
  • @agentic-kit/ollama/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@agentic-kit/ollama) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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 (with token count from /api/embed)
const result = await client.generateEmbedding('Compute embeddings');
console.log('Embedding vector length:', result.embedding.length);
console.log('Prompt tokens:', result.promptTokens);

// 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<EmbeddingResult> β€” returns { embedding: number[], promptTokens: 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');

// Embeddings with real token counts
const result = await provider.embed('Compute embeddings', 'nomic-embed-text');
console.log(result.embedding.length, result.promptTokens);

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.


Education and Tutorials

  1. πŸš€ Quickstart: Getting Up and Running Get started with modular databases in minutes. Install prerequisites and deploy your first module.

  2. πŸ“¦ Modular PostgreSQL Development with Database Packages Learn to organize PostgreSQL projects with pgpm workspaces and reusable database modules.

  3. ✏️ Authoring Database Changes Master the workflow for adding, organizing, and managing database changes with pgpm.

  4. πŸ§ͺ End-to-End PostgreSQL Testing with TypeScript Master end-to-end PostgreSQL testing with ephemeral databases, RLS testing, and CI/CD automation.

  5. ⚑ Supabase Testing Use TypeScript-first tools to test Supabase projects with realistic RLS, policies, and auth contexts.

  6. πŸ’§ Drizzle ORM Testing Run full-stack tests with Drizzle ORM, including database setup, teardown, and RLS enforcement.

  7. πŸ”§ Troubleshooting Common issues and solutions for pgpm, PostgreSQL, and testing.

πŸ“¦ 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.
  • graphile-test: πŸ” Authentication mocking for Graphile-focused test helpers and emulating row-level security contexts.
  • pg-query-context: πŸ”’ Session context injection to add session-local context (e.g., SET LOCAL) into queriesβ€”ideal for setting role, jwt.claims, and other session settings.

🧠 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.
  • pg-proto-parser: πŸ“¦ Protobuf parser for parsing PostgreSQL Protocol Buffers definitions to generate TypeScript interfaces, utility functions, and JSON mappings for enums.
  • @pgsql/enums: 🏷️ TypeScript enums for PostgreSQL AST for safe and ergonomic parsing logic.
  • @pgsql/types: πŸ“ Type definitions for PostgreSQL AST nodes in TypeScript.
  • @pgsql/utils: πŸ› οΈ AST utilities for constructing and transforming PostgreSQL syntax trees.

πŸ“š Documentation & Skills

  • constructive-skills: πŸ“– Platform documentation and AI agent skills β€” feature catalog, blueprint reference, SDK guides (i18n, billing, limits, events, uploads, security, entities, search, AI), and deployment guides.

Install skills for AI coding agents:

# All platform skills (security, blueprints, codegen, billing, etc.)
npx skills add constructive-io/constructive-skills

# Individual repo skills (pgpm, testing, CLI, search, etc.)
npx skills add https://github.com/constructive-io/constructive --skill pgpm
npx skills add https://github.com/constructive-io/constructive --skill constructive-testing

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.