Skip to content

Commit 1f96c10

Browse files
committed
fix format
1 parent a4bd95e commit 1f96c10

File tree

2 files changed

+9
-37
lines changed

2 files changed

+9
-37
lines changed

crates/q_chat/src/lib.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3463,18 +3463,6 @@ fn create_stream(model_responses: serde_json::Value) -> StreamingClient {
34633463
StreamingClient::mock(mock)
34643464
}
34653465

3466-
/// Returns all tools supported by Q chat.
3467-
pub fn load_tools() -> Result<HashMap<String, ToolSpec>> {
3468-
let mut tools: HashMap<String, ToolSpec> = serde_json::from_str(include_str!("tools/tool_index.json"))?;
3469-
3470-
// Only include the think tool if the feature is enabled
3471-
if !tools::think::Think::should_include_in_tools() {
3472-
tools.remove("think");
3473-
}
3474-
3475-
Ok(tools)
3476-
}
3477-
34783466
#[cfg(test)]
34793467
mod tests {
34803468
use bstr::ByteSlice;

crates/q_chat/src/tools/think.rs

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use super::{
1818
/// It provides a dedicated space for the model to process information from tool call results,
1919
/// navigate complex decision trees, and improve the quality of responses in multi-step scenarios.
2020
///
21-
/// This is a beta feature that must be enabled via settings:
22-
/// `q settings enable_thinking true`
21+
/// This is a beta feature that can be enabled/disabled via settings:
22+
/// `q settings chat.enableThinking true`
2323
#[derive(Debug, Clone, Deserialize)]
2424
pub struct Think {
2525
/// The thought content that the model wants to process
@@ -28,23 +28,15 @@ pub struct Think {
2828

2929
impl Think {
3030
/// Checks if the thinking feature is enabled in settings
31-
fn is_enabled() -> bool {
31+
pub fn is_think_tool_enabled() -> bool {
3232
// Default to enabled if setting doesn't exist or can't be read
33-
settings::get_value("chat.enableThinking")
34-
.map(|val| val.and_then(|v| v.as_bool()).unwrap_or(true))
35-
.unwrap_or(true)
36-
}
37-
38-
/// Checks if the think tool should be included in the tool list
39-
/// This allows us to completely exclude the tool when the feature is disabled
40-
pub fn should_include_in_tools() -> bool {
41-
Self::is_enabled()
33+
settings::get_bool_or("chat.enableThinking", true)
4234
}
4335

4436
/// Queues up a description of the think tool for the user
4537
pub fn queue_description(think: &Think, updates: &mut impl Write) -> Result<()> {
46-
// Only show a description if the feature is enabled and there's actual thought content
47-
if Self::is_enabled() && !think.thought.trim().is_empty() {
38+
// Only show a description if there's actual thought content
39+
if !think.thought.trim().is_empty() {
4840
// Show a preview of the thought that will be displayed
4941
queue!(
5042
updates,
@@ -61,23 +53,15 @@ impl Think {
6153
/// Invokes the think tool. This doesn't actually perform any system operations,
6254
/// it's purely for the model's internal reasoning process.
6355
pub async fn invoke(&self, _updates: &mut impl Write) -> Result<InvokeOutput> {
64-
// Only process non-empty thoughts if the feature is enabled
65-
if Self::is_enabled() && !self.thought.trim().is_empty() {
66-
// We've already shown the thought in queue_description
67-
// Just return an empty output to avoid duplication
68-
return Ok(InvokeOutput {
69-
output: OutputKind::Text(String::new()),
70-
});
71-
}
72-
73-
// If disabled or empty thought, return empty output
56+
// The think tool always returns an empty output because:
57+
// 1. When enabled with content: We've already shown the thought in queue_description
58+
// 2. When disabled or empty: Nothing should be shown
7459
Ok(InvokeOutput {
7560
output: OutputKind::Text(String::new()),
7661
})
7762
}
7863

7964
/// Validates the thought - accepts empty thoughts
80-
/// Also checks if the thinking feature is enabled in settings
8165
pub async fn validate(&mut self, _ctx: &fig_os_shim::Context) -> Result<()> {
8266
// We accept empty thoughts - they'll just be ignored
8367
// This makes the tool more robust and prevents errors from blocking the model

0 commit comments

Comments
 (0)