Skip to main content

laminar_ai/
lib.rs

1//! Backend-agnostic AI inference for `LaminarDB`.
2//!
3//! AI SQL functions (`ai_classify`, `ai_embed`, `ai_complete`, …) are task
4//! contracts with fixed input/output. A named model from the [`ModelRegistry`]
5//! satisfies a contract; the model's backend — local ONNX or a remote LLM — is
6//! hidden behind a single [`InferenceProvider`]. This crate holds the pieces
7//! that know nothing about Ring 0: the registry, the provider trait, request
8//! and response types, and (in later batches) the result cache, call log,
9//! adapters, and concrete backends.
10//!
11//! Nothing here runs on the hot path. Inference is driven from a Ring 1 worker
12//! off the compute thread; see the operator in `laminar-db`.
13
14#![deny(missing_docs)]
15#![warn(clippy::all, clippy::pedantic)]
16#![allow(clippy::duration_suboptimal_units)] // MSRV 1.85; from_mins/from_hours are 1.91+
17#![allow(clippy::module_name_repetitions)]
18#![allow(clippy::disallowed_types)] // cold path: registry/planning + background inference only
19#![allow(clippy::doc_markdown)] // product/provider names (ONNX, OpenAI, …) read better unticked
20
21pub mod adapter;
22#[cfg(any(feature = "remote", feature = "local"))]
23pub mod backends;
24pub mod cache;
25pub mod call_log;
26pub mod provider;
27pub mod registry;
28pub mod runtime;
29
30pub use adapter::{parse_response, AdapterError};
31pub use cache::{
32    content_hash, params_version, AiCacheKey, AiResultCache, AiResultCacheConfig, CachedOutput,
33};
34pub use call_log::{AiCallLog, AiCallRecord, CallOutcome};
35pub use provider::{
36    InferenceOutputs, InferenceParams, InferenceProvider, InferenceRequest, InferenceResponse,
37    ProviderError, Usage,
38};
39pub use registry::{BackendKind, ModelBackend, ModelEntry, ModelRegistry, RegistryError, Task};
40pub use runtime::{AiRuntime, AiRuntimeError, ResolvedModel};