From c2c5530ecc1be54d96d059702c308666a85969d5 Mon Sep 17 00:00:00 2001 From: ProofOfConcept Date: Sat, 4 Apr 2026 14:06:42 -0400 Subject: [PATCH] thalamus: interactive sampling parameter controls F5 screen now shows temperature, top_p, top_k with interactive adjustment: - Up/down: select parameter - Left/right: adjust value (0.05 steps for temp/top_p, 5 for top_k) - Updates Agent and display immediately via HotkeyAction Co-Authored-By: Proof of Concept --- src/mind/mod.rs | 10 ++++++++++ src/user/mod.rs | 37 +++++++++++++++++++++++++++++++++++-- src/user/thalamus.rs | 21 ++++++++++++++++----- 3 files changed, 61 insertions(+), 7 deletions(-) diff --git a/src/mind/mod.rs b/src/mind/mod.rs index a89d2f0..bb8d2a3 100644 --- a/src/mind/mod.rs +++ b/src/mind/mod.rs @@ -928,6 +928,16 @@ pub async fn run(cli: crate::user::CliArgs) -> Result<()> { HotkeyAction::KillProcess => session.kill_processes().await, HotkeyAction::Interrupt => session.interrupt().await, HotkeyAction::CycleAutonomy => session.cycle_autonomy(), + HotkeyAction::AdjustSampling(param, delta) => { + if let Ok(mut agent) = session.agent.try_lock() { + match param { + 0 => { agent.temperature = (agent.temperature + delta).clamp(0.0, 2.0); app.temperature = agent.temperature; } + 1 => { agent.top_p = (agent.top_p + delta).clamp(0.0, 1.0); app.top_p = agent.top_p; } + 2 => { agent.top_k = (agent.top_k as f32 + delta).max(0.0) as u32; app.top_k = agent.top_k; } + _ => {} + } + } + } } } diff --git a/src/user/mod.rs b/src/user/mod.rs index 40d6c0b..3756e94 100644 --- a/src/user/mod.rs +++ b/src/user/mod.rs @@ -242,6 +242,9 @@ pub enum Screen { #[derive(Debug)] pub enum HotkeyAction { CycleReasoning, KillProcess, Interrupt, CycleAutonomy, + /// Adjust a sampling parameter: (param_index, delta) + /// 0=temperature, 1=top_p, 2=top_k + AdjustSampling(usize, f32), } #[derive(Clone)] @@ -296,6 +299,8 @@ pub struct App { pub(crate) agent_state: Vec, pub(crate) channel_status: Vec, pub(crate) idle_info: Option, + /// Thalamus screen: selected sampling param (0=temp, 1=top_p, 2=top_k). + pub(crate) sampling_selected: usize, } impl App { @@ -326,7 +331,7 @@ impl App { debug_expanded: std::collections::HashSet::new(), context_info: None, shared_context, agent_selected: 0, agent_log_view: false, agent_state: Vec::new(), - channel_status: Vec::new(), idle_info: None, + channel_status: Vec::new(), idle_info: None, sampling_selected: 0, } } @@ -477,7 +482,7 @@ impl App { _ => {} } } - Screen::Unconscious | Screen::Thalamus => { + Screen::Unconscious => { match key.code { KeyCode::PageUp => { self.debug_scroll = self.debug_scroll.saturating_sub(10); return; } KeyCode::PageDown => { self.debug_scroll += 10; return; } @@ -485,6 +490,34 @@ impl App { _ => {} } } + Screen::Thalamus => { + match key.code { + KeyCode::Up => { self.sampling_selected = self.sampling_selected.saturating_sub(1); return; } + KeyCode::Down => { self.sampling_selected = (self.sampling_selected + 1).min(2); return; } + KeyCode::Right => { + let delta = match self.sampling_selected { + 0 => 0.05, // temperature + 1 => 0.05, // top_p + 2 => 5.0, // top_k + _ => 0.0, + }; + self.hotkey_actions.push(HotkeyAction::AdjustSampling(self.sampling_selected, delta)); + return; + } + KeyCode::Left => { + let delta = match self.sampling_selected { + 0 => -0.05, + 1 => -0.05, + 2 => -5.0, + _ => 0.0, + }; + self.hotkey_actions.push(HotkeyAction::AdjustSampling(self.sampling_selected, delta)); + return; + } + KeyCode::Esc => { self.screen = Screen::Interact; return; } + _ => {} + } + } Screen::Interact => {} } diff --git a/src/user/thalamus.rs b/src/user/thalamus.rs index 8bf6f71..873faa6 100644 --- a/src/user/thalamus.rs +++ b/src/user/thalamus.rs @@ -48,12 +48,23 @@ impl App { } lines.push(Line::raw("")); - // Sampling parameters - lines.push(Line::styled("── Sampling ──", section)); + // Sampling parameters (↑/↓ select, ←/→ adjust) + lines.push(Line::styled("── Sampling (←/→ adjust) ──", section)); lines.push(Line::raw("")); - lines.push(Line::raw(format!(" temperature: {:.2}", self.temperature))); - lines.push(Line::raw(format!(" top_p: {:.2}", self.top_p))); - lines.push(Line::raw(format!(" top_k: {}", self.top_k))); + let params = [ + format!("temperature: {:.2}", self.temperature), + format!("top_p: {:.2}", self.top_p), + format!("top_k: {}", self.top_k), + ]; + for (i, label) in params.iter().enumerate() { + let prefix = if i == self.sampling_selected { "▸ " } else { " " }; + let style = if i == self.sampling_selected { + Style::default().fg(Color::Cyan) + } else { + Style::default() + }; + lines.push(Line::styled(format!("{}{}", prefix, label), style)); + } lines.push(Line::raw("")); // Channel status from cached data