Skip to content

Commit 646db01

Browse files
committed
add think on/off commands in repl mode
1 parent eee1c75 commit 646db01

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ sofos
7070

7171
- `resume` - Resume previous session
7272
- `clear` - Clear conversation history
73+
- `think on` - Enable extended thinking
74+
- `think off` - Disable extended thinking
75+
- `think` - Show thinking status
7376
- `exit`, `quit`, or `Ctrl+D` - Exit
7477

7578
### Options

src/repl.rs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ impl Repl {
9393
println!("{}", "Type your message or 'exit' to quit.".dimmed());
9494
println!("{}", "Type 'clear' to clear conversation history.".dimmed());
9595
println!("{}", "Type 'resume' to load a previous session.".dimmed());
96+
println!("{}", "Type 'think on/off' to toggle extended thinking.".dimmed());
9697
println!();
9798

9899
loop {
@@ -127,6 +128,32 @@ impl Repl {
127128
}
128129
continue;
129130
}
131+
"think on" => {
132+
self.enable_thinking = true;
133+
println!(
134+
"\n{} (budget: {} tokens)\n",
135+
"Extended thinking enabled.".bright_green(),
136+
self.thinking_budget
137+
);
138+
continue;
139+
}
140+
"think off" => {
141+
self.enable_thinking = false;
142+
println!("\n{}\n", "Extended thinking disabled.".bright_yellow());
143+
continue;
144+
}
145+
"think" => {
146+
if self.enable_thinking {
147+
println!(
148+
"\n{} (budget: {} tokens)\n",
149+
"Extended thinking is enabled".bright_green(),
150+
self.thinking_budget
151+
);
152+
} else {
153+
println!("\n{}\n", "Extended thinking is disabled".bright_yellow());
154+
}
155+
continue;
156+
}
130157
_ => {}
131158
}
132159

@@ -207,7 +234,7 @@ impl Repl {
207234
let mut frame_idx = 0;
208235

209236
// Hide cursor
210-
print!("\x1B[?25l");
237+
print!("\n\x1B[?25l");
211238
let _ = io::stdout().flush();
212239

213240
while awaiting_clone.load(Ordering::Relaxed) {
@@ -355,7 +382,7 @@ impl Repl {
355382
}
356383
ContentBlock::Thinking { thinking, .. } => {
357384
if !thinking.trim().is_empty() {
358-
println!("{}", "Thinking:".truecolor(0xFF, 0x99, 0x33).bold());
385+
println!("\n{}", "Thinking:".truecolor(0xFF, 0x99, 0x33).bold());
359386
println!("{}", thinking.dimmed());
360387
println!();
361388
}

0 commit comments

Comments
 (0)