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, and chunking 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.
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.
Keyword search
keywordSearch: bm25()Enables Hybrid Search. If omitted, recall stays semantic-only.
Rerankers
import { jinaReranker, cohereReranker, bgeReranker, crossEncoder } from "wolbarg";
reranker: jinaReranker({ apiKey: process.env.JINA_API_KEY! })Pass rerank: true on recall. If no reranker is configured, reranking is skipped silently. 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.
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 for hybrid, and OCR/vision for images.