logging optimization

This commit is contained in:
Dhanji Prasanna
2025-09-27 12:18:27 +10:00
parent fb114cfcf5
commit 7595ee083e
2 changed files with 41 additions and 0 deletions

25
Cargo.lock generated
View File

@@ -1741,6 +1741,26 @@ dependencies = [
"sha2", "sha2",
] ]
[[package]]
name = "pin-project"
version = "1.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
version = "1.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "pin-project-lite" name = "pin-project-lite"
version = "0.2.16" version = "0.2.16"
@@ -2486,6 +2506,10 @@ version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
dependencies = [ dependencies = [
"futures-core",
"futures-util",
"pin-project",
"pin-project-lite",
"tower-layer", "tower-layer",
"tower-service", "tower-service",
"tracing", "tracing",
@@ -2519,6 +2543,7 @@ dependencies = [
"http-body 1.0.1", "http-body 1.0.1",
"http-body-util", "http-body-util",
"pin-project-lite", "pin-project-lite",
"tokio",
"tower-layer", "tower-layer",
"tower-service", "tower-service",
"tracing", "tracing",

View File

@@ -959,6 +959,7 @@ The tool will execute immediately and you'll receive the result (success or erro
// Check for tool calls - prioritize native tool calls over JSON parsing // Check for tool calls - prioritize native tool calls over JSON parsing
let mut detected_tool_call = None; let mut detected_tool_call = None;
let mut is_text_based_tool_call = false;
// First check for native tool calls in the chunk // First check for native tool calls in the chunk
if let Some(ref tool_calls) = chunk.tool_calls { if let Some(ref tool_calls) = chunk.tool_calls {
@@ -985,6 +986,7 @@ The tool will execute immediately and you'll receive the result (success or erro
detected_tool_call = parser.add_chunk(&chunk.content); detected_tool_call = parser.add_chunk(&chunk.content);
if detected_tool_call.is_some() { if detected_tool_call.is_some() {
debug!("Found JSON tool call in text content for native provider"); debug!("Found JSON tool call in text content for native provider");
is_text_based_tool_call = true;
} }
} }
@@ -1035,6 +1037,20 @@ The tool will execute immediately and you'll receive the result (success or erro
io::stdout().flush()?; io::stdout().flush()?;
} }
// Check if this was a JSON tool call detected from text (not native)
// If so, show a brief indicator that we detected a text-based tool call
let provider = self.providers.get(None)?;
if provider.has_native_tool_calling() && is_text_based_tool_call {
// This means we detected a JSON tool call in text for a native provider
// Show a brief indicator instead of the raw JSON
if !response_started {
print!("\r🤖 "); // Clear thinking indicator and show response indicator
response_started = true;
}
print!("🔧 "); // Brief tool call indicator
io::stdout().flush()?;
}
// Execute the tool with formatted output // Execute the tool with formatted output
println!(); // New line before tool execution println!(); // New line before tool execution