Expand description
Backend-agnostic AI inference for LaminarDB.
AI SQL functions (ai_classify, ai_embed, ai_complete, …) are task
contracts with fixed input/output. A named model from the ModelRegistry
satisfies a contract; the model’s backend — local ONNX or a remote LLM — is
hidden behind a single InferenceProvider. This crate holds the pieces
that know nothing about Ring 0: the registry, the provider trait, request
and response types, and (in later batches) the result cache, call log,
adapters, and concrete backends.
Nothing here runs on the hot path. Inference is driven from a Ring 1 worker
off the compute thread; see the operator in laminar-db.
Re-exports§
pub use adapter::parse_response;pub use adapter::AdapterError;pub use cache::content_hash;pub use cache::params_version;pub use cache::AiCacheKey;pub use cache::AiResultCache;pub use cache::AiResultCacheConfig;pub use cache::CachedOutput;pub use call_log::AiCallLog;pub use call_log::AiCallRecord;pub use call_log::CallOutcome;pub use provider::InferenceOutputs;pub use provider::InferenceParams;pub use provider::InferenceProvider;pub use provider::InferenceRequest;pub use provider::InferenceResponse;pub use provider::ProviderError;pub use provider::Usage;pub use registry::BackendKind;pub use registry::ModelBackend;pub use registry::ModelEntry;pub use registry::ModelRegistry;pub use registry::RegistryError;pub use registry::Task;pub use runtime::AiRuntime;pub use runtime::AiRuntimeError;pub use runtime::ResolvedModel;
Modules§
- adapter
- Resolve a raw provider response into a task’s per-row output, given the
(task, backend)pair. Local classification takes argmax over logits (equal to argmax of softmax — classify returns only the label, so no softmax). Sentiment is numeric: local softmaxes the logits toP(pos) − P(neg), remote parses a number from the reply — a continuous score in[-1, 1]. Stays Arrow-free: returnsInferenceOutputs; the operator builds the column. - backends
- Concrete inference backends.
- cache
- Result cache for AI inference, keyed
(content_hash, model_id, params_version). - call_
log - Bounded in-memory log of inference calls, surfaced as
laminar.ai_calls. - provider
- The single transport abstraction over a model backend.
- registry
- The model registry: the curated catalog that maps a SQL-referenced model name to the backend that runs it and the tasks it can serve.
- runtime
- The assembled AI subsystem: the model registry, the provider clients that back it, the shared result cache, and the call log.