1pub type Token = u32;
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub enum ModelFormat {
11 Gguf,
12 Safetensors,
13 Onnx,
14}
15
16#[derive(Debug, Clone, Copy, PartialEq, Eq)]
18pub enum RuntimeKind {
19 Candle,
21 Tract,
23}
24
25impl ModelFormat {
26 pub fn runtime(self) -> RuntimeKind {
29 match self {
30 ModelFormat::Gguf | ModelFormat::Safetensors => RuntimeKind::Candle,
31 ModelFormat::Onnx => RuntimeKind::Tract,
32 }
33 }
34}
35
36#[derive(Debug, Clone, Copy, PartialEq, Eq)]
39pub enum DeviceTarget {
40 Auto,
41 MidRange,
42 HighEnd,
43}
44
45#[derive(Debug, Clone, Copy, PartialEq, Eq)]
47pub enum Phase {
48 Initialized,
49 Prefilling,
50 Decoding,
51 Completed,
52}
53
54impl Phase {
55 pub fn as_str(self) -> &'static str {
56 match self {
57 Phase::Initialized => "Initialized",
58 Phase::Prefilling => "Prefilling",
59 Phase::Decoding => "Decoding",
60 Phase::Completed => "Completed",
61 }
62 }
63}
64
65#[derive(Debug, Clone, Copy, PartialEq, Eq)]
67pub enum SafetyMode {
68 Off,
69 Lightweight,
70 SecDecoding,
71 Csd,
72}
73
74#[derive(Debug, Clone, Copy, PartialEq, Eq)]
76pub enum SpeculationMode {
77 Off,
78 Draft,
79 LeverLite,
80}
81
82#[derive(Debug, Clone, Copy, PartialEq, Eq)]
84pub enum StopReason {
85 Eos,
86 MaxTokens,
87 Stopped,
88}
89
90#[cfg(test)]
91mod tests {
92 use super::*;
93
94 #[test]
95 fn format_picks_engine() {
96 assert_eq!(ModelFormat::Gguf.runtime(), RuntimeKind::Candle);
97 assert_eq!(ModelFormat::Safetensors.runtime(), RuntimeKind::Candle);
98 assert_eq!(ModelFormat::Onnx.runtime(), RuntimeKind::Tract);
99 }
100}