/** * Embedder — pluggable text-to-vector embedding for the Graphile LLM plugin * * Provides a provider-based architecture for converting text into vector * embeddings. Currently supports Ollama via @agentic-kit/ollama. * * Per-request model/baseUrl overrides are read from AsyncLocalStorage * (`llmConfigStore`). The text-search-plugin sets these overrides from * the database's `llm_module` config via `ctx.useLlm()`. This means * the same embedder function — and its metering wrapper — handle every * request, regardless of which tenant's model config applies. */ import { AsyncLocalStorage } from 'node:async_hooks'; import type { EmbedderConfig, EmbedderFunction, LlmModuleData } from './types'; /** * Per-request LLM config overrides from the database's llm_module. * Only string parameters — the embedder client itself stays the same. */ export interface LlmConfigOverrides { embeddingModel?: string; embeddingBaseUrl?: string; chatModel?: string; chatBaseUrl?: string; } /** * AsyncLocalStorage for per-request LLM config overrides. * * Set by the text-search-plugin resolver wrapper (from ctx.useLlm()), * read by the embedder at call time. The metering wrapper sits between * them and is completely unaware — it just wraps the same function. */ export declare const llmConfigStore: AsyncLocalStorage; /** * Build an embedder function from a config object. * * @returns An EmbedderFunction, or null if the provider is not recognized */ export declare function buildEmbedder(config: EmbedderConfig): EmbedderFunction | null; /** * Build an embedder from an `llm_module` row. * * @param data - The llm_module data from metaschema_modules_public.llm_module * @returns An EmbedderFunction, or null if the provider is not supported */ export declare function buildEmbedderFromModule(data: LlmModuleData): EmbedderFunction | null; /** * Resolve an embedder from environment variables. * This is a fallback for development when no llm_module or defaultEmbedder is configured. * * Environment variables (with defaults from env.ts): * EMBEDDER_PROVIDER - Provider name (default: 'ollama') * EMBEDDER_MODEL - Model identifier (default: 'nomic-embed-text') * EMBEDDER_BASE_URL - Provider base URL (default: 'http://localhost:11434') */ export declare function buildEmbedderFromEnv(): EmbedderFunction | null;