#![forbid(unsafe_code)]
pub mod catalog;
pub mod cpu;
pub mod download;
pub mod fit;
pub mod gguf;
pub mod hf;
pub mod hw;
pub mod prompt;
pub mod store;
#[cfg(test)]
mod testing;
pub mod token;
pub mod worker;
#[cfg(feature = "agent")]
pub mod agent;
#[cfg(feature = "llama")]
pub mod llama;
pub use catalog::{Device, ModelSpec, human};
pub use download::{Consent, Progress, download, download_parts};
pub use hf::Hub;
pub use prompt::{ChatMessage, ChatRole};
pub use store::{ModelStore, StoredModel};
pub use token::HfToken;
pub use worker::{Chunk, Engine, GenerateRequest, Generation, Stats, Worker};
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("{0}")]
Io(#[from] std::io::Error),
#[error("network: {0}")]
Http(String),
#[error("{name}: checksum mismatch (got {got}); the file was deleted")]
Checksum { name: String, got: String },
#[error("download stopped at {done} of {total} (run it again to resume)")]
Incomplete { done: String, total: String },
#[error("download cancelled at {done} of {total} (run it again to resume)")]
Cancelled { done: String, total: String },
#[error("consent was given for another model")]
Consent,
#[error("{0:?} is not a Hugging Face model id (owner/name)")]
BadRepo(String),
#[error("{0}")]
Model(String),
#[error("local models need CPU instructions this one lacks: {}", missing.join(", "))]
UnsupportedCpu { missing: Vec<String> },
#[error("no llama.cpp CPU backend found in {} (ship the ggml-cpu libraries there)", dir.display())]
NoCpuBackend { dir: std::path::PathBuf },
}
pub type Result<T> = std::result::Result<T, Error>;