1use std::str::FromStr;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
5pub enum ReasoningLevel {
6 Low,
8 Medium,
10 #[default]
12 High,
13 XHigh,
15 Max,
17}
18
19impl ReasoningLevel {
20 pub const ALL: [Self; 5] = [Self::Low, Self::Medium, Self::High, Self::XHigh, Self::Max];
22
23 pub fn as_str(self) -> &'static str {
28 match self {
29 Self::Low => "low",
30 Self::Medium => "medium",
31 Self::High => "high",
32 Self::XHigh => "xhigh",
33 Self::Max => "max",
34 }
35 }
36
37 pub fn description(self) -> &'static str {
39 match self {
40 Self::Low => "Fastest responses with lighter reasoning.",
41 Self::Medium => "Balanced speed and reasoning depth.",
42 Self::High => "Deeper reasoning for tougher tasks.",
43 Self::XHigh => "Extra-high reasoning for complex tasks.",
44 Self::Max => "Maximum reasoning effort for the hardest tasks.",
45 }
46 }
47}
48
49impl FromStr for ReasoningLevel {
50 type Err = String;
51
52 fn from_str(value: &str) -> Result<Self, Self::Err> {
53 match value {
54 "low" => Ok(Self::Low),
55 "medium" => Ok(Self::Medium),
56 "high" => Ok(Self::High),
57 "xhigh" => Ok(Self::XHigh),
58 "max" => Ok(Self::Max),
59 other => Err(format!("unknown reasoning level: {other}")),
60 }
61 }
62}
63
64#[cfg(test)]
65#[path = "reasoning_test.rs"]
66mod tests;