pub type Token = u32;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ModelFormat {
Gguf,
Safetensors,
Onnx,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RuntimeKind {
Candle,
Tract,
}
impl ModelFormat {
pub fn runtime(self) -> RuntimeKind {
match self {
ModelFormat::Gguf | ModelFormat::Safetensors => RuntimeKind::Candle,
ModelFormat::Onnx => RuntimeKind::Tract,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DeviceTarget {
Auto,
MidRange,
HighEnd,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Phase {
Initialized,
Prefilling,
Decoding,
Completed,
}
impl Phase {
pub fn as_str(self) -> &'static str {
match self {
Phase::Initialized => "Initialized",
Phase::Prefilling => "Prefilling",
Phase::Decoding => "Decoding",
Phase::Completed => "Completed",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SafetyMode {
Off,
Lightweight,
SecDecoding,
Csd,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SpeculationMode {
Off,
Draft,
LeverLite,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum StopReason {
Eos,
MaxTokens,
Stopped,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn format_picks_engine() {
assert_eq!(ModelFormat::Gguf.runtime(), RuntimeKind::Candle);
assert_eq!(ModelFormat::Safetensors.runtime(), RuntimeKind::Candle);
assert_eq!(ModelFormat::Onnx.runtime(), RuntimeKind::Tract);
}
}