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