/** * LlmModulePlugin * * Detects and loads the `llm_module` configuration from `metaschema_modules_public.llm_module`. * Makes the resolved embedder and chat completer available to other plugins * via the build context. * * This plugin is the foundation that enables per-database LLM configuration. * When an API has an `llm_module` configured, the embedder is resolved and * stored on the build object for other plugins (text search, text mutations) * to consume. * * Resolution order for the embedder: * 1. `defaultEmbedder` from preset options (build-time) * 2. Environment variables (EMBEDDER_PROVIDER, EMBEDDER_MODEL, EMBEDDER_BASE_URL) * 3. null — LLM features are disabled * * Per-database model/baseUrl overrides (from `llm_module` via `ctx.useLlm()`) * are applied at request time via `llmConfigStore` (AsyncLocalStorage) in * the text-search-plugin resolver wrapper. The same embedder function — and * its metering wrapper — handles every request; only the model name and * base URL parameters change per-tenant. * * This plugin is intentionally pure — no billing or metering logic. * The optional LlmMeteringPlugin wraps the embedder with billing integration * if loaded (it runs after this plugin and before the consumer plugins). */ import type { GraphileConfig } from 'graphile-config'; import type { ChatFunction, EmbedderFunction, GraphileLlmOptions } from '../types'; declare global { namespace GraphileBuild { interface Build { /** The resolved embedder function, or null if LLM is not configured */ llmEmbedder: EmbedderFunction | null; /** The resolved chat completion function, or null if not configured */ llmChatCompleter: ChatFunction | null; /** The embedding model name (used as billing meter slug) */ llmEmbeddingModel: string | null; /** The chat model name (used as billing meter slug) */ llmChatModel: string | null; } } namespace GraphileConfig { interface Plugins { LlmModulePlugin: true; } } } /** * Creates the LlmModulePlugin with the given options. */ export declare function createLlmModulePlugin(options?: GraphileLlmOptions): GraphileConfig.Plugin;