1use std::path::PathBuf;
2
3pub type Result<T> = std::result::Result<T, WaxError>;
4
5#[derive(Debug, thiserror::Error)]
6pub enum WaxError {
7 #[error("I/O error: {0}")]
8 Io(#[from] std::io::Error),
9
10 #[error("JSON error: {0}")]
11 Json(#[from] serde_json::Error),
12
13 #[error("Candle error: {0}")]
14 Candle(#[from] candle_core::Error),
15
16 #[error("Tokenizer error: {0}")]
17 Tokenizer(String),
18
19 #[error("unsupported architecture: {architecture}. This engine currently supports only Llama-like causal LM models.")]
20 UnsupportedArchitecture { architecture: String },
21
22 #[error("missing required model file: {0}")]
23 MissingModelFile(PathBuf),
24
25 #[error("invalid model folder {path}: {reason}")]
26 InvalidModelFolder { path: PathBuf, reason: String },
27
28 #[error("unsupported model format: {format}. {message}")]
29 UnsupportedModelFormat {
30 format: &'static str,
31 message: String,
32 },
33
34 #[error("invalid generation request: {0}")]
35 InvalidRequest(String),
36}
37
38impl WaxError {
39 pub(crate) fn tokenizer(err: impl std::fmt::Display) -> Self {
40 Self::Tokenizer(err.to_string())
41 }
42}