WOLBΛRG

Provider Architecture

Embedding, LLM, keyword search, reranker, OCR, vision, and chunking providers in Wolbarg.

What is it?

Wolbarg treats embeddings, LLMs, keyword search, rerankers, OCR, vision, chunking, and storage as swappable providers. Factories ship for common APIs; custom objects work if they match the interface.

Why does it exist?

Agents already have preferred models and endpoints. The SDK must not hardcode a single cloud vendor. Isolate factories in your app so backend switches stay in one folder — see Project layout.

Embedding providers

All factories wrap an OpenAI-compatible /embeddings HTTP API:

import {
  openaiEmbedding,
  ollamaEmbedding,
  openRouterEmbedding,
  lmStudioEmbedding,
  geminiEmbedding,
  togetherEmbedding,
  vllmEmbedding,
  openaiCompatibleEmbedding,
} from "wolbarg";

embedding: openaiEmbedding({
  apiKey: process.env.OPENAI_API_KEY!,
  model: "text-embedding-3-small",
})

embedding: ollamaEmbedding({
  apiKey: "ollama",
  model: "nomic-embed-text",
})

Custom embedding provider

const embedding = {
  model: "my-model",
  async embed(text: string) {
    /* return Float32Array */
  },
  async validate() {
    const v = await this.embed("ping");
    return { dimensions: v.length };
  },
};

Changing embedding dimensionality on an existing database throws at startup — create a new DB file or wipe data first.

LLM providers

import { openaiLlm, ollamaLlm, openRouterLlm } from "wolbarg";

llm: openaiLlm({
  apiKey: process.env.OPENAI_API_KEY!,
  model: "gpt-4.1-mini",
})

Without llm, TypeScript will not allow compress(). At runtime you get ProviderNotConfiguredError.

keywordSearch: bm25()

Enables Hybrid Search. Since 0.6.0, hybrid: true without keywordSearch throws ValidationError — there is no silent semantic-only fallback.

Rerankers

import { jinaReranker, cohereReranker, bgeReranker, crossEncoder } from "wolbarg";

reranker: jinaReranker({ apiKey: process.env.JINA_API_KEY! })

Pass rerank: true on recall. Missing reranker throws ValidationError; built-in adapters throw RerankError on failure. See Rerankers.

OCR and vision

import { tesseract, geminiVision, openaiVision } from "wolbarg";

ocr: tesseract(),
vision: geminiVision({ apiKey: process.env.GEMINI_API_KEY! }),

See OCR and Vision Models.

Chunking

import { createChunkingStrategy } from "wolbarg";

chunking: createChunkingStrategy("markdown")

Strategies: fixed, sentence, paragraph, markdown, heading. Overridable per ingest call.

Graph providers

Removed in 0.6.0. sqliteGraph / neo4jGraph are gone. See Graph memory (removed).

When should it be used?

Configure only the providers you exercise. A semantic-only SQLite setup needs organization + storage + embedding. Add LLM for compression, BM25 before enabling hybrid, OCR/vision for images, and a reranker before enabling rerank: true.