1#![forbid(unsafe_code)]
15
16pub mod catalog;
17pub mod download;
18pub mod hf;
19pub mod prompt;
20pub mod store;
21#[cfg(test)]
22mod testing;
23pub mod worker;
24
25#[cfg(feature = "agent")]
26pub mod agent;
27#[cfg(feature = "llama")]
28pub mod llama;
29
30pub use catalog::{Device, ModelSpec, human};
31pub use download::{Consent, Progress, download};
32pub use prompt::{ChatMessage, ChatRole};
33pub use store::ModelStore;
34pub use worker::{Chunk, Engine, GenerateRequest, Generation, Stats, Worker};
35
36#[derive(Debug, thiserror::Error)]
38pub enum Error {
39 #[error("{0}")]
40 Io(#[from] std::io::Error),
41 #[error("network: {0}")]
42 Http(String),
43 #[error("{name}: checksum mismatch (got {got}); the file was deleted")]
44 Checksum { name: String, got: String },
45 #[error("download stopped at {done} of {total} (run it again to resume)")]
46 Incomplete { done: String, total: String },
47 #[error("download cancelled at {done} of {total} (run it again to resume)")]
48 Cancelled { done: String, total: String },
49 #[error("consent was given for another model")]
50 Consent,
51 #[error("{0:?} is not a Hugging Face model id (owner/name)")]
52 BadRepo(String),
53 #[error("{0}")]
54 Model(String),
55}
56
57pub type Result<T> = std::result::Result<T, Error>;