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/ollamaUsage
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 tohttp://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 tonomic-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:liveThat 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:extendedNotes:
- The preflight checks
OLLAMA_BASE_URLfirst and defaults tohttp://127.0.0.1:11434. - The default live model is
qwen3.5:4b; overrideOLLAMA_LIVE_MODELonly if you want a different local model. - If
nomic-embed-text:latestis installed, the live lane also covers local embeddings. Override it withOLLAMA_LIVE_EMBED_MODELif needed. smokecovers fast adapter invariants;extendedruns 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 testruns 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
π Quickstart: Getting Up and Running Get started with modular databases in minutes. Install prerequisites and deploy your first module.
π¦ Modular PostgreSQL Development with Database Packages Learn to organize PostgreSQL projects with pgpm workspaces and reusable database modules.
βοΈ Authoring Database Changes Master the workflow for adding, organizing, and managing database changes with pgpm.
π§ͺ End-to-End PostgreSQL Testing with TypeScript Master end-to-end PostgreSQL testing with ephemeral databases, RLS testing, and CI/CD automation.
β‘ Supabase Testing Use TypeScript-first tools to test Supabase projects with realistic RLS, policies, and auth contexts.
π§ Drizzle ORM Testing Run full-stack tests with Drizzle ORM, including database setup, teardown, and RLS enforcement.
π§ Troubleshooting Common issues and solutions for pgpm, PostgreSQL, and testing.
Related Constructive Tooling
π¦ 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 settingrole,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-testingCredits
π 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.