Expand description
Model provider interface and registry for Polaris.
Provides a unified interface for AI model access, decoupling consumers from provider implementations.
§Overview
-
Provider-agnostic: Consumers depend only on this crate, not specific provider plugins.
-
Modular provider plugins: Provider crates register at runtime, allowing models to be swapped via configuration without code changes.
-
Minimal dependencies: Each provider lives in a separate crate.
§Example
use polaris_models::{ModelRegistry, ModelsPlugin};
use polaris_models::llm::LlmRequest;
use polaris_system::param::Res;
use polaris_system::system::SystemError;
use polaris_system::system;
#[system]
async fn my_agent(registry: Res<ModelRegistry>) -> Result<String, SystemError> {
let llm = registry
.llm("openai/gpt-4o")
.map_err(|e| SystemError::ExecutionError(e.to_string()))?;
let response = llm.builder()
.system("You are helpful")
.user("Hello!")
.generate()
.await
.map_err(|e| SystemError::ExecutionError(e.to_string()))?;
Ok(response.text())
}§See Also
For the full framework guide, architecture overview, and integration patterns,
see the polaris-ai crate documentation.
Re-exports§
pub use tokenizer::Tokenizer;pub use tokenizer::TokenizerPlugin;
Modules§
- dashboard
dashboard - Dashboard snapshot endpoint for the model provider registry.
- error
- Error types for the model registry.
- llm
- LLM (Large Language Model) generation capabilities.
- tokenizer
- Token counting for LLM requests and messages.
Structs§
- Model
Registry - Registry for model provider implementations.
- Models
Plugin - Plugin that provides the
ModelRegistryfor provider-agnostic model access.