forked from kent/consciousness
thalamus: add thinking mode toggles (native + tool)
Two independent toggles on the thalamus screen: - 't' toggles native Qwen <think> tags (adds <think>\n to generation prompt) - 'T' toggles think tool (Anthropic-style structured reasoning tool) Both can be enabled simultaneously. Native thinking is on by default. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
be909028a7
commit
5d6e663b60
5 changed files with 128 additions and 1 deletions
|
|
@ -102,6 +102,8 @@ struct App {
|
|||
activity_started: Option<std::time::Instant>,
|
||||
running_processes: u32,
|
||||
reasoning_effort: String,
|
||||
think_native: bool,
|
||||
think_tool: bool,
|
||||
temperature: f32,
|
||||
top_p: f32,
|
||||
top_k: u32,
|
||||
|
|
@ -114,6 +116,8 @@ struct App {
|
|||
graph_health: Option<crate::subconscious::daemon::GraphHealth>,
|
||||
/// Agent toggle requests from UI — consumed by mind loop.
|
||||
pub agent_toggles: Vec<String>,
|
||||
/// Flag to rebuild tools section (set by thalamus screen).
|
||||
pub rebuild_tools_pending: bool,
|
||||
walked_count: usize,
|
||||
channel_status: Vec<ChannelStatus>,
|
||||
idle_info: Option<IdleInfo>,
|
||||
|
|
@ -131,6 +135,8 @@ impl App {
|
|||
activity_started: None,
|
||||
running_processes: 0,
|
||||
reasoning_effort: "none".to_string(),
|
||||
think_native: true,
|
||||
think_tool: false,
|
||||
temperature: 0.6,
|
||||
top_p: 0.95,
|
||||
top_k: 20,
|
||||
|
|
@ -142,6 +148,7 @@ impl App {
|
|||
mind_state: None,
|
||||
graph_health: None,
|
||||
agent_toggles: Vec::new(),
|
||||
rebuild_tools_pending: false,
|
||||
walked_count: 0,
|
||||
channel_status: Vec::new(), idle_info: None,
|
||||
}
|
||||
|
|
@ -445,6 +452,12 @@ async fn run(
|
|||
});
|
||||
}
|
||||
|
||||
// Rebuild tools if requested (e.g., think tool toggled)
|
||||
if app.rebuild_tools_pending {
|
||||
app.rebuild_tools_pending = false;
|
||||
agent.rebuild_tools().await;
|
||||
}
|
||||
|
||||
if !pending.is_empty() { idle_state.user_activity(); }
|
||||
|
||||
while !pending.is_empty() || dirty {
|
||||
|
|
|
|||
|
|
@ -43,6 +43,32 @@ impl ScreenView for ThalamusScreen {
|
|||
0 => -0.05, 1 => -0.05, 2 => -5.0, _ => 0.0,
|
||||
};
|
||||
}
|
||||
KeyCode::Char('t') => {
|
||||
app.think_native = !app.think_native;
|
||||
if let Ok(mut st) = app.agent.state.try_lock() {
|
||||
st.think_native = app.think_native;
|
||||
let status = if app.think_native { "enabled" } else { "disabled" };
|
||||
st.notify(format!("native thinking {}", status));
|
||||
}
|
||||
}
|
||||
KeyCode::Char('T') => {
|
||||
app.think_tool = !app.think_tool;
|
||||
if let Ok(mut st) = app.agent.state.try_lock() {
|
||||
st.think_tool = app.think_tool;
|
||||
// Add or remove the think tool from the tools list
|
||||
if app.think_tool {
|
||||
if !st.tools.iter().any(|t| t.name == "think") {
|
||||
st.tools.push(crate::agent::tools::think_tool());
|
||||
}
|
||||
st.notify("think tool enabled");
|
||||
} else {
|
||||
st.tools.retain(|t| t.name != "think");
|
||||
st.notify("think tool disabled");
|
||||
}
|
||||
}
|
||||
// Trigger tools rebuild to update the system prompt
|
||||
app.rebuild_tools_pending = true;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
@ -80,6 +106,25 @@ impl ScreenView for ThalamusScreen {
|
|||
}
|
||||
lines.push(Line::raw(""));
|
||||
|
||||
// Thinking mode
|
||||
lines.push(Line::styled("── Thinking (t/T toggle) ──", section));
|
||||
lines.push(Line::raw(""));
|
||||
let native_style = if app.think_native { Style::default().fg(Color::Green) } else { dim };
|
||||
let tool_style = if app.think_tool { Style::default().fg(Color::Green) } else { dim };
|
||||
lines.push(Line::from(vec![
|
||||
Span::raw(" "),
|
||||
Span::styled(if app.think_native { "●" } else { "○" }, native_style),
|
||||
Span::styled(" native <think> tags ", native_style),
|
||||
Span::styled("[t]", Style::default().fg(Color::DarkGray)),
|
||||
]));
|
||||
lines.push(Line::from(vec![
|
||||
Span::raw(" "),
|
||||
Span::styled(if app.think_tool { "●" } else { "○" }, tool_style),
|
||||
Span::styled(" think tool ", tool_style),
|
||||
Span::styled("[T]", Style::default().fg(Color::DarkGray)),
|
||||
]));
|
||||
lines.push(Line::raw(""));
|
||||
|
||||
// Sampling parameters
|
||||
lines.push(Line::styled("── Sampling (←/→ adjust) ──", section));
|
||||
lines.push(Line::raw(""));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue