1#![forbid(unsafe_code)]
16
17pub mod catalog;
18pub mod cpu;
19pub mod download;
20pub mod hf;
21pub mod prompt;
22pub mod store;
23#[cfg(test)]
24mod testing;
25pub mod worker;
26
27#[cfg(feature = "agent")]
28pub mod agent;
29#[cfg(feature = "llama")]
30pub mod llama;
31
32pub use catalog::{Device, ModelSpec, human};
33pub use download::{Consent, Progress, download};
34pub use prompt::{ChatMessage, ChatRole};
35pub use store::ModelStore;
36pub use worker::{Chunk, Engine, GenerateRequest, Generation, Stats, Worker};
37
38#[derive(Debug, thiserror::Error)]
40pub enum Error {
41 #[error("{0}")]
42 Io(#[from] std::io::Error),
43 #[error("network: {0}")]
44 Http(String),
45 #[error("{name}: checksum mismatch (got {got}); the file was deleted")]
46 Checksum { name: String, got: String },
47 #[error("download stopped at {done} of {total} (run it again to resume)")]
48 Incomplete { done: String, total: String },
49 #[error("download cancelled at {done} of {total} (run it again to resume)")]
50 Cancelled { done: String, total: String },
51 #[error("consent was given for another model")]
52 Consent,
53 #[error("{0:?} is not a Hugging Face model id (owner/name)")]
54 BadRepo(String),
55 #[error("{0}")]
56 Model(String),
57 #[error("local models need CPU instructions this one lacks: {}", missing.join(", "))]
59 UnsupportedCpu { missing: Vec<String> },
60 #[error("no llama.cpp CPU backend found in {} (ship the ggml-cpu libraries there)", dir.display())]
62 NoCpuBackend { dir: std::path::PathBuf },
63}
64
65pub type Result<T> = std::result::Result<T, Error>;